mirror of
https://github.com/nextcloud/server.git
synced 2026-06-12 02:00:51 -04:00
Merge pull request #44996 from nextcloud/fix/unify-access-to-forbidden-chars
fix(files): Use OCP\Util::getForbiddenFileNameChars instead of directaccess to system config
This commit is contained in:
commit
316acc3cc3
5 changed files with 10 additions and 19 deletions
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
},
|
||||
|
|
|
|||
|
|
@ -152,11 +152,6 @@ class ViewControllerTest extends TestCase {
|
|||
'ownerDisplayName' => 'MyDisplayName',
|
||||
]);
|
||||
|
||||
$this->config
|
||||
->expects($this->any())
|
||||
->method('getSystemValue')
|
||||
->with('forbidden_chars', [])
|
||||
->willReturn([]);
|
||||
$this->config
|
||||
->method('getUserValue')
|
||||
->willReturnMap([
|
||||
|
|
|
|||
4
dist/files-main.js
vendored
4
dist/files-main.js
vendored
File diff suppressed because one or more lines are too long
2
dist/files-main.js.map
vendored
2
dist/files-main.js.map
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue