Skip to content

Commit

Permalink
fixed escaping bugs in Mojo::DOM::CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Aug 4, 2014
1 parent 11f9d5e commit df23566
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion Changes
@@ -1,5 +1,6 @@

5.25 2014-08-03
5.25 2014-08-04
- Fixed escaping bugs in Mojo::DOM::CSS.

5.24 2014-08-02
- Improved url_escape performance slightly.
Expand Down
4 changes: 2 additions & 2 deletions lib/Mojo/DOM/CSS.pm
Expand Up @@ -16,9 +16,9 @@ my $ATTR_RE = qr/
/x;
my $CLASS_ID_RE = qr/
(?:
(?:\.((?:\\\.|[^\#.])+)) # Class
(?:\.((?:\\[.\#]|[^\#.])+)) # Class
|
(?:\#((?:\\\#|[^.\#])+)) # ID
(?:\#((?:\\[.\#]|[^.\#])+)) # ID
)
/x;
my $PSEUDO_CLASS_RE = qr/(?::([\w\-]+)(?:\(((?:\([^)]+\)|[^)])+)\))?)/;
Expand Down
5 changes: 5 additions & 0 deletions t/mojo/dom.t
Expand Up @@ -2349,6 +2349,11 @@ 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';

# Dot and hash in class and id attributes
$dom = Mojo::DOM->new('<p class="a#b.c">A</p><p id="a#b.c">B</p>');
is $dom->at('p.a\#b\.c')->text, 'A', 'right text';
is $dom->at('p#a\#b\.c')->text, 'B', 'right text';

# Extra whitespace
$dom = Mojo::DOM->new('< span>a< /span><b >b</b><span >c</ span>');
is $dom->at('span')->text, 'a', 'right text';
Expand Down

0 comments on commit df23566

Please sign in to comment.