//added configuration to enable or disable accented char in URL
This commit is contained in:
@@ -33,6 +33,11 @@
|
||||
<h4 class="tab">1. {l s='Info.'}</h4>
|
||||
<h4>{l s='Product global information'}</h4>
|
||||
<script type="text/javascript">
|
||||
{if isset($PS_ALLOW_ACCENTED_CHARS_URL) && $PS_ALLOW_ACCENTED_CHARS_URL}
|
||||
var PS_ALLOW_ACCENTED_CHARS_URL = 1;
|
||||
{else}
|
||||
var PS_ALLOW_ACCENTED_CHARS_URL = 0;
|
||||
{/if}
|
||||
{$combinationImagesJs}
|
||||
{if $check_product_association_ajax}
|
||||
var search_term = '';
|
||||
|
||||
+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
|
||||
*
|
||||
|
||||
@@ -432,20 +432,26 @@ class AdminMetaControllerCore extends AdminController
|
||||
return;
|
||||
|
||||
$rule = Tools::getValue('PS_ROUTE_'.$route_id);
|
||||
if (!$rule || $rule == $default_routes[$route_id]['rule'])
|
||||
{
|
||||
Configuration::updateValue('PS_ROUTE_'.$route_id, '');
|
||||
return;
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
if (!Dispatcher::getInstance()->validateRoute($route_id, $rule, $errors))
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
$this->errors[] = sprintf('Keyword "{%1$s}" required for route "%2$s" (rule: "%3$s")', $error, $route_id, htmlspecialchars($rule));
|
||||
}
|
||||
if (!Validate::isRoutePattern($rule))
|
||||
$this->errors[] = sprintf('The route %s is not valide', htmlspecialchars($rule));
|
||||
else
|
||||
Configuration::updateValue('PS_ROUTE_'.$route_id, $rule);
|
||||
{
|
||||
if (!$rule || $rule == $default_routes[$route_id]['rule'])
|
||||
{
|
||||
Configuration::updateValue('PS_ROUTE_'.$route_id, '');
|
||||
return;
|
||||
}
|
||||
|
||||
$errors = array();
|
||||
if (!Dispatcher::getInstance()->validateRoute($route_id, $rule, $errors))
|
||||
{
|
||||
foreach ($errors as $error)
|
||||
$this->errors[] = sprintf('Keyword "{%1$s}" required for route "%2$s" (rule: "%3$s")', $error, $route_id, htmlspecialchars($rule));
|
||||
}
|
||||
else
|
||||
Configuration::updateValue('PS_ROUTE_'.$route_id, $rule);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-2
@@ -32,8 +32,10 @@ function str2url(str,encoding,ucfirst)
|
||||
{
|
||||
str = str.toUpperCase();
|
||||
str = str.toLowerCase();
|
||||
|
||||
str = str.replace(/[^a-z0-9\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,'');
|
||||
if (PS_ALLOW_ACCENTED_CHARS_URL)
|
||||
str = str.replace(/[^a-z0-9\s\'\:\/\[\]-]\\u00A1-\\uFFFF/g,'');
|
||||
else
|
||||
str = str.replace(/[^a-z0-9\s\'\:\/\[\]-]/g,'');
|
||||
str = str.replace(/[\u0028\u0029\u0021\u003F\u002E\u0026\u005E\u007E\u002B\u002A\u002F\u003A\u003B\u003C\u003D\u003E]/g,'');
|
||||
str = str.replace(/[\s\'\:\/\[\]-]+/g,' ');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user