X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=xt%2Ftt.t;h=9479a732f4d5f7f6bd22eea7c82ebaeb76f40fcf;hb=skaufman%2Ftt_anycase;hp=a370a1a29f22c9da1bf998d5f569c9d14e84990d;hpb=cf61306dc93f5176e1fd15d2f6ac8338a8481dfd;p=scpubgit%2FHTML-String.git diff --git a/xt/tt.t b/xt/tt.t index a370a1a..9479a73 100644 --- a/xt/tt.t +++ b/xt/tt.t @@ -1,7 +1,7 @@ use strictures 1; use Test::More; use HTML::String::TT; - +plan tests => 10; my $tt = HTML::String::TT->new; sub do_tt { @@ -50,7 +50,7 @@ is( '[% FOREACH item IN items %][% item %][% END %]', { items => [ '', '-> & so "on" <-' ] } ), - '<script>alert("lalala")</script>' + '<script>alert("lalala")</script>' .'-> & so "on" <-' ); @@ -67,11 +67,24 @@ is( do_tt('"0"', {}), '"0"' ); ]; my $with_html_string_tt = do_tt($tmpl, {}); - $tt = Template->new(STASH => Template::Stash->new); my $with_template = do_tt($tmpl, {}); is $with_html_string_tt, $with_template; } +sub _is_escaped { + my $test_name = shift; + $tt = HTML::String::TT->new( @_ ); + is( + do_tt( + '[%- if 1; unsafe_js; %][% end %]', + { unsafe_js => '' } + ), + '<script>alert("anycase alert");</script>', + $test_name + ); +} +_is_escaped('ANYCASE => 1 in a hash',ANYCASE => 1 ); +_is_escaped('ANYCASE => 1 in a hashref',{ ANYCASE => 1 }); done_testing;