diff options
-rw-r--r-- | build/integration/files_features/windows_compatibility.feature | 2 | ||||
-rw-r--r-- | lib/private/Files/FilenameValidator.php | 2 | ||||
-rw-r--r-- | lib/public/Files/IFilenameValidator.php | 2 | ||||
-rw-r--r-- | tests/lib/Files/FilenameValidatorTest.php | 12 |
4 files changed, 9 insertions, 9 deletions
diff --git a/build/integration/files_features/windows_compatibility.feature b/build/integration/files_features/windows_compatibility.feature index 2fdd37d67a1..feaaca1ed3a 100644 --- a/build/integration/files_features/windows_compatibility.feature +++ b/build/integration/files_features/windows_compatibility.feature @@ -54,7 +54,7 @@ Feature: Windows compatible filenames And invoking occ with "files:windows-compatible-filenames --enable" And invoking occ with "files:sanitize-filenames user0" Then as "user0" the file "/2*2=4.txt" does not exist - And as "user0" the file "/2 2=4.txt" exists + And as "user0" the file "/2_2=4.txt" exists Scenario: renaming a file with invalid character and replacement setup Given As an "admin" diff --git a/lib/private/Files/FilenameValidator.php b/lib/private/Files/FilenameValidator.php index 57a62b0b219..a78c6d3cc3c 100644 --- a/lib/private/Files/FilenameValidator.php +++ b/lib/private/Files/FilenameValidator.php @@ -232,7 +232,7 @@ class FilenameValidator implements IFilenameValidator { $forbiddenCharacters = $this->getForbiddenCharacters(); if ($charReplacement === null) { - $charReplacement = array_diff([' ', '_', '-'], $forbiddenCharacters); + $charReplacement = array_diff(['_', '-', ' '], $forbiddenCharacters); $charReplacement = reset($charReplacement) ?: ''; } if (mb_strlen($charReplacement) !== 1) { diff --git a/lib/public/Files/IFilenameValidator.php b/lib/public/Files/IFilenameValidator.php index d8bd06d179d..9b7fa1e2e2e 100644 --- a/lib/public/Files/IFilenameValidator.php +++ b/lib/public/Files/IFilenameValidator.php @@ -43,7 +43,7 @@ interface IFilenameValidator { * If no sanitizing is needed the same name is returned. * * @param string $name The filename to sanitize - * @param null|string $charReplacement Character to use for replacing forbidden ones - by default space, dash or underscore is used if allowed. + * @param null|string $charReplacement Character to use for replacing forbidden ones - by default underscore, dash or space is used if allowed. * @throws \InvalidArgumentException if no character replacement was given (and the default could not be applied) or the replacement is not valid. * @since 32.0.0 */ diff --git a/tests/lib/Files/FilenameValidatorTest.php b/tests/lib/Files/FilenameValidatorTest.php index a52971d109e..a4951c2efd3 100644 --- a/tests/lib/Files/FilenameValidatorTest.php +++ b/tests/lib/Files/FilenameValidatorTest.php @@ -438,7 +438,7 @@ class FilenameValidatorTest extends TestCase { '.thumbs.db', ['.htaccess'], ['.thumbs'], [], [], '.thumbs (renamed).db' ], 'invalid character' => [ - 'a: b.txt', ['.htaccess'], [], [], [':'], 'a b.txt', + 'a: b.txt', ['.htaccess'], [], [], [':'], 'a_ b.txt', ], 'invalid extension' => [ 'a: b.txt', ['.htaccess'], [], ['.txt'], [], 'a: b' @@ -492,13 +492,13 @@ class FilenameValidatorTest extends TestCase { public static function dataSanitizeFilenameCharacterReplacement(): array { return [ 'default' => [ - 'foo*bar', ['*'], null, 'foo bar' + 'foo*bar', ['*'], null, 'foo_bar' ], - 'default - space not allowed' => [ - 'foo*bar', ['*', ' '], null, 'foo_bar' + 'default - underscore not allowed' => [ + 'foo*bar', ['*', '_'], null, 'foo-bar' ], - 'default - space and underscore not allowed' => [ - 'foo*bar', ['*', ' ', '_'], null, 'foo-bar' + 'default - dash and underscore not allowed' => [ + 'foo*bar', ['*', '-', '_'], null, 'foo bar' ], 'default - no replacement' => [ 'foo*bar', ['*', ' ', '_', '-'], null, null |