Hello,
I just filed a ticket for this at
http://code.google.com/p/html-formfu/issues/detail?id=60
but it looks like the mailing list is more active than the issue
tracker, so I'm reposting here.
It seems that attributes attached to the options of Selects,
Radiogroups and Checkboxgroups are not being properly
xml-escaped.
The attached test script demonstrations the bug. (For me, with FF 0.06001,
tests 1, 3 & 5 fail.)
The attached patch may or may not be the solution. It seems to work, but I
haven't tested it thoroughly; and even if it works, it may or may not be
the best solution.
Cheers,
Jeff
#!/usr/bin/perl
use strict;
use warnings;
use Test::More tests => 6;
use HTML::FormFu;
use Regexp::Common;
sub test_group_option_attr_escaping {
my ($elem_type) = @_;
my $form = new HTML::FormFu;
my $field = $form->element($elem_type)->name('test')
->options([
{ value => 1,
label => 'First',
attributes => { myattr => 'needs&escaping' },
label_attributes => { myattr => 'needs&escaping' },
container_attributes => { myattr => 'needs&escaping' },},
{ value => 2,
label => 'Second',
attributes_xml => { myattr => 'pre&escaped' } },
]);
unlike $field, qr/myattr=.needs&escaping/,
"$elem_type: option attributes";
like $field, qr/myattr=.pre&escaped/,
"$elem_type: option attributes_xml";
}
test_group_option_attr_escaping($_)
for qw/Select Radiogroup Checkboxgroup/;
--- HTML/FormFu/Element/_Group.pm.orig 2010-04-22 21:09:24.000000000 -0700
+++ HTML/FormFu/Element/_Group.pm 2010-04-22 21:11:56.000000000 -0700
@@ -378,6 +378,9 @@
foreach my $opt (@$options) {
$opt->{label} = xml_escape( $opt->{label} );
$opt->{value} = xml_escape( $opt->{value} );
+ $opt->{attributes} = xml_escape( $opt->{attributes} );
+ $opt->{label_attributes} = xml_escape( $opt->{label_attributes} );
+ $opt->{container_attributes} = xml_escape( $opt->{container_attributes} );
if ( exists $opt->{group} ) {
$self->_quote_options( $opt->{group} );
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu