Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Do not allow slash in filename when renaming
  • Loading branch information
phil-davis committed Jul 26, 2017
commit a455af2b1696ffac548a48ce0dfe6b6ac2876673
2 changes: 2 additions & 0 deletions apps/files/js/files.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@
throw t('files', '"{name}" is an invalid file name.', {name: name});
} else if (trimmedName.length === 0) {
throw t('files', 'File name cannot be empty.');
} else if (trimmedName.indexOf("/") >= 0) {
throw t('files', 'File name cannot contain "/".');
} else if (OC.fileIsBlacklisted(trimmedName)) {
throw t('files', '"{name}" has a forbidden file type/extension.', {name: name});
}
Expand Down
4 changes: 4 additions & 0 deletions apps/files/tests/js/filesSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ describe('OCA.Files.Files tests', function() {
'.. ',
'. ',
' .',
'/',
'folder/',
'/file',
'folder/file',
'foo.part',
'bar.filepart'
];
Expand Down
20 changes: 17 additions & 3 deletions tests/ui/features/renameFiles.feature
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,31 @@ Feature: renameFiles

Scenario: Rename a file using forbidden characters
When I rename the file "data.zip" to one of these names
|lorem/txt |
|.htaccess |
|lorem\txt |
|\\.txt |
Then notifications should be displayed with the text
|Could not rename "data.zip"|
|Could not rename "data.zip"|
|Could not rename "data.zip"|
|Could not rename "data.zip"|
And the file "data.zip" should be listed

Scenario: Rename a file putting a name of a file which already exists
When I rename the file "data.zip" to "lorem.txt"
Then near the file "data.zip" a tooltip with the text 'lorem.txt already exists' should be displayed
Then near the file "data.zip" a tooltip with the text 'lorem.txt already exists' should be displayed

Scenario: Rename a file using forward slash
When I rename the file "data.zip" to "lorem/txt"
Then near the file "data.zip" a tooltip with the text 'File name cannot contain "/".' should be displayed

Scenario: Rename a file to ..
When I rename the file "data.zip" to ".."
Then near the file "data.zip" a tooltip with the text '".." is an invalid file name.' should be displayed

Scenario: Rename a file to .
When I rename the file "data.zip" to "."
Then near the file "data.zip" a tooltip with the text '"." is an invalid file name.' should be displayed

Scenario: Rename a file to .part
When I rename the file "data.zip" to "data.part"
Then near the file "data.zip" a tooltip with the text '"data.part" has a forbidden file type/extension.' should be displayed
24 changes: 18 additions & 6 deletions tests/ui/features/renameFolders.feature
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,31 @@ Feature: renameFolders

Scenario: Rename a folder using forbidden characters
When I rename the folder "simple-folder" to one of these names
|simple/folder |
|.htaccess |
|simple\folder |
|\\simple/folder |
|../simple-folder|
|\\simple-folder |
Then notifications should be displayed with the text
|Could not rename "simple-folder"|
|Could not rename "simple-folder"|
|Could not rename "simple-folder"|
|Could not rename "simple-folder"|
|Could not rename "simple-folder"|
And the folder "simple-folder" should be listed

Scenario: Rename a folder putting a name of a file which already exists
When I rename the folder "simple-folder" to "lorem.txt"
Then near the folder "simple-folder" a tooltip with the text 'lorem.txt already exists' should be displayed
Then near the folder "simple-folder" a tooltip with the text 'lorem.txt already exists' should be displayed

Scenario: Rename a folder using forward slash
When I rename the folder "simple-folder" to "simple/folder"
Then near the folder "simple-folder" a tooltip with the text 'File name cannot contain "/".' should be displayed

Scenario: Rename a folder to ..
When I rename the folder "simple-folder" to ".."
Then near the folder "simple-folder" a tooltip with the text '".." is an invalid file name.' should be displayed

Scenario: Rename a folder to .
When I rename the folder "simple-folder" to "."
Then near the folder "simple-folder" a tooltip with the text '"." is an invalid file name.' should be displayed

Scenario: Rename a folder to .part
When I rename the folder "simple-folder" to "simple.part"
Then near the folder "simple-folder" a tooltip with the text '"simple.part" has a forbidden file type/extension.' should be displayed