Disabled, checked radiobutton being submitted
[email protected] (Adam Sjøgren)
| Newsgroups | gmane.comp.lang.perl.modules.lwp |
|---|---|
| Organization | koldfront - analysis & revolution, Copenhagen, Denmark |
| Message-ID | <[email protected]> |
Hi.
When I have a disabled, checked radiobutton and a hidden field, both
with the same name, the disabled radiobutton "succeeds" and it's value
is submitted by HTML::Form.
If I understand section 17.12.1 "Disabled controls"¹ in the HTML 4.01
standard correctly, the radiobutton should not succeed when disabled,
and this following test should be valid (patch against libwww-perl-5.808,
Debian testing):
--- t/html/form.t.orig 2008-02-12 10:33:18.000000000 +0100
+++ t/html/form.t 2008-02-12 10:34:20.000000000 +0100
@@ -3,7 +3,7 @@
use strict;
use Test qw(plan ok);
-plan tests => 122;
+plan tests => 123;
use HTML::Form;
@@ -417,6 +417,20 @@
ok(eval{$f->find_input("m3", undef, 2)->value(undef)}, undef);
ok($@ && $@ =~ /^The 'm3' field can't be unchecked/);
+# Try a disabled radiobutton:
+$f = HTML::Form->parse(<<EOT, "http://localhost/");
+<form>
+ <input disabled checked type=radio name=f value=a>
+ <input type=hidden name=f value=b>
+</form>
+
+EOT
+
+ok($f->click->as_string, <<'EOT');
+GET http://localhost/?f=b
+
+EOT
+
$f = HTML::Form->parse(<<EOT, "http://www.example.com");
<!-- from http://www.blooberry.com/indexdot/html/tagpages/k/keygen.htm -->
<form METHOD="post" ACTION="http://example.com/secure/keygen/test.cgi" ENCTYPE="application/x-www-form-urlencoded">
(Neither Mozilla nor Microsoft Internet Explorer submits the radiobutton
value, not that that proves anything...)
Does this seem correct? If so, I will see if I can whip up a patch to
fix it (unless someone beats me to it).
Best regards,
Adam
¹ <http://www.w3.org/TR/html4/interact/forms.html#adef-disabled>
--
"You know, if the sun was an oboe, what would you do?" Adam Sjøgren
[email protected]