18declare(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)) {
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));
An exception for terminatinating execution or to throw for unit testing.
__construct()
FilenameSanitizerImpl constructor.
$whitelist
Contains the whitelisted file suffixes.
isClean(string $filename)
@inheritDoc
extractFileSuffix($filename)
Extracts the suffix from the given filename.
sanitize(string $filename)
@inheritDoc
static sanitizeFileName(string $filename)
static getValidExtensions()
Valid extensions.
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...