Add a failing test for unwanted escaping
[scpubgit/HTML-String.git] / xt / tt.t
diff --git a/xt/tt.t b/xt/tt.t
index bd0af60..02439a7 100644 (file)
--- a/xt/tt.t
+++ b/xt/tt.t
@@ -28,4 +28,49 @@ is(
     '<tag>Hi <bob></tag>',
 );
 
+# Check we aren't nailed by https://rt.perl.org/rt3/Ticket/Display.html?id=49594
+
+is(
+    do_tt('<foo>"$bar"</foo>'."\n"),
+    '<foo>"$bar"</foo>'."\n"
+);
+
+is(
+    do_tt(
+        '[% FOREACH item IN items %][% item %][% END %]',
+        { items => [ '<script>alert("lalala")</script>', '-> & so "on" <-' ] }
+    ),
+    '&lt;script&gt;alert(&quot;lalala&quot;)&lt;/script&gt;'          
+        .'-&gt; &amp; so &quot;on&quot; &lt;-'
+);
+
+is( do_tt('"0"', {}), '"0"' );
+
+{
+    use utf8;
+
+    is(
+        do_tt('<li>foo – bar.</li>', {}),
+        '<li>foo – bar.</li>',
+    );
+}
+
+{
+    my $tmpl = q[
+        [%- MACRO test(name, value) BLOCK;
+            IF !value.length;
+               "ok";
+            END;
+        END; -%]
+[%- test("foo", "") -%]
+];
+
+    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;
+}
+
 done_testing;