diff options
author | Lukas Reschke <lukas@owncloud.com> | 2015-02-20 18:19:14 +0100 |
---|---|---|
committer | Thomas Müller <thomas.mueller@tmit.eu> | 2015-03-09 10:38:38 +0100 |
commit | 2f18a09a20cf62438c742c3020215cab03bc997d (patch) | |
tree | 44d4bc60dec64f33e5a59de3eb65471fa775bced /lib | |
parent | abacfd84dad4334e26b44b367127d45fdaf3fde6 (diff) | |
download | nextcloud-server-2f18a09a20cf62438c742c3020215cab03bc997d.tar.gz nextcloud-server-2f18a09a20cf62438c742c3020215cab03bc997d.zip |
Optimize loop
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/files/storage/common.php | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index a9ba034f4ee..091f89662d5 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -494,18 +494,21 @@ abstract class Common implements \OC\Files\Storage\Storage { } /** - * @param $fileName + * @param string $fileName + * @param string $invalidChars * @throws InvalidPathException */ private function scanForInvalidCharacters($fileName, $invalidChars) { - foreach (str_split($fileName) as $char) { - if (strpos($invalidChars, $char) !== false) { - throw new InvalidPathException('File name contains at least one invalid characters'); - } - if (ord($char) >= 0 && ord($char) <= 31) { + foreach(str_split($invalidChars) as $char) { + if (strpos($fileName, $char) !== false) { throw new InvalidPathException('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'); + } } } |