Skip to content

Commit bc2321d

Browse files
authored
Merge pull request #54821 from nextcloud/fix/use-filename-validator-for-filesyste
fix(Filesystem): use FilenameValidator for `Filesystem::isFileBlacklisted`
2 parents 2c0f312 + a31e520 commit bc2321d

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

lib/private/Files/Filesystem.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ class Filesystem {
3030

3131
private static ?CappedMemoryCache $normalizedPathCache = null;
3232

33-
/** @var string[]|null */
34-
private static ?array $blacklist = null;
33+
private static ?FilenameValidator $validator = null;
3534

3635
/**
3736
* classname which used for hooks handling
@@ -434,16 +433,16 @@ public static function isValidPath($path) {
434433
/**
435434
* @param string $filename
436435
* @return bool
436+
*
437+
* @deprecated 30.0.0 - use \OC\Files\FilenameValidator::isForbidden
437438
*/
438439
public static function isFileBlacklisted($filename) {
439-
$filename = self::normalizePath($filename);
440-
441-
if (self::$blacklist === null) {
442-
self::$blacklist = \OC::$server->getConfig()->getSystemValue('blacklisted_files', ['.htaccess']);
440+
if (self::$validator === null) {
441+
self::$validator = \OCP\Server::get(FilenameValidator::class);
443442
}
444443

445-
$filename = strtolower(basename($filename));
446-
return in_array($filename, self::$blacklist);
444+
$filename = self::normalizePath($filename);
445+
return self::$validator->isForbidden($filename);
447446
}
448447

449448
/**

0 commit comments

Comments
 (0)