Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

HTML4 allows whitespace between the -- and > ending a comment #390

Merged
merged 1 commit into from

2 participants

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 2 deletions.
  1. +1 −1  lib/Mojo/DOM/HTML.pm
  2. +15 −1 t/mojo/dom.t
View
2  lib/Mojo/DOM/HTML.pm
@@ -28,7 +28,7 @@ my $TOKEN_RE = qr/
(?:
<\?(.*?)\?> # Processing Instruction
|
- <!--(.*?)--> # Comment
+ <!--(.*?)--\s*> # Comment
|
<!\[CDATA\[(.*?)\]\]> # CDATA
|
View
16 t/mojo/dom.t
@@ -2,7 +2,7 @@ use Mojo::Base -strict;
use utf8;
-use Test::More tests => 789;
+use Test::More tests => 793;
use Mojo::DOM;
use Mojo::Util 'encode';
@@ -2132,3 +2132,17 @@ $dom = Mojo::DOM->new->charset('doesnotexist');
$dom->parse(qq{<html><div id="a">A</div></html>});
is $dom->at('#a'), undef, 'no result';
is "$dom", '', 'right result';
+
+# Comments
+$dom = Mojo::DOM->new(<<EOF);
+<!-- HTML5 -->
+<!-- bad idea -- HTML5 -->
+<!-- HTML4 -- >
+<!-- bad idea -- HTML4 -- >
+EOF
+my $tree = $dom->tree;
+is $tree->[1][1], ' HTML5 ', 'HTML5 comment';
+is $tree->[3][1], ' bad idea -- HTML5 ', 'HTML5 comment with --';
+is $tree->[5][1], ' HTML4 ', 'HTML4 comment';
+is $tree->[7][1], ' bad idea -- HTML4 ', 'HTML4 comment with --';
+
Something went wrong with that request. Please try again.