Issue Bug Closed

#69358strtolower() breaks German Umlaute in File Pathes

Sebastian Mazza 08/27/15, 14:36 updated 10/02/18, 11:34

Description

The method canonicalizeAndCheckFileIdentifier($fileIdentifier) in sysext/core/Classes/Resource/Driver/AbstractHierarchicalFilesystemDriver.php uses the php function strtolower() which corrupts multibyte characters.

Test: call TYPO3\CMS\Core\Resource\File->getForLocalProcessing(false) for a File with german Umlaut (ä, ö, ü)

Fix: change the line 63 in sysext/core/Classes/Resource/Driver/AbstractHierarchicalFilesystemDriver.php
from: $fileIdentifier = strtolower($fileIdentifier);
to: $fileIdentifier = mb_strtolower($fileIdentifier);

/**
     * Makes sure the Path given as parameter is valid
     *
     * @param string $fileIdentifier The file path (including the file name!)
     * @return string
     * @throws \TYPO3\CMS\Core\Resource\Exception\InvalidPathException
     */
    protected function canonicalizeAndCheckFileIdentifier($fileIdentifier) {
        if ($fileIdentifier !== '') {
            $fileIdentifier = $this->canonicalizeAndCheckFilePath($fileIdentifier);
            $fileIdentifier = '/' . ltrim($fileIdentifier, '/');
            if (!$this->isCaseSensitiveFileSystem()) {
                //$fileIdentifier = strtolower($fileIdentifier); 
                $fileIdentifier = mb_strtolower($fileIdentifier); // fix by Sebastian
            }
        }
        return $fileIdentifier;
    }

Reviews 1