diff --git a/lib/private/Files/View.php b/lib/private/Files/View.php index 494b4493d2cba..b35912c1f7e44 100644 --- a/lib/private/Files/View.php +++ b/lib/private/Files/View.php @@ -1841,13 +1841,13 @@ public function verifyPath($path, $fileName): void { $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 0fd0c330ea5bb..f256a954f9f1d 100644 --- a/tests/lib/Files/PathVerificationTest.php +++ b/tests/lib/Files/PathVerificationTest.php @@ -32,7 +32,7 @@ protected function setUp(): void { 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);