add 'nonstd' escape modifier

This commit is contained in:
mohrt
2004-05-12 19:40:36 +00:00
parent 2647dfea67
commit 530795cbf5
2 changed files with 18 additions and 1 deletions

2
NEWS
View File

@@ -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 - adjusted textformat to not output wrap chars after last para
(Monte) (Monte)
- use tempnam() instead of unqid() to create better temporary files in - use tempnam() instead of unqid() to create better temporary files in

View File

@@ -62,7 +62,22 @@ function smarty_modifier_escape($string, $esc_type = 'html')
case 'mail': case 'mail':
// safe way to display e-mail address on a web page // 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: default:
return $string; return $string;