Merge pull request #54844 from nextcloud/backport/54821/stable31

[stable31] fix(Filesystem): use FilenameValidator for `Filesystem::isFileBlacklisted`
pull/54849/head
Andy Scherzinger 2025-09-03 17:59:52 +07:00 committed by GitHub
commit 5c524726d8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 7 additions and 8 deletions

@ -29,8 +29,7 @@ class Filesystem {
private static ?CappedMemoryCache $normalizedPathCache = null;
/** @var string[]|null */
private static ?array $blacklist = null;
private static ?FilenameValidator $validator = null;
/**
* classname which used for hooks handling
@ -431,16 +430,16 @@ class Filesystem {
/**
* @param string $filename
* @return bool
*
* @deprecated 30.0.0 - use \OC\Files\FilenameValidator::isForbidden
*/
public static function isFileBlacklisted($filename) {
$filename = self::normalizePath($filename);
if (self::$blacklist === null) {
self::$blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']);
if (self::$validator === null) {
self::$validator = \OCP\Server::get(FilenameValidator::class);
}
$filename = strtolower(basename($filename));
return in_array($filename, self::$blacklist);
$filename = self::normalizePath($filename);
return self::$validator->isForbidden($filename);
}
/**