Skip to content
Snippets Groups Projects
Unverified Commit a8ab67ff authored by Roeland Jago Douma's avatar Roeland Jago Douma Committed by GitHub
Browse files

Merge pull request #7676 from nextcloud/fix-slash-in-filename

Show warning if slash is entered as filename
parents 02b092f3 0b4d1867
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,7 @@ namespace OCA\DAV\Connector\Sabre; ...@@ -29,6 +29,7 @@ namespace OCA\DAV\Connector\Sabre;
use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden; use OCA\DAV\Connector\Sabre\Exception\PasswordLoginForbidden;
use OCP\Files\StorageNotAvailableException; use OCP\Files\StorageNotAvailableException;
use OCP\ILogger; use OCP\ILogger;
use Sabre\DAV\Exception\Conflict;
use Sabre\DAV\Exception\Forbidden; use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\InvalidSyncToken; use Sabre\DAV\Exception\InvalidSyncToken;
use Sabre\DAV\Exception\NotAuthenticated; use Sabre\DAV\Exception\NotAuthenticated;
...@@ -61,6 +62,9 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin { ...@@ -61,6 +62,9 @@ class ExceptionLoggerPlugin extends \Sabre\DAV\ServerPlugin {
// happens if some a client uses the wrong method for a given URL // happens if some a client uses the wrong method for a given URL
// the error message itself is visible on the client side anyways // the error message itself is visible on the client side anyways
NotImplemented::class => true, NotImplemented::class => true,
// happens when the parent directory is not present (for example when a
// move is done to a non-existent directory)
Conflict::class => true,
]; ];
/** @var string */ /** @var string */
......
...@@ -128,6 +128,8 @@ ...@@ -128,6 +128,8 @@
throw t('files', '"{name}" is an invalid file name.', {name: name}); throw t('files', '"{name}" is an invalid file name.', {name: name});
} else if (trimmedName.length === 0) { } else if (trimmedName.length === 0) {
throw t('files', 'File name cannot be empty.'); throw t('files', 'File name cannot be empty.');
} else if (trimmedName.indexOf('/') !== -1) {
throw t('files', '"/" is not allowed inside a file name.');
} else if (OC.fileIsBlacklisted(trimmedName)) { } else if (OC.fileIsBlacklisted(trimmedName)) {
throw t('files', '"{name}" is not an allowed filetype', {name: name}); throw t('files', '"{name}" is not an allowed filetype', {name: name});
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment