Project

General

Profile

Bug #19944 » 10313.diff

Administrator Admin, 2009-01-30 21:52

View differences:

t3lib/class.t3lib_basicfilefunc.php (working copy)
}
/**
* Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_'
* Returns a string where any character not matching [.a-zA-Z0-9_-] is substituted by '_' and trailing dots are removed
*
* @param string Input string, typically the body of a filename
* @param string Charset of the a filename (defaults to current charset; depending on context)
* @return string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_'
* @return string Output string with any characters not matching [.a-zA-Z0-9_-] is substituted by '_', trailing dots are simply removed
*/
function cleanFileName($fileName,$charset='') {
// remove trailing dots
$fileName = preg_replace('/\.*$/','',$fileName);
// handle UTF-8 characters
if ($GLOBALS['TYPO3_CONF_VARS']['BE']['forceCharset'] == 'utf-8' && $GLOBALS['TYPO3_CONF_VARS']['SYS']['UTF8filesystem']) {
// allow ".", "-", 0-9, a-z, A-Z and everything beyond U+C0 (latin capital letter a with grave)
......
$fileName = $this->csConvObj->specCharsToASCII($charset,$fileName);
}
$fileName = preg_replace('/[^.[:alnum:]_-]/','_',trim($fileName));
return preg_replace('/\.*$/','',$fileName);
return preg_replace('/[^.[:alnum:]_-]/','_',trim($fileName));
}
/**
......
include_once($TYPO3_CONF_VARS[TYPO3_MODE]['XCLASS']['t3lib/class.t3lib_basicfilefunc.php']);
}
?>
?>
(1-1/3)