Skip Menu |

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

Report information
The Basics
Id: 73472
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 parsing -- empty attribute value
Date: Sat, 24 Dec 2011 13:52:26 -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 fails to parse empty attribute values (e.g., '[a=""]'). 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="">', ); foreach my $in ( @data ) { my $out = HTML::Zoom->from_html($in) ->select('[value=""]')->set_attribute('value' => '1') ->to_html; print "in: $in\n", "out: $out\n", "\n"; print "\n"; }
-------------- script output -------------- Error parsing dispatch specification: Unmatched [ [value="" ^ here
-------------- 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-2.pm 2011-12-24 13:23:09.000000000 -0600 *************** *** 6,13 **** my $sel_char = '-\w_'; my $sel_meta_char = q-!"#$%&'()*+,./:;<=>?@[\]^`{|}~-; ! my $sel_re = qr/((?:(?:\\[\Q$sel_meta_char\E])|[$sel_char])+)/; ! my $match_value_re = qr/"?$sel_re"?/; sub new { bless({}, shift) } --- 6,14 ---- my $sel_char = '-\w_'; my $sel_meta_char = q-!"#$%&'()*+,./:;<=>?@[\]^`{|}~-; ! my $sel_item = qr/(?:(?:\\[\Q$sel_meta_char\E])|[$sel_char])/; ! my $sel_re = qr/($sel_item+)/; ! my $match_value_re = qr/"?($sel_item*)"?/; sub new { bless({}, shift) } *************** *** 207,209 **** --- 208,216 ---- } 1; + + __END__ + + 2011-12-23 Jim Miner + Fix parsing of selectors matching against attribute value "" (empty). + (This does not fix parsing of single-quoted attribute values.)