18 declare(strict_types=1);
61 if (preg_match(
'/^ph(p[3457]?|t|tml|ar)$/i', $suffix)) {
65 return in_array($suffix, $this->whitelist,
true);
75 if ($this->
isClean($filename)) {
79 $pathInfo = pathinfo($filename);
80 $basename = $pathInfo[
'basename'];
81 $parentPath = $pathInfo[
'dirname'];
83 $filename = str_replace(
'.',
'', $basename);
87 if ($parentPath ===
'') {
91 return "$parentPath/$filename";
102 return strtolower(pathinfo(
$filename, PATHINFO_EXTENSION));
extractFileSuffix($filename)
Extracts the suffix from the given filename.
static sanitizeFileName(string $filename)
isClean(string $filename)
__construct()
FilenameSanitizerImpl constructor.
const CLEAN_FILE_SUFFIX
This file suffix will be used to sanitize not whitelisted file names.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getValidExtensions()
Valid extensions.
sanitize(string $filename)