aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files
diff options
context:
space:
mode:
Diffstat (limited to 'apps/files')
-rw-r--r--apps/files/lib/Controller/ViewController.php6
-rw-r--r--apps/files/src/components/FileEntry/FileEntryName.vue12
-rw-r--r--apps/files/tests/Controller/ViewControllerTest.php5
3 files changed, 7 insertions, 16 deletions
diff --git a/apps/files/lib/Controller/ViewController.php b/apps/files/lib/Controller/ViewController.php
index 67cd0bf2aef..5c31ae8ffd4 100644
--- a/apps/files/lib/Controller/ViewController.php
+++ b/apps/files/lib/Controller/ViewController.php
@@ -52,7 +52,6 @@ use OCP\AppFramework\Http\Response;
use OCP\AppFramework\Http\TemplateResponse;
use OCP\AppFramework\Services\IInitialState;
use OCP\Collaboration\Resources\LoadAdditionalScriptsEvent as ResourcesLoadAdditionalScriptsEvent;
-use OCP\Constants;
use OCP\EventDispatcher\IEventDispatcher;
use OCP\Files\Folder;
use OCP\Files\IRootFolder;
@@ -253,9 +252,8 @@ class ViewController extends Controller {
$this->initialState->provideInitialState('filesSortingConfig', $filesSortingConfig);
// Forbidden file characters
- /** @var string[] */
- $forbiddenCharacters = $this->config->getSystemValue('forbidden_chars', []);
- $this->initialState->provideInitialState('forbiddenCharacters', Constants::FILENAME_INVALID_CHARS . implode('', $forbiddenCharacters));
+ $forbiddenCharacters = \OCP\Util::getForbiddenFileNameChars();
+ $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
},
diff --git a/apps/files/tests/Controller/ViewControllerTest.php b/apps/files/tests/Controller/ViewControllerTest.php
index 2714a6b25c0..79834539883 100644
--- a/apps/files/tests/Controller/ViewControllerTest.php
+++ b/apps/files/tests/Controller/ViewControllerTest.php
@@ -153,11 +153,6 @@ class ViewControllerTest extends TestCase {
]);
$this->config
- ->expects($this->any())
- ->method('getSystemValue')
- ->with('forbidden_chars', [])
- ->willReturn([]);
- $this->config
->method('getUserValue')
->willReturnMap([
[$this->user->getUID(), 'files', 'file_sorting', 'name', 'name'],