diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-04 14:03:47 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 10:38:38 +0100 |
commit | 3623f14e73046a51953872fe49853bc200ac736d (patch) | |
tree | c23a3311c6c0868be2cc43742186309e27534b6a /lib/private | |
parent | 2367797c17aafe0f0570477ff653894f3033e97c (diff) | |
download | nextcloud-server-3623f14e73046a51953872fe49853bc200ac736d.tar.gz nextcloud-server-3623f14e73046a51953872fe49853bc200ac736d.zip |
no translation service in common storage class
Diffstat (limited to 'lib/private')
-rw-r--r-- | lib/private/files/storage/common.php | 16 | ||||
-rw-r--r-- | lib/private/files/view.php | 14 |
2 files changed, 17 insertions, 13 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index e948b5aa35a..8549d5a1fad 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -13,7 +13,9 @@ use OC\Files\Cache\Scanner; use OC\Files\Cache\Storage; use OC\Files\Filesystem; use OC\Files\Cache\Watcher; +use OCP\Files\InvalidCharacterInPathException; use OCP\Files\InvalidPathException; +use OCP\Files\ReservedWordException; /** * Storage backend class for providing common filesystem operation methods @@ -476,7 +478,7 @@ abstract class Common implements \OC\Files\Storage\Storage { $this->scanForInvalidCharacters($fileName, "\\/<>:\"|?*"); $reservedNames = ['CON', 'PRN', 'AUX', 'NUL', 'COM1', 'COM2', 'COM3', 'COM4', 'COM5', 'COM6', 'COM7', 'COM8', 'COM9', 'LPT1', 'LPT2', 'LPT3', 'LPT4', 'LPT5', 'LPT6', 'LPT7', 'LPT8', 'LPT9']; if (in_array(strtoupper($fileName), $reservedNames)) { - throw new InvalidPathException($this->t("File name is a reserved word")); + throw new ReservedWordException(); } } @@ -489,7 +491,7 @@ abstract class Common implements \OC\Files\Storage\Storage { $this->scanForInvalidCharacters($fileName, "\\/"); $reservedNames = ['*']; if (in_array($fileName, $reservedNames)) { - throw new InvalidPathException($this->t('File name is a reserved word')); + throw new ReservedWordException(); } } @@ -501,19 +503,13 @@ abstract class Common implements \OC\Files\Storage\Storage { private function scanForInvalidCharacters($fileName, $invalidChars) { foreach(str_split($invalidChars) as $char) { if (strpos($fileName, $char) !== false) { - throw new InvalidPathException($this->t('File name contains at least one invalid characters')); + throw new InvalidCharacterInPathException(); } } $sanitizedFileName = filter_var($fileName, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); if($sanitizedFileName !== $fileName) { - throw new InvalidPathException($this->t('File name contains at least one invalid characters')); + throw new InvalidCharacterInPathException(); } } - - private function t($string) { - $l10n = \OC::$server->getL10N('lib'); - return $l10n->t($string); - } - } diff --git a/lib/private/files/view.php b/lib/private/files/view.php index 9d8416d2331..f14209fd925 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -11,7 +11,9 @@ namespace OC\Files; use OC\Files\Cache\Updater; use OC\Files\Mount\MoveableMount; +use OCP\Files\InvalidCharacterInPathException; use OCP\Files\InvalidPathException; +use OCP\Files\ReservedWordException; /** * Class to provide access to ownCloud filesystem via a "view", and methods for @@ -1563,8 +1565,14 @@ class View { throw new InvalidPathException($l10n->t('4-byte characters are not supported in file names')); } - /** @type \OCP\Files\Storage $storage */ - list($storage, $internalPath) = $this->resolvePath($path); - $storage->verifyPath($internalPath, $fileName); + try { + /** @type \OCP\Files\Storage $storage */ + list($storage, $internalPath) = $this->resolvePath($path); + $storage->verifyPath($internalPath, $fileName); + } catch (ReservedWordException $ex) { + throw new InvalidPathException($l10n->t('File name is a reserved word')); + } catch (InvalidCharacterInPathException $ex) { + throw new InvalidPathException($l10n->t('File name contains at least one invalid characters')); + } } } |