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 bd0e15e277f7ebb33914332fccc1b59345ed4102..7d023146eef48d65c69bb858dff5fe50b5c317bf 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 5b3fa2a13600b6a4d136c2ecc69f0c9af305fd95..a82c916d0b5fbecf87531d0f5538bf539b4a2c8a 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(