diff --git a/classes/Tools.php b/classes/Tools.php index fb1382d57c7ad..8ec0b5ac0cad5 100644 --- a/classes/Tools.php +++ b/classes/Tools.php @@ -968,15 +968,20 @@ public static function link_rewrite($str, $utf8_decode = false) */ public static function str2url($str) { + static $allow_accented_chars = null; + + if ($allow_accented_chars === null) + $allow_accented_chars = Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'); + if (function_exists('mb_strtolower')) $str = mb_strtolower($str, 'utf-8'); $str = trim($str); - if (!function_exists('mb_strtolower') || !Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) + if (!function_exists('mb_strtolower') || !$allow_accented_chars) $str = Tools::replaceAccentedChars($str); // Remove all non-whitelist chars. - if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL')) + if ($allow_accented_chars) $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str); else $str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);