commit c9870525e17802bc748b417ab23308ef45d2d3a3
Author: Gisle Aas <gisle@aas.no>
Date: Wed Jul 23 20:07:32 2008 +0200
Checkbox picks up nearby text in description of alternates [RT#36771]
Telling HTML::Parser to not report all tags make the get_phrase() method
look too far ahead.
diff --git a/lib/HTML/Form.pm b/lib/HTML/Form.pm
index e539cfa..337bbe1 100644
--- a/lib/HTML/Form.pm
+++ b/lib/HTML/Form.pm
@@ -114,10 +114,6 @@ sub parse
require HTML::TokeParser;
my $p = HTML::TokeParser->new(ref($html) ? $html->decoded_content(ref => 1) : \$html);
die "Failed to create HTML::TokeParser object" unless $p;
- eval {
- # optimization
- $p->report_tags(qw(form input textarea select optgroup option keygen label button));
- };
my $base_uri = delete $opt{base};
my $verbose = delete $opt{verbose};
diff --git a/t/html/form.t b/t/html/form.t
index f27da8c..75a455e 100644
--- a/t/html/form.t
+++ b/t/html/form.t
@@ -3,7 +3,7 @@
use strict;
use Test qw(plan ok);
-plan tests => 124;
+plan tests => 125;
use HTML::Form;
@@ -535,3 +535,33 @@ ok(join(":", $f->find_input("r1")->value_names), "one");
ok(join(":", $f->find_input("r2")->value_names), "two");
ok(join(":", $f->find_input("r3")->value_names), "nested");
ok(join(":", $f->find_input("r4")->value_names), "before and after");
+
+$f = HTML::Form->parse(<<EOT, "
http://www.example.com");
+<form>
+ <table>
+ <TR>
+ <TD align="left" colspan="2">
+ Keep me informed on the progress of this election
+ <INPUT type="checkbox" id="keep_informed" name="keep_informed" value="yes" checked>
+ </TD>
+ </TR>
+ <TR>
+ <TD align=left colspan=2>
+ <BR><B>The place you are registered to vote:</B>
+ </TD>
+ </TR>
+ <TR>
+ <TD valign="middle" height="2" align="right">
+ <A name="Note1back">County or Parish</A>
+ </TD>
+ <TD align="left">
+ <INPUT type="text" id="reg_county" size="40" name="reg_county" value="">
+ </TD>
+ <TD align="left" width="10">
+ <A href="#Note2" class="c2" tabindex="-1">Note 2</A>
+ </TD>
+ </TR>
+ </table>
+</form>
+EOT
+ok(join(":", $f->find_input("keep_informed")->value_names), "off:");