fix: Make forbidden filename list case insensitive again

It previously was, even if not documented, case insensitive.

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
fix/forbidden-files-insensitive
Ferdinand Thiessen 2 weeks ago
parent cc308f7b6a
commit ac730bc3b9
No known key found for this signature in database
GPG Key ID: 45FAE7268762B400

@ -1966,6 +1966,8 @@ $CONFIG = [
*
* WARNING: USE THIS ONLY IF YOU KNOW WHAT YOU ARE DOING.
*
* Note that this list is case-insensitive.
*
* Defaults to ``array('.htaccess')``
*/
'blacklisted_files' => ['.htaccess'],

@ -487,7 +487,7 @@ class Filesystem {
}
$forbiddenNames = \OCP\Util::getForbiddenFilenames();
return in_array($filename, $forbiddenNames);
return in_array(mb_strtolower($filename), $forbiddenNames);
}
/**

@ -527,6 +527,7 @@ class Util {
/**
* Get a list of reserved file names that must not be used
* This list should be checked case-insensitive, all names are returned lowercase.
* @return string[]
* @since 30.0.0
*/
@ -539,7 +540,7 @@ class Util {
\OCP\Server::get(LoggerInterface::class)->error('Invalid system config value for "blacklisted_files" is ignored.');
$invalidFilenames = ['.htaccess'];
}
self::$invalidFilenames = $invalidFilenames;
self::$invalidFilenames = array_map('mb_strtolower', $invalidFilenames);
}
return self::$invalidFilenames;
}

@ -284,7 +284,7 @@ class FilesystemTest extends \Test\TestCase {
['/etc/foo\bar/.htaccess/', true],
['/etc/foo\bar/.htaccess/foo', false],
['//foo//bar/\.htaccess/', true],
['\foo\bar\.htaccess', true],
['\foo\bar\.HTAccess', true],
];
}

Loading…
Cancel
Save