Issue Bug Closed

#45489t3lib_stdGraphic: escaping of filenames does not work when using brackets ()

Markus Kappe 02/14/13, 17:26 updated 08/14/15, 10:44

Description

When you got an image that has brackets () in its filename, resizing (i.e. all ImageMagick actions) won’t work. The reason is that the filenames with brackets need to be surrunded by quotes when passed to the IM command. But the quotes are removed (after properly applied).

The code from 4.5.22:

    protected function wrapFileName($inputName) {
        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
            $currentLocale = setlocale(LC_CTYPE, 0);
            setlocale(LC_CTYPE, $GLOBALS['TYPO3_CONF_VARS']['SYS']['systemLocale']);
        }
        $escapedInputName = escapeshellarg($inputName);
        if ($GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
            setlocale(LC_CTYPE, $currentLocale);
        }
            // if escapeshellarg didn't change anything and if there is no whitespace in the original string
            // keep the original for (partial) safe_mode compatibility
        if (trim($escapedInputName, '"\'') === $inputName && !preg_match('/[[:space:]]/', $inputName)) {
///////////// remove the next line for bugfix ////////////////////////
            $escapedInputName = $inputName;
        }
        return $escapedInputName;
    }

Reviews 0

No change resolves or names this issue in its commit message, and no comment links one.