[TYPO3-dev] Where to use setlocale?
Jigal van Hemert
jigal at xs4all.nl
Thu Mar 18 22:06:30 CET 2010
Ernesto Baschny [cron IT] wrote:
> I guess minimal disruption would be to set it around the code that needs
> it (around the escapeshellarg()). And this only if UTF8filesystem
> setting is present.
Trying to take into account Windows and Mac peculiarities and to cause
no disruption the following would do the trick?
/**
* Escapes a file name so it can safely be used on the command line.
*
* @param string $inputName filename to safeguard, must not be empty
*
* @return string $inputName escaped as needed
*/
protected function wrapFileName($inputName) {
if ($TYPO3_CONF_VARS['SYS']['UTF8filesystem']) {
$oldLocale = setlocale(LC_CTYPE, 0);
setlocale(LC_CTYPE, 'en_US.UTF8', 'en_US.UTF-8', 'en_US', 'American',
'ENG', 'English');
$inputName = escapeshellarg($inputName);
setlocale(LC_CTYPE, $oldLocale);
unset($oldLocale);
} else {
$inputName = escapeshellarg($inputName);
}
return $inputName;
}
The same should be possible in thumbs.php
If this looks okay, I'll drop a patch in the core list...
--
Jigal van Hemert.
More information about the TYPO3-dev
mailing list