From 0ce0f28a2306d442b8fd3781ef20524c995d7027 Mon Sep 17 00:00:00 2001 From: plegall Date: Mon, 3 May 2010 23:31:42 +0000 Subject: bug 1063 fixed: avoid error when adding a tag in chinese or russian characters. In any language where the str2url would return an empty string. The behavior doesn't change for european characters. rvelices warned me about the many issues we might encounter with copy/paste of the URL and required url_encode/url_decode BUT after many tests (Linux with Firefox 3.0/Google Chrome 5, MacOS 10.6 with Firefox/Safari, WindowsXP with IE6/Firefox) I've found 0 problem, even with the most error prone mode $conf['tag_url_style'] = 'tag' git-svn-id: http://piwigo.org/svn/trunk@6060 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/functions.inc.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/functions.inc.php b/include/functions.inc.php index e44421fdb..dc87f508c 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -381,11 +381,18 @@ function remove_accents($string) */ function str2url($str) { + $raw = $str; + $str = remove_accents($str); $str = preg_replace('/[^a-z0-9_\s\'\:\/\[\],-]/','',strtolower($str)); $str = preg_replace('/[\s\'\:\/\[\],-]+/',' ',trim($str)); $res = str_replace(' ','_',$str); + if (empty($res)) + { + $res = $raw; + } + return $res; } -- cgit v1.2.3