This commit is contained in:
Rémi Gaillard
2013-01-15 18:56:42 +01:00
parent 02bbfb25d6
commit a4997405dc
+7 -2
View File
@@ -968,15 +968,20 @@ class ToolsCore
*/
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);