diff --git a/libraries/joomla/filesystem/file.php b/libraries/joomla/filesystem/file.php index 01e728bbb4fb4..ecfa280fec9ce 100644 --- a/libraries/joomla/filesystem/file.php +++ b/libraries/joomla/filesystem/file.php @@ -65,6 +65,13 @@ public static function makeSafe($file) // Remove any trailing dots, as those aren't ever valid file names. $file = rtrim($file, '.'); + // Try transiterating the file name using the native php function + if (function_exists('transliterator_transliterate') && function_exists('iconv')) + { + // Using iconv to ignore characters that can't be transliterated + $file = iconv("UTF-8", "ASCII//TRANSLIT//IGNORE", transliterator_transliterate('Any-Latin; Latin-ASCII; Lower()', $file)); + } + $regex = array('#(\.){2,}#', '#[^A-Za-z0-9\.\_\- ]#', '#^\.#'); return trim(preg_replace($regex, '', $file));