Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fixed Mojo::DOM::HTML to handle slashes in unquoted attribute values …
…correctly
  • Loading branch information
kraih committed May 21, 2014
1 parent 6f543e3 commit db69f6a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
4 changes: 3 additions & 1 deletion Changes
@@ -1,5 +1,5 @@

5.0 2014-05-17
5.0 2014-05-21
- Code name "Tiger Face", this is a major release.
- Changed heuristics for number detection in Mojo::JSON to better line up
with user expectations.
Expand All @@ -15,6 +15,8 @@
- Added check method to Mojo::Server::Morbo.
- Updated jQuery to version 2.1.1.
- Improved Mojo::Parameters to consistently accept arrays.
- Fixed Mojo::DOM::HTML to handle slashes in unquoted attribute values
correctly.
- Fixed Mojo::IOLoop::Server to work correctly with newer versions of
IO::Socket::SSL. (noxxi)
- Fixed verification bug in Mojo::IOLoop::Server.
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojo/DOM/HTML.pm
Expand Up @@ -16,7 +16,7 @@ my $ATTR_RE = qr/
|
'([^']*?)' # Apostrophes
|
([^>\s\/]*) # Unquoted
([^>\s]*) # Unquoted
)
)?
\s*
Expand Down
10 changes: 6 additions & 4 deletions t/mojo/dom.t
Expand Up @@ -303,15 +303,17 @@ EOF
is $dom->at('script')->text, "alert('lalala');", 'right script content';

# HTML5 (unquoted values)
$dom
= Mojo::DOM->new->parse('<div id = test foo ="bar" class=tset>works</div>');
$dom = Mojo::DOM->new->parse(
'<div id = test foo ="bar" class=tset bar=/baz/ baz=//>works</div>');
is $dom->at('#test')->text, 'works', 'right text';
is $dom->at('div')->text, 'works', 'right text';
is $dom->at('[foo=bar][foo="bar"]')->text, 'works', 'right text';
is $dom->at('[foo="ba"]'), undef, 'no result';
is $dom->at('[foo=bar]')->text, 'works', 'right text';
is $dom->at('[foo=ba]'), undef, 'no result';
is $dom->at('.tset')->text, 'works', 'right text';
is $dom->at('.tset')->text, 'works', 'right text';
is $dom->at('[bar=/baz/]')->text, 'works', 'right text';
is $dom->at('[baz=//]')->text, 'works', 'right text';

# HTML1 (single quotes, uppercase tags and whitespace in attributes)
$dom = Mojo::DOM->new->parse(
Expand Down Expand Up @@ -2298,7 +2300,7 @@ is $dom->find('div > ul ul')->[0]->text, 'C', 'right text';
is $dom->find('div > ul ul')->[1], undef, 'no result';

# Slash between attributes
$dom = Mojo::DOM->new('<input /type=checkbox/value="/a/" checked/><br/>');
$dom = Mojo::DOM->new('<input /type=checkbox / value="/a/" checked/><br/>');
is_deeply $dom->at('input')->attr,
{type => 'checkbox', value => '/a/', checked => undef}, 'right attributes';
is "$dom", '<input checked type="checkbox" value="/a/"><br>', 'right result';
Expand Down

0 comments on commit db69f6a

Please sign in to comment.