Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed another HTML5 unescaping bug
  • Loading branch information
kraih committed Apr 23, 2012
1 parent a861330 commit 40809b6
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
3 changes: 1 addition & 2 deletions lib/Mojo/Util.pm
Expand Up @@ -2376,8 +2376,7 @@ $REVERSE_ENTITIES{$ENTITIES{$_}} //= $_ for reverse sort keys %ENTITIES;
$ENTITIES{'apos;'} = "\x{0027}";

# Entities regex for html_unescape
my $ENTITIES_RE
= qr/&(?:\#((?:\d{1,7}|x[0-9A-Fa-f]{1,6}));|([A-Za-z]{1,8};?))/;
my $ENTITIES_RE = qr/&(?:\#((?:\d{1,7}|x[0-9A-Fa-f]{1,6}));|([\w\.]+;?))/;

# Encode cache
my %ENCODE;
Expand Down
7 changes: 6 additions & 1 deletion t/mojo/bytestream.t
Expand Up @@ -5,7 +5,7 @@ use utf8;
# "Homer, we're going to ask you a few simple yes or no questions.
# Do you understand?
# Yes. *lie dectector blows up*"
use Test::More tests => 142;
use Test::More tests => 143;

# Need to be loaded first to trigger edge case
use MIME::Base64;
Expand Down Expand Up @@ -202,6 +202,11 @@ is $stream->html_escape, 'foobar', 'right html escaped result';
$stream = b('foobar<baz>&"');
is $stream->html_unescape, "foobar<baz>&\"", 'right html unescaped result';

# html_unescape (special entities)
$stream = b('foo &CounterClockwiseContourIntegral; bar &b.Sigma; &sup1baz');
is $stream->html_unescape, "foo \x{2233} bar \x{1d6ba} \x{00b9}baz",
'right html unescaped result';

# html_unescape (apos)
$stream = b('foobar&apos;&lt;baz&gt;&#x26;&#34;');
is $stream->html_unescape, "foobar'<baz>&\"", 'right html unescaped result';
Expand Down

0 comments on commit 40809b6

Please sign in to comment.