Subject: | Using -attributes and -disabled with a checkbox_group generates invalid HTML |
Date: | Tue, 08 Oct 2013 20:53:24 +0000 |
To: | bug-CGI.pm [...] rt.cpan.org |
From: | Jörg Westheide <joerg [...] port25.com> |
I found the following code to generate invalid HTML:
#!/usr/bin/perl -w
use strict;
use CGI;
my $q = CGI->new();
print $q->checkbox_group(-name => 'box', -values => 'a',
-disabled => ["a"],
-attributes => {"a" => {"foo" => "bar"}});
The generated output is:
<label><input type="checkbox" name="box" value="a"
foo="bar"disabled='1'/><span style="color:gray">a</span></label>
Note the missing white space between foo="bar" and disabled='1'.
The bug is reproducible with CGI.pm versions 3.42 and 3.63, presumably
all versions in between and possibly older ones, too.
Here's a diff of a possible fix of v3.63:
--- CGI.pm 2012-11-15 00:42:54.000000000 +0100
+++ CGI.pm 2013-10-08 17:31:02.000000000 +0200
@@ -2476,7 +2476,7 @@
for (@values) {
my $disable="";
if ($disabled{$_}) {
- $disable="disabled='1'";
+ $disable=" disabled='1'";
}
my $checkit = $self->_checked($box_type eq 'radio' ?
($checked{$_} && !$radio_checked++)
Jörg