mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-04 10:24:26 +02:00
removed global vars from fetch function, added attrs to escape modifier
This commit is contained in:
3
NEWS
3
NEWS
@@ -1,7 +1,8 @@
|
||||
- added "hex" and "hexentity" attributes to escape modifier (Monte)
|
||||
- removed dependency on PEAR. (Andrei)
|
||||
- update popup_init to accept src attribute. (Monte, Duncan Forrest)
|
||||
- implemented several optimizations, speeding up Smarty significantly in
|
||||
most cases. (Andrei)
|
||||
most cases. (Andrei,Monte)
|
||||
- implemented plugin architecture. (Andrei)
|
||||
- added modifiers wordwrap and indent. (Monte)
|
||||
- added support for 'If-Modified-Since' headers for cached content. (Monte)
|
||||
|
@@ -5513,8 +5513,11 @@ no title
|
||||
</tgroup>
|
||||
</informaltable>
|
||||
<para>
|
||||
This is used to html escape, url escape, or escape single quotes on
|
||||
a variable not already escaped. By default, the variable is html
|
||||
This is used to html escape, url escape, escape single quotes on a
|
||||
variable not already escaped, hex escape or hexentity escape. hex
|
||||
and hexentity escape can be used in conjunction to hide "mailto:"
|
||||
links on a page from web spiders (spam collectors) and yet keep
|
||||
them readable and linkable. By default, the variable is html
|
||||
escaped.
|
||||
</para>
|
||||
<example>
|
||||
@@ -5526,6 +5529,7 @@ no title
|
||||
{$articleTitle|escape:"html"}
|
||||
{$articleTitle|escape:"url"}
|
||||
{$articleTitle|escape:"quotes"}
|
||||
<a href="mailto:{$EmailAddress|escape:"hex"}">{$EmailAddress|escape:"hexentity"}</a>
|
||||
|
||||
OUTPUT:
|
||||
|
||||
@@ -5534,6 +5538,7 @@ OUTPUT:
|
||||
'Stiff%20Opposition%20Expected%20to%20Casketless%20Funeral%20Plan'
|
||||
'Stiff+Opposition+Expected+to+Casketless+Funeral+Plan'
|
||||
\'Stiff Opposition Expected to Casketless Funeral Plan\'
|
||||
<a href="mailto:%62%6f%62%40%6d%65%2e%6e%65%74">bob@me.net</a>
|
||||
|
||||
</programlisting>
|
||||
</example>
|
||||
|
@@ -21,6 +21,17 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
||||
// escape unescaped single quotes
|
||||
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
||||
|
||||
case 'hex':
|
||||
// escape every character into hex
|
||||
for ($x=0; $x<strlen($string); $x++) {
|
||||
$return .= '%'.bin2hex($string[$x]);
|
||||
}
|
||||
return $return;
|
||||
case 'hexentity':
|
||||
for ($x=0; $x<strlen($string); $x++) {
|
||||
$return .= '&#x'.bin2hex($string[$x]).';';
|
||||
}
|
||||
return $return;
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
|
@@ -21,6 +21,17 @@ function smarty_modifier_escape($string, $esc_type = 'html')
|
||||
// escape unescaped single quotes
|
||||
return preg_replace("%(?<!\\\\)'%", "\\'", $string);
|
||||
|
||||
case 'hex':
|
||||
// escape every character into hex
|
||||
for ($x=0; $x<strlen($string); $x++) {
|
||||
$return .= '%'.bin2hex($string[$x]);
|
||||
}
|
||||
return $return;
|
||||
case 'hexentity':
|
||||
for ($x=0; $x<strlen($string); $x++) {
|
||||
$return .= '&#x'.bin2hex($string[$x]).';';
|
||||
}
|
||||
return $return;
|
||||
default:
|
||||
return $string;
|
||||
}
|
||||
|
Reference in New Issue
Block a user