diff options
author | Ferdinand Thiessen <opensource@fthiessen.de> | 2024-08-12 18:11:31 +0200 |
---|---|---|
committer | Andy Scherzinger <info@andy-scherzinger.de> | 2024-08-22 08:51:58 +0200 |
commit | 1e49c8355637ab0cef611091e52d354f2a84c71d (patch) | |
tree | e29d2d6a6118a5d67bebadc32404713f785d9af4 /tests/lib/Files | |
parent | e5a14f68318a6ce11272508730be411d14549f22 (diff) | |
download | nextcloud-server-1e49c8355637ab0cef611091e52d354f2a84c71d.tar.gz nextcloud-server-1e49c8355637ab0cef611091e52d354f2a84c71d.zip |
fix: `FilenameValidator::isForbidden` should only check forbidden files
And not forbidden basenames as this is used for different purposes.
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
Diffstat (limited to 'tests/lib/Files')
-rw-r--r-- | tests/lib/Files/FilenameValidatorTest.php | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/tests/lib/Files/FilenameValidatorTest.php b/tests/lib/Files/FilenameValidatorTest.php index 1fcc03064a2..ac9ac032b64 100644 --- a/tests/lib/Files/FilenameValidatorTest.php +++ b/tests/lib/Files/FilenameValidatorTest.php @@ -252,15 +252,13 @@ class FilenameValidatorTest extends TestCase { /** * @dataProvider dataIsForbidden */ - public function testIsForbidden(string $filename, array $forbiddenNames, array $forbiddenBasenames, bool $expected): void { + public function testIsForbidden(string $filename, array $forbiddenNames, bool $expected): void { /** @var FilenameValidator&MockObject */ $validator = $this->getMockBuilder(FilenameValidator::class) - ->onlyMethods(['getForbiddenFilenames', 'getForbiddenBasenames']) + ->onlyMethods(['getForbiddenFilenames']) ->setConstructorArgs([$this->l10n, $this->database, $this->config, $this->logger]) ->getMock(); - $validator->method('getForbiddenBasenames') - ->willReturn($forbiddenBasenames); $validator->method('getForbiddenFilenames') ->willReturn($forbiddenNames); @@ -270,27 +268,19 @@ class FilenameValidatorTest extends TestCase { public function dataIsForbidden(): array { return [ 'valid name' => [ - 'a: b.txt', ['.htaccess'], [], false + 'a: b.txt', ['.htaccess'], false ], 'valid name with some more parameters' => [ - 'a: b.txt', ['.htaccess'], [], false + 'a: b.txt', ['.htaccess'], false ], 'valid name as only full forbidden should be matched' => [ - '.htaccess.sample', ['.htaccess'], [], false, + '.htaccess.sample', ['.htaccess'], false, ], 'forbidden name' => [ - '.htaccess', ['.htaccess'], [], true + '.htaccess', ['.htaccess'], true ], 'forbidden name - name is case insensitive' => [ - 'COM1', ['.htaccess', 'com1'], [], true, - ], - 'forbidden name - basename is checked' => [ - // needed for Windows namespaces - 'com1.suffix', ['.htaccess'], ['com1'], true - ], - 'forbidden name - basename is checked also with multiple extensions' => [ - // needed for Windows namespaces - 'com1.tar.gz', ['.htaccess'], ['com1'], true + 'COM1', ['.htaccess', 'com1'], true, ], ]; } |