From a4997405dc00876709f8e740e99ed6e7c64d82da Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Gaillard?= Date: Tue, 15 Jan 2013 18:56:42 +0100 Subject: [PATCH] // opti --- classes/Tools.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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);