Subject: | HTML::Form - work around checked="" and selected="" [patch] |
One application I'm using WWW::Mechanize against sends out form elements
like the following:
<option ... SELECTED="" />
<input type="checkbox" ... CHECKED="" />
HTML::Form parses those as being not selected and not checked, which is
not what the application intended. (The application may very well be
wrong, but it works on popular browsers..)
This patch makes HTML::Form parse those the same way as the popular
browsers.
Subject: | html-form-accept-empty-selected-checked.diff |
--- HTML/Form.pm.orig 2009-02-16 18:27:02.000000000 -0800
+++ HTML/Form.pm 2009-02-16 18:27:07.000000000 -0800
@@ -1057,7 +1057,7 @@
{ value => undef, name => "off", },
{ value => $value, name => $value_name, },
];
- $self->{current} = (delete $self->{checked}) ? 1 : 0;
+ $self->{current} = (defined delete $self->{checked}) ? 1 : 0;
;
}
else {
@@ -1066,7 +1066,7 @@
$self->{menu} = [
{value => $value, name => $value_name},
];
- my $checked = $self->{checked} || $self->{option_selected};
+ my $checked = defined $self->{checked} || defined $self->{option_selected};
delete $self->{checked};
delete $self->{option_selected};
if (exists $self->{multiple}) {