diff --git a/change_log.txt b/change_log.txt index 2a092f79..e55598be 100644 --- a/change_log.txt +++ b/change_log.txt @@ -5,6 +5,7 @@ - changed unloadFilter() to not return a boolean in favor of chaining and API conformity - bugfix unregisterObject() raised notice when object to unregister did not exist - changed internals to use Smarty::$_MBSTRING ($_CHARSET, $_DATE_FORMAT) for better unit testing +- added Smarty::$_UTF8_MODIFIER for proper PCRE charset handling (Forum Topic 20452) 17.12.2011 - improvement of compiling speed by new handling of plain text blocks in the lexer/parser (issue 68) diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 6f72b49d..b129aa97 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -61,9 +61,15 @@ if (!defined('SMARTY_MBSTRING')) { } if (!defined('SMARTY_RESOURCE_CHAR_SET')) { // UTF-8 can only be done properly when mbstring is available! + /** + * @deprecated in favor of Smarty::$_CHARSET + */ define('SMARTY_RESOURCE_CHAR_SET', SMARTY_MBSTRING ? 'UTF-8' : 'ISO-8859-1'); } if (!defined('SMARTY_RESOURCE_DATE_FORMAT')) { + /** + * @deprecated in favor of Smarty::$_DATE_FORMAT + */ define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); } @@ -166,12 +172,25 @@ class Smarty extends Smarty_Internal_TemplateBase { * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() */ public static $_muted_directories = array(); - + /** + * Flag denoting if Multibyte String functions are available + */ public static $_MBSTRING = SMARTY_MBSTRING; + /** + * The character set to adhere to (e.g. "UTF-8") + */ public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; + /** + * The date format to be used internally + * (accepts date() and strftime()) + */ public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; + /** + * Flag denoting if PCRE should run in UTF-8 mode + */ public static $_UTF8_MODIFIER = 'u'; + /**#@+ * variables */ @@ -1437,7 +1456,7 @@ class Smarty extends Smarty_Internal_TemplateBase { } } -// let PREG treat strings as ISO-8859-1 if we're not dealing with UTF-8 +// let PCRE (preg_*) treat strings as ISO-8859-1 if we're not dealing with UTF-8 if (Smarty::$_CHARSET !== 'UTF-8') { Smarty::$_UTF8_MODIFIER = ''; } diff --git a/libs/plugins/block.textformat.php b/libs/plugins/block.textformat.php index 93f8a52b..b22b104a 100644 --- a/libs/plugins/block.textformat.php +++ b/libs/plugins/block.textformat.php @@ -84,7 +84,7 @@ function smarty_block_textformat($params, $content, $template, &$repeat) continue; } // convert mult. spaces & special chars to single space - $_paragraph = preg_replace(array('!\s+!u', '!(^\s+)|(\s+$)!u'), array(' ', ''), $_paragraph); + $_paragraph = preg_replace(array('!\s+!' . Smarty::$_UTF8_MODIFIER, '!(^\s+)|(\s+$)!' . Smarty::$_UTF8_MODIFIER), array(' ', ''), $_paragraph); // indent first line if ($indent_first > 0) { $_paragraph = str_repeat($indent_char, $indent_first) . $_paragraph; diff --git a/libs/plugins/function.html_checkboxes.php b/libs/plugins/function.html_checkboxes.php index 42513691..fb9584bb 100644 --- a/libs/plugins/function.html_checkboxes.php +++ b/libs/plugins/function.html_checkboxes.php @@ -177,7 +177,7 @@ function smarty_function_html_checkboxes_output($name, $value, $output, $selecte if ($labels) { if ($label_ids) { - $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!u', '_', $name . '_' . $value)); + $_id = smarty_function_escape_special_chars(preg_replace('![^\w\-\.]!' . Smarty::$_UTF8_MODIFIER, '_', $name . '_' . $value)); $_output .= '