Attached are patches/tests for the following bugs: * when specifying a default_escape, you can't turn it off
I have fixed ESCAPE=0 and added ESCAPE=NONE to turn off escaping altogether for a TMPL_VAR. The pod was also updated to reflect this change.
Usage: <TMPL_VAR foo ESCAPE=NONE> <TMPL_VAR foo ESCAPE=0> * ESCAPE='JS' did not work I fixed a regex so that single quotes around JS now works. I have also added a new test file: 04default_escape.t Tom
04default_escape.t
Description: Troff document
--- Template.pm 2005-12-21 15:21:01.000000000 -0800
+++ blib/lib/HTML/Template.pm 2006-03-15 22:40:10.000000000 -0800
@@ -126,8 +126,9 @@
You'll get what you wanted no matter what value happens to be passed in for
param. You can also write ESCAPE="HTML", ESCAPE='HTML' and ESCAPE='1'.
-Substitute a 0 for the HTML and you turn off escaping, which is the default
-anyway.
+
+"ESCAPE=0" and "ESCAPE=NONE" turn off escaping, which is the default
+behavior.
There is also the "ESCAPE=URL" option which may be used for VARs that
populate a URL. It will do URL escaping, like replacing ' ' with '+'
@@ -1859,18 +1860,13 @@
[Ee][Ss][Cc][Aa][Pp][Ee]
\s*=\s*
(?:
- (?: 0 | (?:"0") | (?:'0') )
- |
- ( 1 | (?:"1") | (?:'1') |
- (?:[Hh][Tt][Mm][Ll]) |
- (?:"[Hh][Tt][Mm][Ll]") |
- (?:'[Hh][Tt][Mm][Ll]') |
- (?:[Uu][Rr][Ll]) |
- (?:"[Uu][Rr][Ll]") |
- (?:'[Uu][Rr][Ll]') |
- (?:[Jj][Ss]) |
- (?:"[Jj][Ss]") |
- (?:'[Jj][Ss]') |
+ (
+ (?:["']?0["']?)|
+ (?:["']?1["']?)|
+ (?:["']?[Hh][Tt][Mm][Ll]["']?) |
+ (?:["']?[Uu][Rr][Ll]["']?) |
+ (?:["']?[Jj][Ss]["']?) |
+ (?:["']?[Nn][Oo][Nn][Ee]["']?)
) # $5 => ESCAPE on
)
)* # allow multiple ESCAPEs
@@ -1929,18 +1925,13 @@
[Ee][Ss][Cc][Aa][Pp][Ee]
\s*=\s*
(?:
- (?: 0 | (?:"0") | (?:'0') )
- |
- ( 1 | (?:"1") | (?:'1') |
- (?:[Hh][Tt][Mm][Ll]) |
- (?:"[Hh][Tt][Mm][Ll]") |
- (?:'[Hh][Tt][Mm][Ll]') |
- (?:[Uu][Rr][Ll]) |
- (?:"[Uu][Rr][Ll]") |
- (?:'[Uu][Rr][Ll]') |
- (?:[Jj][Ss]) |
- (?:"[Jj][Ss]") |
- (?:'[Jj][Ss]') |
+ (
+ (?:["']?0["']?)|
+ (?:["']?1["']?)|
+ (?:["']?[Hh][Tt][Mm][Ll]["']?) |
+ (?:["']?[Uu][Rr][Ll]["']?) |
+ (?:["']?[Jj][Ss]["']?) |
+ (?:["']?[Nn][Oo][Nn][Ee]["']?)
) # $15 => ESCAPE on
)
)* # allow multiple ESCAPEs
@@ -2023,11 +2014,16 @@
# if ESCAPE was set, push an ESCAPE op on the stack before
# the variable. output will handle the actual work.
+ # unless of course, they have set escape=0 or escape=none
if ($escape) {
if ($escape =~ /^["']?[Uu][Rr][Ll]["']?$/) {
push(@pstack, $URLESCAPE);
- } elsif ($escape =~ /^"?[Jj][Ss]"?$/) {
+ } elsif ($escape =~ /^["']?[Jj][Ss]["']?$/) {
push(@pstack, $JSESCAPE);
+ } elsif ($escape =~ /^["']?0["']?$/) {
+ # do nothing if escape=0
+ } elsif ($escape =~ /^["']?[Nn][Oo][Nn][Ee]["']?$/ ) {
+ # do nothing if escape=none
} else {
push(@pstack, $ESCAPE);
}
