[svn r14317] Added comments to replace_accents()

skala
Yannick Warnier 18 years ago
parent 10fbfe8bc3
commit d187e9180e
  1. 13
      main/inc/lib/fileUpload.lib.php

@ -93,6 +93,19 @@ function replace_dangerous_char($filename, $strict = 'loose')
return ereg_replace("[^!-~]", "x", $filename);
}
/**
* Replaces all accentuated characters by non-accentuated characters for filenames, as
* well as special HTML characters by their HTML entity's first letter.
*
* Although this method is not absolute, it gives good results in general. It first
* transforms the string to HTML entities (ô, @oslash;, etc) then removes the
* HTML character part to result in simple characters (o, o, etc).
* In the case of special characters (out of alphabetical value) like   and <,
* it will still replace them by the first letter of the HTML entity (n, l, ...) but it
* is still an acceptable method, knowing we're filtering filenames here...
* @param string The accentuated string
* @return string The escaped string, not absolutely correct but satisfying
*/
function replace_accents($string){
$string = htmlentities($string,ENT_QUOTES);
return preg_replace("/&([a-z])[a-z]+;/i","$1",$string);

Loading…
Cancel
Save