From: Simon Elliott Date: Thu, 28 Feb 2013 12:18:17 +0000 (+0000) Subject: patches from rt X-Git-Tag: 0.009009~1^2~3 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FHTML-Zoom.git;a=commitdiff_plain;h=4c6b44299edb3613877d7e99586026423e9f15b5 patches from rt --- diff --git a/Changes b/Changes index f966b95..4944407 100644 --- a/Changes +++ b/Changes @@ -1,3 +1,20 @@ +0.009008 2013-02-28 + - Several patches for incorrect functionality (thanks to Jim Miner & + stratman@gmail.com) :- + + - Don't throw away leading PCDATA in $text, in _hacky_tag_parser(). + This is important so we can use from_html and replace_content to + insert fragments with or without markup into templates. + + - Fix matching against attribute value "0" (zero) or "" (empty). + + - Fix parsing of selectors matching against attribute value "" (empty). + (This does not fix parsing of single-quoted attribute values.) + +0.009007 2013-02-24 + - Remove long form ( name, value ) for attributes to set_attribute / add_attribute + to allow future enhancements (selector in options). + 0.009006 2011-05-20 - Add DESTROY method to fix test failures / warnings in perl >= 5.13.1 diff --git a/Makefile.PL b/Makefile.PL deleted file mode 100644 index 0dc20df..0000000 --- a/Makefile.PL +++ /dev/null @@ -1,13 +0,0 @@ -use strict; -use warnings FATAL => 'all'; -use 5.008001; -use ExtUtils::MakeMaker; - -(do 'maint/Makefile.PL.include' or die $@) unless -f 'META.yml'; - -WriteMakefile( - NAME => 'HTML-Zoom', - VERSION_FROM => 'lib/HTML/Zoom.pm', - PREREQ_PM => { strictures => 1, 'Test::More' => '0.88' }, - test => { TESTS => 't/*.t t/*/*.t' }, -); diff --git a/dist.ini b/dist.ini new file mode 100644 index 0000000..b4b1985 --- /dev/null +++ b/dist.ini @@ -0,0 +1,11 @@ +name = HTML-Zoom +version = 0.009007 +author = Matt S. Trout +license = Perl_5 +copyright_holder = Matt S. Trout + +[@Basic] + +[Prereqs] +strictures = 0 +Test::More = 0 diff --git a/lib/HTML/Zoom.pm b/lib/HTML/Zoom.pm index 208bf77..eba4adf 100644 --- a/lib/HTML/Zoom.pm +++ b/lib/HTML/Zoom.pm @@ -8,7 +8,7 @@ use HTML::Zoom::Transform; use HTML::Zoom::TransformBuilder; use Scalar::Util (); -our $VERSION = '0.009007_1'; +our $VERSION = '0.009007'; $VERSION = eval $VERSION; diff --git a/lib/HTML/Zoom/FilterBuilder.pm b/lib/HTML/Zoom/FilterBuilder.pm index 1b92c09..6713841 100644 --- a/lib/HTML/Zoom/FilterBuilder.pm +++ b/lib/HTML/Zoom/FilterBuilder.pm @@ -43,8 +43,6 @@ sub set_attribute { sub _parse_attribute_args { my $self = shift; - # allow ->add_to_attribute(name => 'value') - # or ->add_to_attribute({ name => 'name', value => 'value' }) die "Long form arg (name => 'class', value => 'x') is no longer supported" if(@_ == 1 && $_[0]->{'name'} && $_[0]->{'value'}); diff --git a/lib/HTML/Zoom/Parser/BuiltIn.pm b/lib/HTML/Zoom/Parser/BuiltIn.pm index 13ae444..1e87919 100644 --- a/lib/HTML/Zoom/Parser/BuiltIn.pm +++ b/lib/HTML/Zoom/Parser/BuiltIn.pm @@ -27,6 +27,10 @@ sub html_to_stream { sub _hacky_tag_parser { my ($text, $handler) = @_; + $text =~ m{^([^<]*)}g; + if ( length $1 ) { # leading PCDATA + $handler->({ type => 'TEXT', raw => $1 }); + } while ( $text =~ m{ ( diff --git a/lib/HTML/Zoom/SelectorParser.pm b/lib/HTML/Zoom/SelectorParser.pm index e2215f9..1432c4d 100644 --- a/lib/HTML/Zoom/SelectorParser.pm +++ b/lib/HTML/Zoom/SelectorParser.pm @@ -6,8 +6,9 @@ use Carp qw(confess); 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"?/; +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) } @@ -54,7 +55,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E/; } }; @@ -65,7 +66,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E$/; } }; @@ -76,7 +77,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\Q$value\E/; } }; @@ -87,7 +88,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/\b\Q$value\E\b/; } }; @@ -98,7 +99,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} =~ qr/^\Q$value\E(?:-|$)/; } }; @@ -109,7 +110,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - $_[0]->{attrs}{$attribute} + exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value; } }; @@ -120,7 +121,7 @@ sub _raw_parse_simple_selector { my $attribute = $_[0]->_unescape($1); my $value = $_[0]->_unescape($2); sub { - ! ($_[0]->{attrs}{$attribute} + ! (exists $_[0]->{attrs}{$attribute} && $_[0]->{attrs}{$attribute} eq $value); } };