19declare(strict_types=1);
64 if (preg_match(
'/^ph(p[3457]?|t|tml|ar)$/i', $suffix)) {
68 return in_array($suffix, $this->whitelist,
true);
79 if ($this->
isClean($filename)) {
84 $basename = $pathInfo[
'basename'];
85 $parentPath = $pathInfo[
'dirname'] ===
'.' ?
'' : $pathInfo[
'dirname'];
88 $filename = str_replace(
'.',
'', $basename);
92 if ($parentPath ===
'') {
96 return "$parentPath/$filename";
109 return strtolower(pathinfo(
$filename, PATHINFO_EXTENSION));
__construct(array $whitelist)
FilenameSanitizerImpl constructor.
array $whitelist
Contains the whitelisted file suffixes.
isClean(string $filename)
Checks if the filename is prefixed with a valid whitelisted ending.
sanitize(string $filename)
@inheritDoc
extractFileSuffix(string $filename)
Extracts the suffix from the given filename.
static sanitizeFileName(string $filename)
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...