fix: disallow "/" in renamed directory and filenames
This commit is contained in:
parent
e6c674b3c6
commit
69f5db9590
@ -16,6 +16,9 @@
|
||||
@keyup.enter="submit"
|
||||
v-model.trim="name"
|
||||
/>
|
||||
<p class="invalid-name" v-if="!isValidName">
|
||||
{{ $t("errors.invalidFileName") }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="card-action">
|
||||
@ -31,6 +34,7 @@
|
||||
@click="submit"
|
||||
class="button button--flat"
|
||||
type="submit"
|
||||
:disabled="!isValidName"
|
||||
:aria-label="$t('buttons.rename')"
|
||||
:title="$t('buttons.rename')"
|
||||
>
|
||||
@ -48,6 +52,8 @@ import url from "@/utils/url";
|
||||
import { files as api } from "@/api";
|
||||
import { removePrefix } from "@/api/utils";
|
||||
|
||||
const INVALID_CHARACTERS = ["/"];
|
||||
|
||||
export default {
|
||||
name: "rename",
|
||||
data: function () {
|
||||
@ -67,6 +73,9 @@ export default {
|
||||
"isListing",
|
||||
]),
|
||||
...mapWritableState(useFileStore, ["reload", "preselect"]),
|
||||
isValidName() {
|
||||
return !INVALID_CHARACTERS.some((char) => this.name.includes(char));
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
...mapActions(useLayoutStore, ["closeHovers"]),
|
||||
@ -117,3 +126,9 @@ export default {
|
||||
},
|
||||
};
|
||||
</script>
|
||||
<style scoped>
|
||||
.invalid-name {
|
||||
color: var(--red);
|
||||
font-size: 0.9em;
|
||||
}
|
||||
</style>
|
||||
|
||||
@ -57,7 +57,8 @@
|
||||
"forbidden": "You don't have permissions to access this.",
|
||||
"internal": "Something really went wrong.",
|
||||
"notFound": "This location can't be reached.",
|
||||
"connection": "The server can't be reached."
|
||||
"connection": "The server can't be reached.",
|
||||
"invalidFileName": "The file or directory name is not valid."
|
||||
},
|
||||
"files": {
|
||||
"body": "Body",
|
||||
|
||||
Loading…
Reference in New Issue
Block a user