mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 02:44: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
|
- 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
|
||||||
|
@@ -64,6 +64,21 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user