do not quote scalar refs to pass literal html
authorMischa POSLAWSKY <perl@shiar.org>
Wed, 22 Oct 2008 01:46:21 +0000 (01:46 +0000)
committerMischa POSLAWSKY <perl@shiar.org>
Wed, 22 Oct 2008 01:46:21 +0000 (01:46 +0000)
Treat scalar references as escaped in quote(), so that raw input can be
given if one really wants to.

lib/HTML/Form/Simple.pm
t/html.t

index bd0e15e..7d02314 100644 (file)
@@ -24,6 +24,7 @@ sub _attr {
 
 sub quote {
        my $self = shift;
+       return ${$_[0]} if ref $_[0] eq 'SCALAR';
        return XML::Quote::xml_quote_min($_[0]);
 }
 
index 5b3fa2a..a82c916 100644 (file)
--- a/t/html.t
+++ b/t/html.t
@@ -5,13 +5,39 @@ use warnings;
 
 use Test::More;
 
-plan tests => 72;
+plan tests => 76;
 
 use_ok('HTML::Form::Simple');
 
 my $form = HTML::Form::Simple->new;
 ok($form, 'new form');
 
+# basics
+
+is(
+       $form->quote('<"test">'),
+       '&lt;&quot;test&quot;>',
+       'quote'
+);
+
+is(
+       $form->quote(\'<"test">'),
+       '<"test">',
+       'quote unquoted'
+);
+
+is(
+       $form->tag('foo'),
+       '<foo>',
+       'tag'
+);
+
+is(
+       $form->tag('a "' => {'b"' => 'c"'}),
+       '<a " b"="c&quot;">',
+       'tag attributes'
+);
+
 # form
 
 is(