Skip Menu |

This queue is for tickets about the HTML-Zoom CPAN distribution.

Report information
The Basics
Id: 73471
Status: resolved
Priority: 0/
Queue: HTML-Zoom

People
Owner: cpan [...] papercreatures.com
Requestors: m-rt.cpan.org-98jw3v [...] lexoid.com
Cc:
AdminCc:

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



Subject: Bug in selector generation -- attribute values "0" and ""
Date: Sat, 24 Dec 2011 13:50:41 -0600
To: bug-HTML-Zoom [...] rt.cpan.org
From: Jim Miner <m-rt.cpan.org-98jw3v [...] lexoid.com>
Bug report for HTML-Zoom-0.009006 / perl v5.8.8 / (OSX 10.5 & RHEL4) The selector parser does not generate valid selector code when matching against the attribute value "0" (zero) or "" (empty). Below find: - script demonstrating the bug. - output of the script. - patch. Show quoted text
-------------- script -------------- #!/usr/bin/perl use strictures 1; use HTML::Zoom; my @data = ( '<input type="radio" name="x" value="0">', ); foreach my $in ( @data ) { my $out = HTML::Zoom->from_html($in)->select('[value="0"]')->set_attribute('value' => '1')->to_html; print "in: $in\n", "out: $out\n", "\n"; print "\n"; }
-------------- script output -------------- in: <input type="radio" name="x" value="0"> out: <input type="radio" name="x" value="0">
-------------- patch -------------- *** HTML-Zoom-0.009006/lib/HTML/Zoom/SelectorParser.pm 2011-05-11 13:58:15.000000000 -0500 --- HTML-Zoom-0.009006/lib/HTML/Zoom/SelectorParser-FIX-1.pm 2011-12-24 13:10:31.000000000 -0600 *************** *** 54,60 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E/; } }; --- 54,60 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E/; } }; *************** *** 65,71 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E$/; } }; --- 65,71 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E$/; } }; *************** *** 76,82 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E/; } }; --- 76,82 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E/; } }; *************** *** 87,93 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\b\Q$value\E\b/; } }; --- 87,93 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\b\Q$value\E\b/; } }; *************** *** 98,104 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E(?:-|$)/; } }; --- 98,104 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E(?:-|$)/; } }; *************** *** 109,115 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value; } }; --- 109,115 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value; } }; *************** *** 120,126 **** my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! ! ($_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value); } }; --- 120,126 ---- my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { ! ! (exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value); } }; *************** *** 207,209 **** --- 207,217 ---- } 1; + + __END__ + + + __END__ + + 2011-12-23 Jim Miner + Fix matching against attribute value "0" (zero) or "" (empty).