diff options
author | Thomas Müller <thomas.mueller@tmit.eu> | 2015-02-24 19:20:59 +0300 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 12:38:38 +0300 |
commit | 33b11682f9826346f48b7587161dc5a43944a063 (patch) | |
tree | c9ed3e32598a00d9743fd09eb683fed3c3957326 | |
parent | 2f18a09a20cf62438c742c3020215cab03bc997d (diff) |
translate error messages
-rw-r--r-- | lib/private/files/storage/common.php | 17 | ||||
-rw-r--r-- | lib/private/files/view.php | 8 |
2 files changed, 16 insertions, 9 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 091f89662d5..e948b5aa35a 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -471,12 +471,12 @@ abstract class Common implements \OC\Files\Storage\Storage { * @param string $fileName * @throws InvalidPathException */ - private function verifyWindowsPath($fileName) { + protected function verifyWindowsPath($fileName) { $fileName = trim($fileName); $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("File name is a reserved word"); + throw new InvalidPathException($this->t("File name is a reserved word")); } } @@ -484,12 +484,12 @@ abstract class Common implements \OC\Files\Storage\Storage { * @param string $fileName * @throws InvalidPathException */ - private function verifyPosixPath($fileName) { + protected function verifyPosixPath($fileName) { $fileName = trim($fileName); $this->scanForInvalidCharacters($fileName, "\\/"); $reservedNames = ['*']; if (in_array($fileName, $reservedNames)) { - throw new InvalidPathException("File name is a reserved word"); + throw new InvalidPathException($this->t('File name is a reserved word')); } } @@ -501,14 +501,19 @@ 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('File name contains at least one invalid characters'); + throw new InvalidPathException($this->t('File name contains at least one invalid characters')); } } $sanitizedFileName = filter_var($fileName, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); if($sanitizedFileName !== $fileName) { - throw new InvalidPathException('File name contains at least one invalid characters'); + throw new InvalidPathException($this->t('File name contains at least one invalid characters')); } } + 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 6a93d7bbf8a..9d8416d2331 100644 --- a/lib/private/files/view.php +++ b/lib/private/files/view.php @@ -1543,13 +1543,15 @@ class View { */ public function verifyPath($path, $fileName) { + $l10n = \OC::$server->getL10N('lib'); + // verify empty and dot files $trimmed = trim($fileName); if ($trimmed === '') { - throw new InvalidPathException('Empty filename is not allowed'); + throw new InvalidPathException($l10n->t('Empty filename is not allowed')); } if ($trimmed === '.' || $trimmed === '..') { - throw new InvalidPathException('Dot files are not allowed'); + throw new InvalidPathException($l10n->t('Dot files are not allowed')); } // verify database - e.g. mysql only 3-byte chars @@ -1558,7 +1560,7 @@ class View { | [\xF1-\xF3][\x80-\xBF]{3} # planes 4-15 | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 )*$%xs', $fileName)) { - throw new InvalidPathException('4-byte characters are not supported in file names'); + throw new InvalidPathException($l10n->t('4-byte characters are not supported in file names')); } /** @type \OCP\Files\Storage $storage */ |