mirror of
https://github.com/nextcloud/server.git
synced 2026-05-28 04:32:30 -04:00
Merge pull request #54844 from nextcloud/backport/54821/stable31
[stable31] fix(Filesystem): use FilenameValidator for `Filesystem::isFileBlacklisted`
This commit is contained in:
commit
5c524726d8
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);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue