diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php index cef9f6e88a94..861b07b256d7 100644 --- a/lib/private/legacy/util.php +++ b/lib/private/legacy/util.php @@ -1439,8 +1439,8 @@ public static function isValidFileName($file) { return false; } - $path_parts = pathinfo($trimmed); - if ($path_parts['extension'] === 'part') { + // detect part files + if (preg_match('/' . \OCP\Files\FileInfo::BLACKLIST_FILES_REGEX . '/', $trimmed) !== 0) { return false; } diff --git a/tests/lib/UtilTest.php b/tests/lib/UtilTest.php index 241fd6d63297..442ece6dcce4 100644 --- a/tests/lib/UtilTest.php +++ b/tests/lib/UtilTest.php @@ -10,6 +10,9 @@ use OC_Util; +/** + * @group DB + */ class UtilTest extends \Test\TestCase { public function testGetVersion() { $version = \OCP\Util::getVersion(); @@ -234,6 +237,13 @@ public function filenameValidationProvider() { ['.. ', false], ['. ', false], [' .', false], + // part files not allowed + ['.part', false], + ['notallowed.part', false], + ['neither.filepart', false], + // part in the middle is ok + ['super movie part one.mkv', true], + ['super.movie.part.mkv', true], ]; }