diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-27 19:42:00 +0200 |
---|---|---|
committer | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-27 23:12:24 +0200 |
commit | 81c6c24cd5995addd5407ff7ca4d886c7f931b32 (patch) | |
tree | 8dd5f942affc227428a5b1c33ac9faf262ddf8ac | |
parent | 5db859fd25cf56ff1e6692df3cb0821bcf24bccd (diff) | |
download | nextcloud-server-81c6c24cd5995addd5407ff7ca4d886c7f931b32.tar.gz nextcloud-server-81c6c24cd5995addd5407ff7ca4d886c7f931b32.zip |
fix: Adjust filename validation messages
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r-- | lib/private/Files/View.php | 6 | ||||
-rw-r--r-- | tests/lib/Files/PathVerificationTest.php | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 494b4493d2c..b35912c1f7e 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1841,13 +1841,13 @@ class View { $storage->verifyPath($internalPath, $fileName); } catch (ReservedWordException $ex) { $l = \OCP\Util::getL10N('lib'); - throw new InvalidPathException($l->t('File name is a reserved word')); + throw new InvalidPathException($ex->getMessage() ?: $l->t('Filename is a reserved word')); } catch (InvalidCharacterInPathException $ex) { $l = \OCP\Util::getL10N('lib'); - throw new InvalidPathException($l->t('File name contains at least one invalid character')); + throw new InvalidPathException($ex->getMessage() ?: $l->t('Filename contains at least one invalid character')); } catch (FileNameTooLongException $ex) { $l = \OCP\Util::getL10N('lib'); - throw new InvalidPathException($l->t('File name is too long')); + throw new InvalidPathException($l->t('Filename is too long')); } catch (InvalidDirectoryException $ex) { $l = \OCP\Util::getL10N('lib'); throw new InvalidPathException($l->t('Dot files are not allowed')); diff --git a/tests/lib/Files/PathVerificationTest.php b/tests/lib/Files/PathVerificationTest.php index 0fd0c330ea5..f256a954f9f 100644 --- a/tests/lib/Files/PathVerificationTest.php +++ b/tests/lib/Files/PathVerificationTest.php @@ -32,7 +32,7 @@ class PathVerificationTest extends \Test\TestCase { public function testPathVerificationFileNameTooLong() { $this->expectException(\OCP\Files\InvalidPathException::class); - $this->expectExceptionMessage('File name is too long'); + $this->expectExceptionMessage('Filename is too long'); $fileName = str_repeat('a', 500); $this->view->verifyPath('', $fileName); |