WebCore: Space should be allowed between -- and > in comment end
authorjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jun 2010 14:41:13 +0000 (14:41 +0000)
committerjchaffraix@webkit.org <jchaffraix@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 7 Jun 2010 14:41:13 +0000 (14:41 +0000)
commit71cef7e657a25850b2c84bd7fb8be25aefd3f3d9
treeca36400d86fcb1004017f1de0b996448a6ae29e6
parent4888a397058016b21a3f7007cc431e0e88f4a9a3
WebCore: Space should be allowed between -- and > in comment end
https://bugs.webkit.org/show_bug.cgi?id=21945

Reviewed by Alexey Proskuryakov.

Implemented the HTML comment parsing algorithm so that we match HTML5 and
FF when parsing comments. Missing from this patch is
the parser errors, which will be added in a follow up patch.

Added tests cases for broken comments.

Tests: fast/parser/broken-comment-1.html
       fast/parser/broken-comment-2.html
       fast/parser/broken-comment-3.html
       fast/parser/broken-comment-4.html
       fast/parser/broken-comment-5.html
       fast/parser/broken-comment-6.html
       fast/parser/broken-comment-in-head-1.html
       fast/parser/broken-comment-in-head-2.html
       fast/parser/broken-comment-in-head-3.html
       fast/parser/broken-comment-in-head-4.html
       fast/parser/broken-comment-in-head-5.html

* html/HTMLTokenizer.cpp:
(WebCore::HTMLTokenizer::parseComment): Now we use a state machine
that matches the HTML5 specification.
(WebCore::HTMLTokenizer::emitCommentToken): This emits the comment token
and keep some of the original behavior as parseComment is called in wrong
context (inside a <title> for example). Added a more explicit comment about
this.
(WebCore::HTMLTokenizer::parseTag): Remove the handling of <!--> in quirks mode.
HTML5 specifies that we should accept this in strict mode too.
* html/HTMLTokenizer.h:
(WebCore::HTMLTokenizer::): Added a new enum for the comment parsing state.

LayoutTests: Tests for:
Space should be allowed between -- and > in comment end
https://bugs.webkit.org/show_bug.cgi?id=21945

Reviewed by Alexey Proskuryakov.

* fast/css/word-space-extra.html: Tweaked the comment as -- > is now
a valid comment end.

* fast/parser/broken-comment-1-expected.txt: Added.
* fast/parser/broken-comment-1.html: Added.
* fast/parser/broken-comment-2-expected.txt: Added.
* fast/parser/broken-comment-2.html: Added.
* fast/parser/broken-comment-3-expected.txt: Added.
* fast/parser/broken-comment-3.html: Added.
* fast/parser/broken-comment-4-expected.txt: Added.
* fast/parser/broken-comment-4.html: Added.
* fast/parser/broken-comment-5-expected.txt: Added.
* fast/parser/broken-comment-5.html: Added.
* fast/parser/broken-comment-6-expected.txt: Added.
* fast/parser/broken-comment-6.html: Added.
Those test checks that broken comments in body are correctly parsed.
* fast/parser/broken-comment-in-head-1-expected.txt: Added.
* fast/parser/broken-comment-in-head-1.html: Added.
* fast/parser/broken-comment-in-head-2-expected.txt: Added.
* fast/parser/broken-comment-in-head-2.html: Added.
* fast/parser/broken-comment-in-head-3-expected.txt: Added.
* fast/parser/broken-comment-in-head-3.html: Added.
* fast/parser/broken-comment-in-head-4-expected.txt: Added.
* fast/parser/broken-comment-in-head-4.html: Added.
* fast/parser/broken-comment-in-head-5-expected.txt: Added.
* fast/parser/broken-comment-in-head-5.html: Added.
Those test checks that broken comments in head are correctly parsed.

* fast/parser/broken-comments-vs-parsing-mode.html: Needed to wrap the broken comment
in a title as we match FF here and would not recover from it.

* fast/parser/comments-expected.txt:
* fast/parser/comments.html:
Added more tests for comment parsing. Made sure that we close empty comments
<!--> and <!---> as is specified in HTML5.

* html5lib/runner-expected.txt: Removed the test that we now pass.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@60781 268f45cc-cd09-0410-ab3c-d52691b4dbfc
31 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/word-space-extra.html
LayoutTests/fast/parser/broken-comment-1-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-1.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-2-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-2.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-3-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-3.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-4-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-4.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-5-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-5.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-6-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-6.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-1-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-1.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-2-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-2.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-3-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-3.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-4-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-4.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-5-expected.txt [new file with mode: 0644]
LayoutTests/fast/parser/broken-comment-in-head-5.html [new file with mode: 0644]
LayoutTests/fast/parser/broken-comments-vs-parsing-mode.html
LayoutTests/fast/parser/comments-expected.txt
LayoutTests/fast/parser/comments.html
LayoutTests/html5lib/runner-expected.txt
WebCore/ChangeLog
WebCore/html/HTMLTokenizer.cpp
WebCore/html/HTMLTokenizer.h