diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-29 17:13:40 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-04-29 17:15:00 +0200 |
commit | c6f3aecef1b128dc61380960e6b027d7a3691f76 (patch) | |
tree | f7e7ad98f60d5f9e2b37525c2066f56a9cd25d59 /apps/files | |
parent | 6a281f019c73dec54f487890d7ff80d26a3f04bf (diff) | |
download | nextcloud-server-c6f3aecef1b128dc61380960e6b027d7a3691f76.tar.gz nextcloud-server-c6f3aecef1b128dc61380960e6b027d7a3691f76.zip |
fix(files): Use string array instead of string for forbidden characters
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'apps/files')
-rw-r--r-- | apps/files/lib/Controller/ViewController.php | 2 | ||||
-rw-r--r-- | apps/files/src/components/FileEntry/FileEntryName.vue | 12 |
2 files changed, 6 insertions, 8 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php index 2e6ffa6a749..5c31ae8ffd4 100644 --- a/apps/files/lib/Controller/ViewController.php +++ b/apps/files/lib/Controller/ViewController.php @@ -253,7 +253,7 @@ class ViewController extends Controller { // Forbidden file characters $forbiddenCharacters = \OCP\Util::getForbiddenFileNameChars(); - $this->initialState->provideInitialState('forbiddenCharacters', implode('', $forbiddenCharacters)); + $this->initialState->provideInitialState('forbiddenCharacters', $forbiddenCharacters); $event = new LoadAdditionalScriptsEvent(); $this->eventDispatcher->dispatchTyped($event); diff --git a/apps/files/src/components/FileEntry/FileEntryName.vue b/apps/files/src/components/FileEntry/FileEntryName.vue index 87859de353a..3b2faa4e506 100644 --- a/apps/files/src/components/FileEntry/FileEntryName.vue +++ b/apps/files/src/components/FileEntry/FileEntryName.vue @@ -70,7 +70,7 @@ import NcTextField from '@nextcloud/vue/dist/Components/NcTextField.js' import { useRenamingStore } from '../../store/renaming.ts' import logger from '../../logger.js' -const forbiddenCharacters = loadState('files', 'forbiddenCharacters', '') as string +const forbiddenCharacters = loadState<string[]>('files', 'forbiddenCharacters', []) export default Vue.extend({ name: 'FileEntryName', @@ -230,12 +230,10 @@ export default Vue.extend({ throw new Error(t('files', '{newName} already exists.', { newName: name })) } - const toCheck = trimmedName.split('') - toCheck.forEach(char => { - if (forbiddenCharacters.indexOf(char) !== -1) { - throw new Error(this.t('files', '"{char}" is not allowed inside a file name.', { char })) - } - }) + const char = forbiddenCharacters.find((char) => trimmedName.includes(char)) + if (char) { + throw new Error(t('files', '"{char}" is not allowed inside a file name.', { char })) + } return true }, |