Skip to content

Commit

Permalink
// opti
Browse files Browse the repository at this point in the history
  • Loading branch information
rGaillard committed Jan 15, 2013
1 parent 02bbfb2 commit a499740
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions classes/Tools.php
Expand Up @@ -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);
Expand Down

1 comment on commit a499740

@alexsegura
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As Configuration :: get() already caches the values, does this change anything ? I think not.

Please sign in to comment.