From: Dan Book Date: Wed, 23 Dec 2015 16:13:38 +0000 (-0500) Subject: fix bug where html_unescape would try to unescape non-ascii numerics X-Git-Tag: v0.003~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=catagits%2FDOM-Tiny.git;a=commitdiff_plain;h=4d7ffd9750b680d72934879b281bce45448807a4 fix bug where html_unescape would try to unescape non-ascii numerics --- diff --git a/Changes b/Changes index 4bc93f7..52c9ae0 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,7 @@ {{$NEXT}} - Merge several CSS bugfixes and improvements from Mojolicious 6.31 and 6.32. - Merge wrap and wrap_content bugfixes from Mojolicious 6.34. + - Fix small html_unescape bug in DOM::Tiny::Entities 0.002 2015-11-09 19:28:42 EST - Support perl 5.8 (mst) diff --git a/META.json b/META.json index 682ac7e..ee5941e 100644 --- a/META.json +++ b/META.json @@ -4,7 +4,7 @@ "Dan Book " ], "dynamic_config" : 0, - "generated_by" : "Dist::Zilla version 5.041, CPAN::Meta::Converter version 2.150005", + "generated_by" : "Dist::Zilla version 5.042, CPAN::Meta::Converter version 2.150005", "license" : [ "artistic_2" ], diff --git a/Makefile.PL b/Makefile.PL index 4b415a2..7b1e928 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -1,4 +1,4 @@ -# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.041. +# This file was automatically generated by Dist::Zilla::Plugin::MakeMaker v5.042. use strict; use warnings; diff --git a/lib/DOM/Tiny/Entities.pm b/lib/DOM/Tiny/Entities.pm index db25659..7b76fd4 100644 --- a/lib/DOM/Tiny/Entities.pm +++ b/lib/DOM/Tiny/Entities.pm @@ -33,7 +33,7 @@ sub html_escape { sub html_unescape { my $str = shift; - $str =~ s/&(?:\#((?:\d{1,7}|x[0-9a-fA-F]{1,6}));|(\w+;))/_decode($1, $2)/ge; + $str =~ s/&(?:\#((?:[0-9]{1,7}|x[0-9a-fA-F]{1,6}));|(\w+;))/_decode($1, $2)/ge; return $str; } diff --git a/t/entities.t b/t/entities.t index e3012d5..7d8f879 100644 --- a/t/entities.t +++ b/t/entities.t @@ -24,6 +24,9 @@ is html_unescape('foobar'<baz>&"'), "foobar'&\"", # html_unescape (nothing to unescape) is html_unescape('foobar'), 'foobar', 'right HTML unescaped result'; +# html_unescape (bengal numbers with nothing to unescape) +is html_unescape('&#০৩৯;&#x০৩৯;'), '&#০৩৯;&#x০৩৯;', 'no changes'; + # html_unescape (UTF-8) is html_unescape(decode 'UTF-8', 'foo<baz>&"Œ&Foo;'), "foo&\"\x{152}&Foo;", 'right HTML unescaped result';