mirror of
https://github.com/nextcloud/server.git
synced 2026-05-25 02:34:12 -04:00
fix(Filesystem): use FilenameValidator for Filesystem::isFileBlacklisted
This fixes the issue that some methods will not allow uploading files because they still require the deprecated config option to be used. So instead we need to use the validator introduced in v30. Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
parent
347f10b64b
commit
6860d92bf4
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