diff --git a/lib/private/files/storage/common.php b/lib/private/files/storage/common.php index 031a2f1cb7a..5de243e177a 100644 --- a/lib/private/files/storage/common.php +++ b/lib/private/files/storage/common.php @@ -512,7 +512,7 @@ abstract class Common implements \OC\Files\Storage\Storage { } } - $sanitizedFileName = filter_var($fileName, FILTER_SANITIZE_STRING, FILTER_FLAG_STRIP_LOW); + $sanitizedFileName = filter_var($fileName, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW); if($sanitizedFileName !== $fileName) { throw new InvalidCharacterInPathException(); } diff --git a/tests/lib/files/pathverificationtest.php b/tests/lib/files/pathverificationtest.php index 5d38c6291a6..65342c7799e 100644 --- a/tests/lib/files/pathverificationtest.php +++ b/tests/lib/files/pathverificationtest.php @@ -230,4 +230,30 @@ class PathVerification extends \Test\TestCase { ]; } + /** + * @dataProvider providesValidPosixPaths + */ + public function testPathVerificationValidPaths($fileName) { + $storage = new Local(['datadir' => '']); + + \Test_Helper::invokePrivate($storage, 'verifyPosixPath', [$fileName]); + \Test_Helper::invokePrivate($storage, 'verifyWindowsPath', [$fileName]); + // nothing thrown + $this->assertTrue(true); + } + + public function providesValidPosixPaths() { + return [ + ['simple'], + ['simple.txt'], + ['\''], + ['`'], + ['%'], + ['()'], + ['[]'], + ['!'], + ['$'], + ['_'], + ]; + } }