From 061e1dbc2abe6c89b90348e22e5f3455a2b8328d Mon Sep 17 00:00:00 2001 From: Mischa POSLAWSKY Date: Wed, 22 Oct 2008 01:46:21 +0000 Subject: [PATCH] do not quote scalar refs to pass literal html Treat scalar references as escaped in quote(), so that raw input can be given if one really wants to. --- lib/HTML/Form/Simple.pm | 1 + t/html.t | 28 +++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/lib/HTML/Form/Simple.pm b/lib/HTML/Form/Simple.pm index bd0e15e..7d02314 100644 --- a/lib/HTML/Form/Simple.pm +++ b/lib/HTML/Form/Simple.pm @@ -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]); } diff --git a/t/html.t b/t/html.t index 5b3fa2a..a82c916 100644 --- 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">'), + '<"test">', + 'quote' +); + +is( + $form->quote(\'<"test">'), + '<"test">', + 'quote unquoted' +); + +is( + $form->tag('foo'), + '', + 'tag' +); + +is( + $form->tag('a "' => {'b"' => 'c"'}), + '', + 'tag attributes' +); + # form is( -- 2.30.0