From: <var...@us...> - 2009-03-04 13:02:22
|
Revision: 6628 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=6628&view=rev Author: vargenau Date: 2009-03-04 13:02:18 +0000 (Wed, 04 Mar 2009) Log Message: ----------- Allow uploading files with accents in name Modified Paths: -------------- trunk/lib/plugin/UpLoad.php trunk/lib/stdlib.php Modified: trunk/lib/plugin/UpLoad.php =================================================================== --- trunk/lib/plugin/UpLoad.php 2009-03-04 12:51:27 UTC (rev 6627) +++ trunk/lib/plugin/UpLoad.php 2009-03-04 13:02:18 UTC (rev 6628) @@ -225,7 +225,7 @@ $message->pushContent(HTML::p(fmt("Only files with the extension %s are allowed.", join(", ", $this->allowed_extensions)))); } - elseif (preg_match("/[^._a-zA-Z0-9- ]/", $userfile_name)) + elseif (preg_match("/[^._a-zA-Z0-9- ]/", strip_accents($userfile_name))) { $message->pushContent($err_header); $message->pushContent(HTML::p(_("Invalid filename. File names may only contain alphanumeric characters and dot, underscore, space or dash."))); Modified: trunk/lib/stdlib.php =================================================================== --- trunk/lib/stdlib.php 2009-03-04 12:51:27 UTC (rev 6627) +++ trunk/lib/stdlib.php 2009-03-04 13:02:18 UTC (rev 6628) @@ -1204,7 +1204,7 @@ $RE[] = "/(?<= |${sep}|^)([AI])([[:upper:]][[:lower:]])/"; break; case 'fr': - $RE[] = "/(?<= |${sep}|^)([\xC0])([[:upper:]][[:lower:]])/"; + $RE[] = "/(?<= |${sep}|^)([À])([[:upper:]][[:lower:]])/"; break; } // Split numerals from following letters. @@ -2561,6 +2561,16 @@ return $table[$i][$j]; } +/** + * Remove accents from given text. + */ +function strip_accents($text) { + $res = utf8_decode($text); + $res = strtr($res, + utf8_decode('àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ'), + 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); + return utf8_encode($res); +} // (c-file-style: "gnu") // Local Variables: // mode: php This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |