2 declare(strict_types = 1);
52 $this->allowedPaths = [
53 $GLOBALS[
'TYPO3_CONF_VARS'][
'BE'][
'fileadminDir'],
60 if (!empty(
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths'])) {
61 $paths = GeneralUtility::trimExplode(
',',
$GLOBALS[
'TYPO3_CONF_VARS'][
'FE'][
'addAllowedPaths'],
true);
62 foreach ($paths as $path) {
63 if (is_string($path)) {
64 $this->allowedPaths[] = $path;
76 public function sanitize(
string $originalFileName):
string
78 $file = trim($originalFileName);
82 if (strpos($file,
'../') !==
false) {
83 throw new InvalidPathException(
'File path "' . $file .
'" contains illegal string "../"', 1530169814);
86 $urlScheme = parse_url($file, PHP_URL_SCHEME);
92 $file = GeneralUtility::getFileAbsFileName($file);
93 if (!$file || is_dir($file)) {
100 foreach ($this->allowedPaths as $allowedPath) {
101 if (strpos((
string)$file, (
string)$allowedPath, 0) === 0) {