Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the CGI CPAN distribution.

Report information
The Basics
Id: 36583
Status: resolved
Priority: 0/
Queue: CGI

People
Owner: MARKSTOS [...] cpan.org
Requestors: ASPEER [...] cpan.org
Cc: andrew.speer [...] isolutions.com.au
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: andrew.speer [...] isolutions.com.au
Subject: Malformed output from checkbox_group
The following CGI.pm code will produce malformed HTML - the "checked" tag attribute runs on from other attributes with no space: perl -MCGI=-no_xhtml -e 'print CGI->checkbox_group({ values=>[1,2], defaults=>[1] })' produces: <input type="checkbox" name="" value="1"checked >1<input type .. Note the runon after value=1 Culprit appears to be line 890 in CGI.pm version 3.37: return $XHTML ? qq(checked="checked" ) : qq(checked ); should probably be qq( checked ); Same bug may apply in _selected routine a few lines up (line 883) .. Thanks for creating and looking after the CGI.pm module .. Regards, Andrew Speer
On Mon Jun 09 09:03:48 2008, ASPEER wrote: Show quoted text
> The following CGI.pm code will produce malformed HTML - the "checked" > tag attribute runs on from other attributes with no space: > > perl -MCGI=-no_xhtml -e 'print CGI->checkbox_group({ values=>[1,2], > defaults=>[1] })' > > produces: > > <input type="checkbox" name="" value="1"checked >1<input type .. > > Note the runon after value=1 > > Culprit appears to be line 890 in CGI.pm version 3.37: > > return $XHTML ? qq(checked="checked" ) : qq(checked ); > > should probably be qq( checked ); > > Same bug may apply in _selected routine a few lines up (line 883) .. > > Thanks for creating and looking after the CGI.pm module .. > > Regards, > > Andrew Speer
Thanks for the report. To proceed, next we'll need an automated test which illustrates the issue. Thanks for your help! Mark
I have a test and a patch ready for version 3.45 and am just wondering where to put the test - I thought about adding it to form.t where the rest of the checkbox_group tests are but this is only a problem when the -no_xhtml flag is set. Should I make a new test file that will hold the tests that require -no_xhtml? Show quoted text
> > Thanks for the report. > > To proceed, next we'll need an automated test which illustrates the > issue. Thanks for your help! > > Mark
On Sat Aug 15 17:42:11 2009, BUBAFLUB wrote: Show quoted text
> I have a test and a patch ready for version 3.45 and am just wondering > where to put the test - I thought about adding it to form.t where the > rest of the checkbox_group tests are but this is only a problem when the > -no_xhtml flag is set. Should I make a new test file that will hold the > tests that require -no_xhtml?
Thanks. Please create a new "checkbox_group.t" script and put the test in there.
Show quoted text
> > Thanks.
No problem. Show quoted text
> > Please create a new "checkbox_group.t" script and put the test in there.
Attached is a patch file that contains the changes to CGI.pm and the new test file, checkbox_group.t If it's more convenient, I have forked the project on github and you can pull my changes from http://github.com/bubaflub/CGI.pm/tree/master
From 25857ba9ac36cf80d9505e6f6f0b390844fa146d Mon Sep 17 00:00:00 2001 From: Bob Kuo <bob@celect.org> Date: Sat, 15 Aug 2009 18:14:15 -0500 Subject: [PATCH] fixes RT #36583: malformed output from checkbox_group (with -no_xhtml flag) --- lib/CGI.pm | 2 +- t/checkbox_group.t | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletions(-) create mode 100644 t/checkbox_group.t diff --git a/lib/CGI.pm b/lib/CGI.pm index 3bf17db..775871c 100644 --- a/lib/CGI.pm +++ b/lib/CGI.pm @@ -2475,7 +2475,7 @@ sub _box_group { CGI::label($labelattributes, qq(<input type="$box_type" name="$name" value="$_" $checkit$other$tab$attribs$disable/>$label)).${break}; } else { - push(@elements,qq/<input type="$box_type" name="$name" value="$_"$checkit$other$tab$attribs$disable>${label}${break}/); + push(@elements,qq/<input type="$box_type" name="$name" value="$_" $checkit$other$tab$attribs$disable>${label}${break}/); } } $self->register_parameter($name); diff --git a/t/checkbox_group.t b/t/checkbox_group.t new file mode 100644 index 0000000..61e1bc4 --- /dev/null +++ b/t/checkbox_group.t @@ -0,0 +1,12 @@ +#!/usr/local/bin/perl -w + +use Test::More tests => 2; + +BEGIN { use_ok('CGI'); }; +use CGI (':standard','-no_debug','-no_xhtml'); + +is(checkbox_group(-name => 'game', + '-values' => [qw/checkers chess cribbage/], + '-defaults' => ['cribbage']), + qq(<input type="checkbox" name="game" value="checkers" >checkers <input type="checkbox" name="game" value="chess" >chess <input type="checkbox" name="game" value="cribbage" checked >cribbage), + 'checkbox_group()'); -- 1.6.3.1
Thanks. I happened to see this first on GitHub and commented there: http://github.com/bubaflub/CGI.pm/commit/25857ba9ac36cf80d9505e6f6f0b390844fa146d#comment_27521
Thanks, this patch has now been accepted and pushed to my public github repo now. Mark
Subject: Thanks, released
The patch for this ticket has now been released in CGI.pm 3.47, and this ticket is considered resolved. Thanks again for you help to improve CGI.pm! Mark