aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files/src/components/FileEntry
diff options
context:
space:
mode:
authorMaksim Sukharev <antreesy.web@gmail.com>2024-07-22 18:02:41 +0200
committerFerdinand Thiessen <opensource@fthiessen.de>2024-07-24 13:14:56 +0200
commit5709e54b8d5e6467bbc834363b23e5cb4c1e8c98 (patch)
treee31c3eeee5dbd9c03e56996d0a990c538d3bad27 /apps/files/src/components/FileEntry
parentfd9de4024b3d9cdcde62f22f65a6428c62f367ac (diff)
downloadnextcloud-server-5709e54b8d5e6467bbc834363b23e5cb4c1e8c98.tar.gz
nextcloud-server-5709e54b8d5e6467bbc834363b23e5cb4c1e8c98.zip
fix(files): validate input when creating file/directory
Signed-off-by: Maksim Sukharev <antreesy.web@gmail.com>
Diffstat (limited to 'apps/files/src/components/FileEntry')
-rw-r--r--apps/files/src/components/FileEntry/FileEntryName.vue13
1 files changed, 6 insertions, 7 deletions
diff --git a/apps/files/src/components/FileEntry/FileEntryName.vue b/apps/files/src/components/FileEntry/FileEntryName.vue
index 4e5a3571e74..4fb907dd005 100644
--- a/apps/files/src/components/FileEntry/FileEntryName.vue
+++ b/apps/files/src/components/FileEntry/FileEntryName.vue
@@ -211,23 +211,22 @@ export default defineComponent({
isFileNameValid(name: string) {
const trimmedName = name.trim()
+ const char = trimmedName.indexOf('/') !== -1
+ ? '/'
+ : forbiddenCharacters.find((char) => trimmedName.includes(char))
+
if (trimmedName === '.' || trimmedName === '..') {
throw new Error(t('files', '"{name}" is an invalid file name.', { name }))
} else if (trimmedName.length === 0) {
throw new Error(t('files', 'File name cannot be empty.'))
- } else if (trimmedName.indexOf('/') !== -1) {
- throw new Error(t('files', '"/" is not allowed inside a file name.'))
+ } else if (char) {
+ throw new Error(t('files', '"{char}" is not allowed inside a file name.', { char }))
} else if (trimmedName.match(window.OC.config.blacklist_files_regex)) {
throw new Error(t('files', '"{name}" is not an allowed filetype.', { name }))
} else if (this.checkIfNodeExists(name)) {
throw new Error(t('files', '{newName} already exists.', { newName: name }))
}
- 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
},