Skip to content
Snippets Groups Projects
Commit 2f18a09a authored by Lukas Reschke's avatar Lukas Reschke Committed by Thomas Müller
Browse files

Optimize loop

parent abacfd84
No related branches found
No related tags found
No related merge requests found
......@@ -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');
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment