Commit b3f93726 authored by Jigal van Hemert's avatar Jigal van Hemert Committed by Susanne Moog
Browse files

[TASK] Use PathUtility wrappers for basename/dirname

Basename and dirname are locale aware and can damage path and file names
if they are used with UTF-8 file/path names while a UTF-8 locale is not
loaded.
The PathUtility wrappers solve this.

Releases: master
Resolves: #74806
Change-Id: Ibe113a1632b4e61ea87ed9a7dc8600bf3535acab
Reviewed-on: https://review.typo3.org/47169


Reviewed-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarMathias Schreiber <mathias.schreiber@typo3.com>
Tested-by: default avatarTYPO3com <no-reply@typo3.com>
Reviewed-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
Tested-by: Susanne Moog's avatarSusanne Moog <susanne.moog@typo3.org>
parent 5519649d
...@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation; ...@@ -25,6 +25,7 @@ use TYPO3\CMS\Core\Type\Bitmask\JsConfirmation;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Fluid\View\StandaloneView; use TYPO3\CMS\Fluid\View\StandaloneView;
/** /**
...@@ -556,7 +557,7 @@ class Clipboard ...@@ -556,7 +557,7 @@ class Clipboard
if (!$this->fileMode) { if (!$this->fileMode) {
$str = '<span class="text-muted">' . $str . '</span>'; $str = '<span class="text-muted">' . $str . '</span>';
} elseif (ExtensionManagementUtility::isLoaded('filelist')) { } elseif (ExtensionManagementUtility::isLoaded('filelist')) {
$str = '<a href="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute('file_list', ['id' => dirname($rec)])) . '">' . $str . '</a>'; $str = '<a href="' . htmlspecialchars((string)$uriBuilder->buildUriFromRoute('file_list', ['id' => PathUtility::dirname($rec)])) . '">' . $str . '</a>';
} }
} }
return $str; return $str;
...@@ -697,10 +698,10 @@ class Clipboard ...@@ -697,10 +698,10 @@ class Clipboard
$labelKey = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.' . ($this->currentMode() === 'copy' ? 'copy' : 'move') . ($this->current === 'normal' ? '' : 'cb') . '_' . $type; $labelKey = 'LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:mess.' . ($this->currentMode() === 'copy' ? 'copy' : 'move') . ($this->current === 'normal' ? '' : 'cb') . '_' . $type;
$msg = $this->getLanguageService()->sL($labelKey . ($columnLabel ? '_colPos' : '')); $msg = $this->getLanguageService()->sL($labelKey . ($columnLabel ? '_colPos' : ''));
if ($table === '_FILE') { if ($table === '_FILE') {
$thisRecTitle = basename($rec); $thisRecTitle = PathUtility::basename($rec);
if ($this->current === 'normal') { if ($this->current === 'normal') {
$selItem = reset($clElements); $selItem = reset($clElements);
$selRecTitle = basename($selItem); $selRecTitle = PathUtility::basename($selItem);
} else { } else {
$selRecTitle = count($clElements); $selRecTitle = count($clElements);
} }
......
...@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Backend\Form\FieldControl; ...@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Backend\Form\FieldControl;
use TYPO3\CMS\Backend\Form\AbstractNode; use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Core\Localization\LanguageService; use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/** /**
* Renders the icon "insert record from clipboard", * Renders the icon "insert record from clipboard",
...@@ -52,7 +53,7 @@ class InsertClipboard extends AbstractNode ...@@ -52,7 +53,7 @@ class InsertClipboard extends AbstractNode
$title = sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clipInsert_file'), count($clipboardElements)); $title = sprintf($languageService->sL('LLL:EXT:core/Resources/Private/Language/locallang_core.xlf:labels.clipInsert_file'), count($clipboardElements));
foreach ($clipboardElements as $clipboardElement) { foreach ($clipboardElements as $clipboardElement) {
$value = $clipboardElement['value']; $value = $clipboardElement['value'];
$title = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(basename($clipboardElement['title']))) . ')'; $title = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(PathUtility::basename($clipboardElement['title']))) . ')';
$clipboardOnClick[] = 'setFormValueFromBrowseWin(' $clipboardOnClick[] = 'setFormValueFromBrowseWin('
. GeneralUtility::quoteJSvalue($elementName) . ',' . GeneralUtility::quoteJSvalue($elementName) . ','
. 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(str_replace('%20', ' ', $value))) . '),' . 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(str_replace('%20', ' ', $value))) . '),'
......
...@@ -2975,7 +2975,7 @@ class BackendUtility ...@@ -2975,7 +2975,7 @@ class BackendUtility
$mainParams = ['id' => $mainParams]; $mainParams = ['id' => $mainParams];
} }
if (!$script) { if (!$script) {
$script = basename(Environment::getCurrentScript()); $script = PathUtility::basename(Environment::getCurrentScript());
} }
if ($routePath = GeneralUtility::_GP('route')) { if ($routePath = GeneralUtility::_GP('route')) {
......
...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers; ...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*/ */
use TYPO3\CMS\Belog\Domain\Model\LogEntry; use TYPO3\CMS\Belog\Domain\Model\LogEntry;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface; use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper; use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic; use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
...@@ -78,7 +79,7 @@ class FormatDetailsViewHelper extends AbstractViewHelper ...@@ -78,7 +79,7 @@ class FormatDetailsViewHelper extends AbstractViewHelper
protected static function stripPathFromFilenames(array $files = []) protected static function stripPathFromFilenames(array $files = [])
{ {
foreach ($files as $key => $file) { foreach ($files as $key => $file) {
$files[$key] = basename($file); $files[$key] = PathUtility::basename($file);
} }
return $files; return $files;
} }
......
...@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Cache\Backend; ...@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Service\OpcodeCacheService; use TYPO3\CMS\Core\Service\OpcodeCacheService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Core\Utility\StringUtility;
/** /**
...@@ -126,7 +127,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem ...@@ -126,7 +127,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
if (!is_string($data)) { if (!is_string($data)) {
throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1204481674); throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1204481674);
} }
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
} }
if ($entryIdentifier === '') { if ($entryIdentifier === '') {
...@@ -171,7 +172,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem ...@@ -171,7 +172,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
if ($this->frozen === true) { if ($this->frozen === true) {
return isset($this->cacheEntryIdentifiers[$entryIdentifier]) ? file_get_contents($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension) : false; return isset($this->cacheEntryIdentifiers[$entryIdentifier]) ? file_get_contents($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension) : false;
} }
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073033); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073033);
} }
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension; $pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
...@@ -201,7 +202,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem ...@@ -201,7 +202,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
if ($this->frozen === true) { if ($this->frozen === true) {
return isset($this->cacheEntryIdentifiers[$entryIdentifier]); return isset($this->cacheEntryIdentifiers[$entryIdentifier]);
} }
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073034); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073034);
} }
return !$this->isCacheFileExpired($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension); return !$this->isCacheFileExpired($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
...@@ -219,7 +220,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem ...@@ -219,7 +220,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
*/ */
public function remove($entryIdentifier) public function remove($entryIdentifier)
{ {
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073035); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073035);
} }
if ($entryIdentifier === '') { if ($entryIdentifier === '') {
...@@ -392,7 +393,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem ...@@ -392,7 +393,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
} }
return false; return false;
} }
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073036); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073036);
} }
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension; $pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
......
...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Cache\Backend; ...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Core\Environment; use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Service\OpcodeCacheService; use TYPO3\CMS\Core\Service\OpcodeCacheService;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Core\Utility\StringUtility;
/** /**
...@@ -217,7 +218,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im ...@@ -217,7 +218,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
if (!is_string($data)) { if (!is_string($data)) {
throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1334756734); throw new \TYPO3\CMS\Core\Cache\Exception\InvalidDataException('The specified data is of type "' . gettype($data) . '" but a string is expected.', 1334756734);
} }
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
} }
if ($entryIdentifier === '') { if ($entryIdentifier === '') {
...@@ -246,7 +247,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im ...@@ -246,7 +247,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/ */
public function get($entryIdentifier) public function get($entryIdentifier)
{ {
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756877); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756877);
} }
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension; $pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
...@@ -266,7 +267,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im ...@@ -266,7 +267,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/ */
public function has($entryIdentifier) public function has($entryIdentifier)
{ {
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756878); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756878);
} }
return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension); return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
...@@ -283,7 +284,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im ...@@ -283,7 +284,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/ */
public function remove($entryIdentifier) public function remove($entryIdentifier)
{ {
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756960); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756960);
} }
if ($entryIdentifier === '') { if ($entryIdentifier === '') {
...@@ -352,7 +353,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im ...@@ -352,7 +353,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
public function requireOnce($entryIdentifier) public function requireOnce($entryIdentifier)
{ {
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension; $pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
if ($entryIdentifier !== basename($entryIdentifier)) { if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073037); throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073037);
} }
return file_exists($pathAndFilename) ? require_once $pathAndFilename : false; return file_exists($pathAndFilename) ? require_once $pathAndFilename : false;
......
...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Core; ...@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Core;
*/ */
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility; use TYPO3\CMS\Core\Utility\StringUtility;
/** /**
...@@ -402,7 +403,7 @@ class SystemEnvironmentBuilder ...@@ -402,7 +403,7 @@ class SystemEnvironmentBuilder
*/ */
protected static function getRootPathFromScriptPath($scriptPath, $entryPointLevel) protected static function getRootPathFromScriptPath($scriptPath, $entryPointLevel)
{ {
$entryScriptDirectory = dirname($scriptPath); $entryScriptDirectory = PathUtility::dirnameDuringBootstrap($scriptPath);
if ($entryPointLevel > 0) { if ($entryPointLevel > 0) {
list($rootPath) = GeneralUtility::revExplode('/', $entryScriptDirectory, $entryPointLevel + 1); list($rootPath) = GeneralUtility::revExplode('/', $entryScriptDirectory, $entryPointLevel + 1);
} else { } else {
......
...@@ -2211,7 +2211,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -2211,7 +2211,7 @@ class DataHandler implements LoggerAwareInterface
if ($this->autoVersioningUpdate === true) { if ($this->autoVersioningUpdate === true) {
foreach ($valueArray as $key => $theFile) { foreach ($valueArray as $key => $theFile) {
// If it is an already attached file... // If it is an already attached file...
if ($theFile === basename($theFile)) { if ($theFile === PathUtility::basename($theFile)) {
$valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile; $valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
} }
} }
...@@ -2297,7 +2297,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -2297,7 +2297,7 @@ class DataHandler implements LoggerAwareInterface
$this->copiedFileMap[$theFile] = $theDestFile; $this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache(); clearstatcache();
if (!@is_file($theDestFile)) { if (!@is_file($theDestFile)) {
$this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, [$theFile, dirname($theDestFile), $recFID], $propArr['event_pid']); $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, [$theFile, PathUtility::dirname($theDestFile), $recFID], $propArr['event_pid']);
} }
} else { } else {
$this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, [$theFile, $theDestFile, $recFID], $propArr['event_pid']); $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, [$theFile, $theDestFile, $recFID], $propArr['event_pid']);
...@@ -2367,7 +2367,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -2367,7 +2367,7 @@ class DataHandler implements LoggerAwareInterface
if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) { if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
$theFile = PATH_site . $this->alternativeFilePath[$theFile]; $theFile = PATH_site . $this->alternativeFilePath[$theFile];
} elseif (@is_file($theFile)) { } elseif (@is_file($theFile)) {
$dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]); $dest = PathUtility::dirname(PATH_site . $this->alternativeFilePath[$theFile]);
if (!@is_dir($dest)) { if (!@is_dir($dest)) {
GeneralUtility::mkdir_deep($dest); GeneralUtility::mkdir_deep($dest);
} }
...@@ -2390,7 +2390,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -2390,7 +2390,7 @@ class DataHandler implements LoggerAwareInterface
$this->copiedFileMap[$theFile] = $theDestFile; $this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache(); clearstatcache();
if (!@is_file($theDestFile)) { if (!@is_file($theDestFile)) {
$this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, [$theFile, dirname($theDestFile), $recFID], $propArr['event_pid']); $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: The destination path (%s) may be write protected. Please make it write enabled!. (%s)', 16, [$theFile, PathUtility::dirname($theDestFile), $recFID], $propArr['event_pid']);
} }
} else { } else {
$this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, [$theFile, $theDestFile, $recFID], $propArr['event_pid']); $this->log($table, $id, 5, 0, 1, 'Copying file \'%s\' failed!: No destination file (%s) possible!. (%s)', 11, [$theFile, $theDestFile, $recFID], $propArr['event_pid']);
...@@ -4175,7 +4175,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -4175,7 +4175,7 @@ class DataHandler implements LoggerAwareInterface
return; return;
} }
foreach ($rteFileRecords as $rteFileRecord) { foreach ($rteFileRecords as $rteFileRecord) {
$filename = basename($rteFileRecord['ref_string']); $filename = PathUtility::basename($rteFileRecord['ref_string']);
if (!GeneralUtility::isFirstPartOfStr($filename, 'RTEmagicC_')) { if (!GeneralUtility::isFirstPartOfStr($filename, 'RTEmagicC_')) {
continue; continue;
} }
...@@ -4189,8 +4189,8 @@ class DataHandler implements LoggerAwareInterface ...@@ -4189,8 +4189,8 @@ class DataHandler implements LoggerAwareInterface
continue; continue;
} }
// Initialize; Get directory prefix for file and set the original name: // Initialize; Get directory prefix for file and set the original name:
$dirPrefix = dirname($rteFileRecord['ref_string']) . '/'; $dirPrefix = PathUtility::dirname($rteFileRecord['ref_string']) . '/';
$rteOrigName = basename($fileInfo['original']); $rteOrigName = PathUtility::basename($fileInfo['original']);
// If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file! // If filename looks like an RTE file, and the directory is in "uploads/", then process as a RTE file!
if ($rteOrigName && GeneralUtility::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) { if ($rteOrigName && GeneralUtility::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
// RTE: // RTE:
...@@ -4198,7 +4198,7 @@ class DataHandler implements LoggerAwareInterface ...@@ -4198,7 +4198,7 @@ class DataHandler implements LoggerAwareInterface
$origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix); $origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
// Create copy file name: // Create copy file name:
$pI = pathinfo($rteFileRecord['ref_string']); $pI = pathinfo($rteFileRecord['ref_string']);
$copyDestName = dirname($origDestName) . '/RTEmagicC_' . mb_substr(basename($origDestName), 10) . '.' . $pI['extension']; $copyDestName = PathUtility::dirname($origDestName) . '/RTEmagicC_' . mb_substr(PathUtility::basename($origDestName), 10) . '.' . $pI['extension'];
if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === GeneralUtility::getFileAbsFileName($origDestName) && $copyDestName === GeneralUtility::getFileAbsFileName($copyDestName)) { if (!@is_file($copyDestName) && !@is_file($origDestName) && $origDestName === GeneralUtility::getFileAbsFileName($origDestName) && $copyDestName === GeneralUtility::getFileAbsFileName($copyDestName)) {
// Making copies: // Making copies:
GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName); GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
......
...@@ -898,7 +898,7 @@ class ReferenceIndex implements LoggerAwareInterface ...@@ -898,7 +898,7 @@ class ReferenceIndex implements LoggerAwareInterface
if (trim($file)) { if (trim($file)) {
$realFile = $destinationFolder . '/' . trim($file); $realFile = $destinationFolder . '/' . trim($file);
$newValueFile = [ $newValueFile = [
'filename' => basename($file), 'filename' => PathUtility::basename($file),
'ID' => md5($realFile), 'ID' => md5($realFile),
'ID_absFile' => $realFile 'ID_absFile' => $realFile
]; ];
......
...@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; ...@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\LinkHandling\LinkService; use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Resource\File; use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Frontend\Service\TypoLinkCodecService; use TYPO3\CMS\Frontend\Service\TypoLinkCodecService;
/** /**
...@@ -176,7 +177,7 @@ class SoftReferenceIndex ...@@ -176,7 +177,7 @@ class SoftReferenceIndex
$elements[$k] = []; $elements[$k] = [];
$elements[$k]['matchString'] = $v; $elements[$k]['matchString'] = $v;
// If the image seems to be an RTE image, then proceed to set up substitution token: // If the image seems to be an RTE image, then proceed to set up substitution token:
if (GeneralUtility::isFirstPartOfStr($srcRef, 'uploads/') && preg_match('/^RTEmagicC_/', basename($srcRef))) { if (GeneralUtility::isFirstPartOfStr($srcRef, 'uploads/') && preg_match('/^RTEmagicC_/', PathUtility::basename($srcRef))) {
// Token and substitute value: // Token and substitute value:
// Make sure the value we work on is found and will get substituted in the content (Very important that the src-value is not DeHSC'ed) // Make sure the value we work on is found and will get substituted in the content (Very important that the src-value is not DeHSC'ed)
if (strstr($splitContent[$k], $attribs[0]['src'])) { if (strstr($splitContent[$k], $attribs[0]['src'])) {
......
...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Http; ...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Http;
use Psr\Http\Message\StreamInterface; use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface; use Psr\Http\Message\UploadedFileInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/** /**
* Class UploadedFile which represents one uploaded file, usually coming * Class UploadedFile which represents one uploaded file, usually coming
...@@ -185,7 +186,7 @@ class UploadedFile implements UploadedFileInterface ...@@ -185,7 +186,7 @@ class UploadedFile implements UploadedFileInterface
} }
if (!empty($this->file) && is_uploaded_file($this->file)) { if (!empty($this->file) && is_uploaded_file($this->file)) {
if (GeneralUtility::upload_copy_move($this->file, $targetPath . basename($this->file)) === false) { if (GeneralUtility::upload_copy_move($this->file, $targetPath . PathUtility::basename($this->file)) === false) {
throw new \RuntimeException('An error occurred while moving uploaded file', 1436717310); throw new \RuntimeException('An error occurred while moving uploaded file', 1436717310);
} }
} elseif ($this->stream) { } elseif ($this->stream) {
......
...@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Utility\CommandUtility; ...@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility; use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility; use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/** /**
* Standard graphical functions * Standard graphical functions
...@@ -2131,7 +2132,7 @@ class GraphicalFunctions ...@@ -2131,7 +2132,7 @@ class GraphicalFunctions
$command .= ' -colorspace ' . $this->colorspace; $command .= ' -colorspace ' . $this->colorspace;
$cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : ''; $cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : '';
if ($this->alternativeOutputKey) { if ($this->alternativeOutputKey) {
$theOutputName = GeneralUtility::shortMD5($command . $cropscale . basename($imagefile) . $this->alternativeOutputKey . '[' . $frame . ']'); $theOutputName = GeneralUtility::shortMD5($command . $cropscale . PathUtility::basename($imagefile) . $this->alternativeOutputKey . '[' . $frame . ']');
} else { } else {
$theOutputName = GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']'); $theOutputName = GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']');
} }
...@@ -2533,7 +2534,7 @@ class GraphicalFunctions ...@@ -2533,7 +2534,7 @@ class GraphicalFunctions
if (($type === 'IM' || !$type) && $gfxConf['processor_enabled'] && $gfxConf['processor_path_lzw']) { if (($type === 'IM' || !$type) && $gfxConf['processor_enabled'] && $gfxConf['processor_path_lzw']) {
// Use temporary file to prevent problems with read and write lock on same file on network file systems // Use temporary file to prevent problems with read and write lock on same file on network file systems
$temporaryName = dirname($theFile) . '/' . md5(uniqid('', true)) . '.gif'; $temporaryName = PathUtility::dirname($theFile) . '/' . md5(uniqid('', true)) . '.gif';
// Rename could fail, if a simultaneous thread is currently working on the same thing // Rename could fail, if a simultaneous thread is currently working on the same thing
if (@rename($theFile, $temporaryName)) { if (@rename($theFile, $temporaryName)) {
$cmd = CommandUtility::imageMagickCommand('convert', '"' . $temporaryName . '" "' . $theFile . '"', $gfxConf['processor_path_lzw']); $cmd = CommandUtility::imageMagickCommand('convert', '"' . $temporaryName . '" "' . $theFile . '"', $gfxConf['processor_path_lzw']);
......
...@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder; ...@@ -22,6 +22,7 @@ use TYPO3\CMS\Core\Database\Query\Expression\ExpressionBuilder;
use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction; use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\Database\RelationHandler; use TYPO3\CMS\Core\Database\RelationHandler;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/** /**
* This class holds functions used by the TYPO3 backend to check the integrity of the database (The DBint module, 'lowlevel' extension) * This class holds functions used by the TYPO3 backend to check the integrity of the database (The DBint module, 'lowlevel' extension)
...@@ -579,9 +580,9 @@ class DatabaseIntegrityCheck ...@@ -579,9 +580,9 @@ class DatabaseIntegrityCheck
$references = 1; $references = 1;
} }
// The directory must be empty (prevents checking of the root directory) // The directory must be empty (prevents checking of the root directory)
$directory = dirname($file); $directory = PathUtility::dirname($file);
if ($directory !== '') { if ($directory !== '') {
$newCheckFileRefs[$directory][basename($file)] = $references; $newCheckFileRefs[$directory][PathUtility::basename($file)] = $references;
} }
} }
} }
......
...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Localization\Parser; ...@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Localization\Parser;
use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException; use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
use TYPO3\CMS\Core\Localization\Exception\InvalidXmlFileException; use TYPO3\CMS\Core\Localization\Exception\InvalidXmlFileException;
use TYPO3\CMS\Core\Utility\GeneralUtility; use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/** /**
* Abstract class for XML based parser. * Abstract class for XML based parser.
...@@ -95,7 +96,7 @@ abstract class AbstractXmlParser implements LocalizationParserInterface ...@@ -95,7 +96,7 @@ abstract class AbstractXmlParser implements LocalizationParserInterface
protected function getLocalizedFileName($fileRef, $language, $sameLocation = false) protected function getLocalizedFileName($fileRef, $language, $sameLocation = false)
{ {
// If $fileRef is already prefixed with "[language key]" then we should return it as is // If $fileRef is already prefixed with "[language key]" then we should return it as is
$fileName = basename($fileRef); $fileName = PathUtility::basename($fileRef);
if (GeneralUtility::isFirstPartOfStr($fileName, $language . '.')) { if (GeneralUtility::isFirstPartOfStr($fileName, $language . '.')) {
return GeneralUtility::getFileAbsFileName($fileRef);