//added configuration to enable or disable accented char in URL
This commit is contained in:
+6
-2
@@ -975,11 +975,15 @@ class ToolsCore
|
||||
$str = mb_strtolower($str, 'utf-8');
|
||||
|
||||
$str = trim($str);
|
||||
if (!function_exists('mb_strtolower'))
|
||||
if (!function_exists('mb_strtolower') || !Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
|
||||
$str = Tools::replaceAccentedChars($str);
|
||||
|
||||
// Remove all non-whitelist chars.
|
||||
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str);
|
||||
if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
|
||||
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-\pL]/u', '', $str);
|
||||
else
|
||||
$str = preg_replace('/[^a-zA-Z0-9\s\'\:\/\[\]-]/','', $str);
|
||||
|
||||
$str = preg_replace('/[\s\'\:\/\[\]-]+/', ' ', $str);
|
||||
$str = str_replace(array(' ', '/'), '-', $str);
|
||||
|
||||
|
||||
+17
-2
@@ -322,9 +322,24 @@ class ValidateCore
|
||||
*/
|
||||
public static function isLinkRewrite($link)
|
||||
{
|
||||
return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link);
|
||||
if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
|
||||
return preg_match('/^[_a-zA-Z0-9\-\pL]+$/u', $link);
|
||||
return preg_match('/^[_a-zA-Z0-9\-]+$/', $link);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Check for a route pattern validity
|
||||
*
|
||||
* @param string $pattern to validate
|
||||
* @return boolean Validity is ok or not
|
||||
*/
|
||||
public static function isRoutePattern($pattern)
|
||||
{
|
||||
if (Configuration::get('PS_ALLOW_ACCENTED_CHARS_URL'))
|
||||
return preg_match('/^[_a-zA-Z0-9\(\)\.{}:\/\-\pL]+$/u', $pattern);
|
||||
return preg_match('/^[_a-zA-Z0-9\(\)\.{}:\/\-]+$/', $pattern);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check for a postal address validity
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user