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;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Fluid\View\StandaloneView;
/**
......@@ -556,7 +557,7 @@ class Clipboard
if (!$this->fileMode) {
$str = '<span class="text-muted">' . $str . '</span>';
} 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;
......@@ -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;
$msg = $this->getLanguageService()->sL($labelKey . ($columnLabel ? '_colPos' : ''));
if ($table === '_FILE') {
$thisRecTitle = basename($rec);
$thisRecTitle = PathUtility::basename($rec);
if ($this->current === 'normal') {
$selItem = reset($clElements);
$selRecTitle = basename($selItem);
$selRecTitle = PathUtility::basename($selItem);
} else {
$selRecTitle = count($clElements);
}
......
......@@ -18,6 +18,7 @@ namespace TYPO3\CMS\Backend\Form\FieldControl;
use TYPO3\CMS\Backend\Form\AbstractNode;
use TYPO3\CMS\Core\Localization\LanguageService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Renders the icon "insert record from clipboard",
......@@ -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));
foreach ($clipboardElements as $clipboardElement) {
$value = $clipboardElement['value'];
$title = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(basename($clipboardElement['title']))) . ')';
$title = 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(PathUtility::basename($clipboardElement['title']))) . ')';
$clipboardOnClick[] = 'setFormValueFromBrowseWin('
. GeneralUtility::quoteJSvalue($elementName) . ','
. 'unescape(' . GeneralUtility::quoteJSvalue(rawurlencode(str_replace('%20', ' ', $value))) . '),'
......
......@@ -2975,7 +2975,7 @@ class BackendUtility
$mainParams = ['id' => $mainParams];
}
if (!$script) {
$script = basename(Environment::getCurrentScript());
$script = PathUtility::basename(Environment::getCurrentScript());
}
if ($routePath = GeneralUtility::_GP('route')) {
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Belog\ViewHelpers;
*/
use TYPO3\CMS\Belog\Domain\Model\LogEntry;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3Fluid\Fluid\Core\Rendering\RenderingContextInterface;
use TYPO3Fluid\Fluid\Core\ViewHelper\AbstractViewHelper;
use TYPO3Fluid\Fluid\Core\ViewHelper\Traits\CompileWithRenderStatic;
......@@ -78,7 +79,7 @@ class FormatDetailsViewHelper extends AbstractViewHelper
protected static function stripPathFromFilenames(array $files = [])
{
foreach ($files as $key => $file) {
$files[$key] = basename($file);
$files[$key] = PathUtility::basename($file);
}
return $files;
}
......
......@@ -16,6 +16,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Service\OpcodeCacheService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
/**
......@@ -126,7 +127,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
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);
}
if ($entryIdentifier !== basename($entryIdentifier)) {
if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1282073032);
}
if ($entryIdentifier === '') {
......@@ -171,7 +172,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
if ($this->frozen === true) {
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);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
......@@ -201,7 +202,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
if ($this->frozen === true) {
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);
}
return !$this->isCacheFileExpired($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
......@@ -219,7 +220,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
*/
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);
}
if ($entryIdentifier === '') {
......@@ -392,7 +393,7 @@ class FileBackend extends \TYPO3\CMS\Core\Cache\Backend\SimpleFileBackend implem
}
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);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Cache\Backend;
use TYPO3\CMS\Core\Core\Environment;
use TYPO3\CMS\Core\Service\OpcodeCacheService;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
/**
......@@ -217,7 +218,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
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);
}
if ($entryIdentifier !== basename($entryIdentifier)) {
if ($entryIdentifier !== PathUtility::basename($entryIdentifier)) {
throw new \InvalidArgumentException('The specified entry identifier must not contain a path segment.', 1334756735);
}
if ($entryIdentifier === '') {
......@@ -246,7 +247,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/
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);
}
$pathAndFilename = $this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension;
......@@ -266,7 +267,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/
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);
}
return file_exists($this->cacheDirectory . $entryIdentifier . $this->cacheEntryFileExtension);
......@@ -283,7 +284,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
*/
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);
}
if ($entryIdentifier === '') {
......@@ -352,7 +353,7 @@ class SimpleFileBackend extends \TYPO3\CMS\Core\Cache\Backend\AbstractBackend im
public function requireOnce($entryIdentifier)
{
$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);
}
return file_exists($pathAndFilename) ? require_once $pathAndFilename : false;
......
......@@ -15,6 +15,7 @@ namespace TYPO3\CMS\Core\Core;
*/
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Core\Utility\StringUtility;
/**
......@@ -402,7 +403,7 @@ class SystemEnvironmentBuilder
*/
protected static function getRootPathFromScriptPath($scriptPath, $entryPointLevel)
{
$entryScriptDirectory = dirname($scriptPath);
$entryScriptDirectory = PathUtility::dirnameDuringBootstrap($scriptPath);
if ($entryPointLevel > 0) {
list($rootPath) = GeneralUtility::revExplode('/', $entryScriptDirectory, $entryPointLevel + 1);
} else {
......
......@@ -2211,7 +2211,7 @@ class DataHandler implements LoggerAwareInterface
if ($this->autoVersioningUpdate === true) {
foreach ($valueArray as $key => $theFile) {
// If it is an already attached file...
if ($theFile === basename($theFile)) {
if ($theFile === PathUtility::basename($theFile)) {
$valueArray[$key] = PATH_site . $tcaFieldConf['uploadfolder'] . '/' . $theFile;
}
}
......@@ -2297,7 +2297,7 @@ class DataHandler implements LoggerAwareInterface
$this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache();
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 {
$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
if (@is_file(PATH_site . $this->alternativeFilePath[$theFile])) {
$theFile = PATH_site . $this->alternativeFilePath[$theFile];
} elseif (@is_file($theFile)) {
$dest = dirname(PATH_site . $this->alternativeFilePath[$theFile]);
$dest = PathUtility::dirname(PATH_site . $this->alternativeFilePath[$theFile]);
if (!@is_dir($dest)) {
GeneralUtility::mkdir_deep($dest);
}
......@@ -2390,7 +2390,7 @@ class DataHandler implements LoggerAwareInterface
$this->copiedFileMap[$theFile] = $theDestFile;
clearstatcache();
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 {
$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
return;
}
foreach ($rteFileRecords as $rteFileRecord) {
$filename = basename($rteFileRecord['ref_string']);
$filename = PathUtility::basename($rteFileRecord['ref_string']);
if (!GeneralUtility::isFirstPartOfStr($filename, 'RTEmagicC_')) {
continue;
}
......@@ -4189,8 +4189,8 @@ class DataHandler implements LoggerAwareInterface
continue;
}
// Initialize; Get directory prefix for file and set the original name:
$dirPrefix = dirname($rteFileRecord['ref_string']) . '/';
$rteOrigName = basename($fileInfo['original']);
$dirPrefix = PathUtility::dirname($rteFileRecord['ref_string']) . '/';
$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 ($rteOrigName && GeneralUtility::isFirstPartOfStr($dirPrefix, 'uploads/') && @is_dir(PATH_site . $dirPrefix)) {
// RTE:
......@@ -4198,7 +4198,7 @@ class DataHandler implements LoggerAwareInterface
$origDestName = $this->fileFunc->getUniqueName($rteOrigName, PATH_site . $dirPrefix);
// Create copy file name:
$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)) {
// Making copies:
GeneralUtility::upload_copy_move(PATH_site . $fileInfo['original'], $origDestName);
......
......@@ -898,7 +898,7 @@ class ReferenceIndex implements LoggerAwareInterface
if (trim($file)) {
$realFile = $destinationFolder . '/' . trim($file);
$newValueFile = [
'filename' => basename($file),
'filename' => PathUtility::basename($file),
'ID' => md5($realFile),
'ID_absFile' => $realFile
];
......
......@@ -19,6 +19,7 @@ use TYPO3\CMS\Core\Database\Query\Restriction\DeletedRestriction;
use TYPO3\CMS\Core\LinkHandling\LinkService;
use TYPO3\CMS\Core\Resource\File;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Frontend\Service\TypoLinkCodecService;
/**
......@@ -176,7 +177,7 @@ class SoftReferenceIndex
$elements[$k] = [];
$elements[$k]['matchString'] = $v;
// 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:
// 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'])) {
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Http;
use Psr\Http\Message\StreamInterface;
use Psr\Http\Message\UploadedFileInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Class UploadedFile which represents one uploaded file, usually coming
......@@ -185,7 +186,7 @@ class UploadedFile implements UploadedFileInterface
}
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);
}
} elseif ($this->stream) {
......
......@@ -23,6 +23,7 @@ use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\ExtensionManagementUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\MathUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Standard graphical functions
......@@ -2131,7 +2132,7 @@ class GraphicalFunctions
$command .= ' -colorspace ' . $this->colorspace;
$cropscale = $data['crs'] ? 'crs-V' . $data['cropV'] . 'H' . $data['cropH'] : '';
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 {
$theOutputName = GeneralUtility::shortMD5($command . $cropscale . $imagefile . filemtime($imagefile) . '[' . $frame . ']');
}
......@@ -2533,7 +2534,7 @@ class GraphicalFunctions
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
$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
if (@rename($theFile, $temporaryName)) {
$cmd = CommandUtility::imageMagickCommand('convert', '"' . $temporaryName . '" "' . $theFile . '"', $gfxConf['processor_path_lzw']);
......
......@@ -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\RelationHandler;
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)
......@@ -579,9 +580,9 @@ class DatabaseIntegrityCheck
$references = 1;
}
// The directory must be empty (prevents checking of the root directory)
$directory = dirname($file);
$directory = PathUtility::dirname($file);
if ($directory !== '') {
$newCheckFileRefs[$directory][basename($file)] = $references;
$newCheckFileRefs[$directory][PathUtility::basename($file)] = $references;
}
}
}
......
......@@ -17,6 +17,7 @@ namespace TYPO3\CMS\Core\Localization\Parser;
use TYPO3\CMS\Core\Localization\Exception\FileNotFoundException;
use TYPO3\CMS\Core\Localization\Exception\InvalidXmlFileException;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
/**
* Abstract class for XML based parser.
......@@ -95,7 +96,7 @@ abstract class AbstractXmlParser implements LocalizationParserInterface
protected function getLocalizedFileName($fileRef, $language, $sameLocation = false)
{
// 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 . '.')) {
return GeneralUtility::getFileAbsFileName($fileRef);
}
......
......@@ -184,7 +184,7 @@ class FileWriter extends AbstractWriter
if (file_exists($this->logFile)) {
return;
}
$logFileDirectory = dirname($this->logFile);
$logFileDirectory = PathUtility::dirname($this->logFile);
if (!@is_dir($logFileDirectory)) {
GeneralUtility::mkdir_deep($logFileDirectory);
// create .htaccess file if log file is within the site path
......
......@@ -371,8 +371,8 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
/** @var SplFileInfo $fileInfo */
foreach ($finder as $fileInfo) {
$path = dirname($fileInfo->getPathname());
$extensionName = basename($path);
$path = PathUtility::dirname($fileInfo->getPathname());
$extensionName = PathUtility::basename($path);
// Fix Windows backslashes
// we can't use GeneralUtility::fixWindowsFilePath as we have to keep double slashes for Unit Tests (vfs://)
$currentPath = str_replace('\\', '/', $path) . '/';
......@@ -871,13 +871,13 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
$json = file_get_contents($manifestPath . 'composer.json');
$composerManifest = json_decode($json);
if (!$composerManifest instanceof \stdClass) {
throw new Exception\InvalidPackageManifestException('The composer.json found for extension "' . basename($manifestPath) . '" is invalid!', 1439555561);
throw new Exception\InvalidPackageManifestException('The composer.json found for extension "' . PathUtility::basename($manifestPath) . '" is invalid!', 1439555561);
}
}
$extensionManagerConfiguration = $this->getExtensionEmConf($manifestPath);
$composerManifest = $this->mapExtensionManagerConfigurationToComposerManifest(
basename($manifestPath),
PathUtility::basename($manifestPath),
$extensionManagerConfiguration,
$composerManifest ?: new \stdClass()
);
......@@ -895,7 +895,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
*/
protected function getExtensionEmConf($packagePath)
{
$packageKey = basename($packagePath);
$packageKey = PathUtility::basename($packagePath);
$_EXTKEY = $packageKey;
$path = $packagePath . 'ext_emconf.php';
$EM_CONF = null;
......@@ -1041,7 +1041,7 @@ class PackageManager implements \TYPO3\CMS\Core\SingletonInterface
throw new Exception\InvalidPackageManifestException('Invalid composer manifest in package path: ' . $packagePath, 1348146451);
}
if (isset($manifest->type) && substr($manifest->type, 0, 10) === 'typo3-cms-') {
$packageKey = basename($packagePath);
$packageKey = PathUtility::basename($packagePath);
return preg_replace('/[^A-Za-z0-9._-]/', '', $packageKey);
}
$packageKey = str_replace('/', '.', $manifest->name);
......
......@@ -26,6 +26,7 @@ use TYPO3\CMS\Core\Resource\Service\FileProcessingService;
use TYPO3\CMS\Core\Type\File\ImageInfo;
use TYPO3\CMS\Core\Utility\CommandUtility;
use TYPO3\CMS\Core\Utility\GeneralUtility;
use TYPO3\CMS\Core\Utility\PathUtility;
use TYPO3\CMS\Frontend\Imaging\GifBuilder;
/**
......@@ -150,7 +151,7 @@ class PreviewProcessing
if (!file_exists($temporaryFileName)) {
// Create a error image
$graphicalFunctions = $this->getGraphicalFunctionsObject();
$graphicalFunctions->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', basename($originalFileName));
$graphicalFunctions->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', PathUtility::basename($originalFileName));
}
}
......@@ -195,7 +196,7 @@ class PreviewProcessing
if (!file_exists($temporaryFileName)) {
// Create a error image
$graphicalFunctions = $this->getGraphicalFunctionsObject();
$graphicalFunctions->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', basename($originalFileName));
$graphicalFunctions->getTemporaryImageWithText($temporaryFileName, 'No thumb', 'generated!', PathUtility::basename($originalFileName));
}
}
......
......@@ -989,14 +989,14 @@ class TypoScriptParser
} else {
// Apparently this is not a folder, so the restriction
// is the folder so we restrict into this folder
$finder->in(dirname($absoluteFileName));
$finder->in(PathUtility::dirname($absoluteFileName));
if (!is_file($absoluteFileName)
&& strpos(basename($absoluteFileName), '*') === false
&& substr(basename($absoluteFileName), -11) !== '.typoscript') {
&& strpos(PathUtility::basename($absoluteFileName), '*') === false
&& substr(PathUtility::basename($absoluteFileName), -11) !== '.typoscript') {
$absoluteFileName .= '*.typoscript';
}
$finder->name(basename($absoluteFileName));
$readableFilePrefix = dirname($filename);
$finder->name(PathUtility::basename($absoluteFileName));
$readableFilePrefix = PathUtility::dirname($filename);
}
foreach ($finder as $fileObject) {
......
......@@ -206,7 +206,7 @@ class CommandUtility
$cmd = @self::exec('which ' . $cmd);
if (@is_executable($cmd)) {
self::$applications[$cmd]['app'] = $cmd;
self::$applications[$cmd]['path'] = dirname($cmd) . '/';
self::$applications[$cmd]['path'] = PathUtility::dirname($cmd) . '/';
self::$applications[$cmd]['valid'] = true;
return true;
}
......@@ -361,8 +361,8 @@ class CommandUtility
continue;
}
list($cmd, $cmdPath) = GeneralUtility::trimExplode('=', $val, true, 2);
$cmdArr[$cmd]['app'] = basename($cmdPath);
$cmdArr[$cmd]['path'] = dirname($cmdPath) . '/';
$cmdArr[$cmd]['app'] = PathUtility::basename($cmdPath);
$cmdArr[$cmd]['path'] = PathUtility::dirname($cmdPath) . '/';
$cmdArr[$cmd]['valid'] = true;
}
}
......
......@@ -2794,7 +2794,7 @@ class GeneralUtility
if (defined('TYPO3_PATH_WEB')) {
$retVal = $url;
} elseif (Environment::getCurrentScript() && defined('PATH_site')) {
$lPath = PathUtility::stripPathSitePrefix(dirname(Environment::getCurrentScript())) . '/';
$lPath = PathUtility::stripPathSitePrefix(PathUtility::dirnameDuringBootstrap(Environment::getCurrentScript())) . '/';
$siteUrl = substr($url, 0, -strlen($lPath));
if (substr($siteUrl, -1) !== '/') {
$siteUrl .= '/';
......@@ -3328,7 +3328,7 @@ class GeneralUtility
self::mkdir_deep($temporaryPath);
}
if ($fileSuffix === '') {
$tempFileName = $temporaryPath . basename(tempnam($temporaryPath, $filePrefix));
$tempFileName = $temporaryPath . PathUtility::basename(tempnam($temporaryPath, $filePrefix));
} else {
do {
$tempFileName = $temporaryPath . $filePrefix . mt_rand(1, PHP_INT_MAX) . $fileSuffix;
......@@ -3404,7 +3404,7 @@ class GeneralUtility
{
trigger_error('This method will be removed in TYPO3 v10.0, the functionality has been moved into AbstractXmlParser', E_USER_DEPRECATED);
// If $fileRef is already prefixed with "[language key]" then we should return it as is
$fileName = basename($fileRef);
$fileName = PathUtility::basename($fileRef);
if (self::isFirstPartOfStr($fileName, $language . '.')) {
return $fileRef;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment