mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 18:34:27 +02:00
add 'nonstd' escape modifier
This commit is contained in:
2
NEWS
2
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
|
||||
|
@@ -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;
|
||||
|
Reference in New Issue
Block a user