translate error messages
This commit is contained in:
parent
2f18a09a20
commit
33b11682f9
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
|
Loading…
Reference in New Issue