diff --git a/NEWS b/NEWS index 87cbe2c2..58fbdf18 100644 --- a/NEWS +++ b/NEWS @@ -1,3 +1,5 @@ + - add 'nonstd' to escape modifier for escaping non-std chars, + such as ms doc quote (Monte) - adjusted textformat to not output wrap chars after last para (Monte) - use tempnam() instead of unqid() to create better temporary files in diff --git a/libs/plugins/modifier.escape.php b/libs/plugins/modifier.escape.php index 1f441688..855b1d14 100644 --- a/libs/plugins/modifier.escape.php +++ b/libs/plugins/modifier.escape.php @@ -62,7 +62,22 @@ function smarty_modifier_escape($string, $esc_type = 'html') case 'mail': // safe way to display e-mail address on a web page - return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '),$string); + return str_replace(array('@', '.'),array(' [AT] ', ' [DOT] '), $string); + + case 'nonstd': + // escape non-standard chars, such as ms document quotes + $_res = ''; + for($_i = 0, $_len = strlen($string); $_i < $_len; $_i++) { + $_ord = ord($string{$_i}); + // non-standard char, escape it + if($_ord >= 126){ + $_res .= '&#' . $_ord . ';'; + } + else { + $_res .= $string{$_i}; + } + } + return $_res; default: return $string;