Fix for row 13 of the Acid2 test. Change HTML comment parsing in strict mode to...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2005 20:36:16 +0000 (20:36 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Apr 2005 20:36:16 +0000 (20:36 +0000)
checking for pairs of -- and only being willing to close the comment if every -- is paired up.

        * khtml/html/htmltokenizer.cpp:
        (khtml::HTMLTokenizer::parseComment):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9020 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog-2005-08-23
WebCore/khtml/html/htmltokenizer.cpp

index 9c63fe9d777b1de1a35ecb6616c9c932e5ca9555..b05b03b3ebd7f2aff119784a884e10a6f79b48ea 100644 (file)
@@ -1,3 +1,11 @@
+2005-04-15  David Hyatt  <hyatt@apple.com>
+
+       Fix for row 13 of the Acid2 test.  Change HTML comment parsing in strict mode to do proper SGML parsing,
+       checking for pairs of -- and only being willing to close the comment if every -- is paired up.
+       
+        * khtml/html/htmltokenizer.cpp:
+        (khtml::HTMLTokenizer::parseComment):
+
 2005-04-12  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Richard.
 2005-04-12  Maciej Stachowiak  <mjs@apple.com>
 
         Reviewed by Richard.
index cbb60a0be24cef5dc3f7ebb220468ecfa80829ea..2141d5681c1f51759c18c73fcd90d2a5a6f72bb6 100644 (file)
@@ -657,6 +657,9 @@ void HTMLTokenizer::scriptExecution( const QString& str, QString scriptURL,
 
 void HTMLTokenizer::parseComment(TokenizerString &src)
 {
 
 void HTMLTokenizer::parseComment(TokenizerString &src)
 {
+    bool strict = !parser->doc()->inCompatMode();
+    int delimiterCount = 0;
+    bool canClose = false;
     checkScriptBuffer(src.length());
     while ( !src.isEmpty() ) {
         scriptCode[ scriptCodeSize++ ] = *src;
     checkScriptBuffer(src.length());
     while ( !src.isEmpty() ) {
         scriptCode[ scriptCodeSize++ ] = *src;
@@ -664,19 +667,35 @@ void HTMLTokenizer::parseComment(TokenizerString &src)
         qDebug("comment is now: *%s*",
                QConstString((QChar*)src.current(), QMIN(16, src.length())).string().latin1());
 #endif
         qDebug("comment is now: *%s*",
                QConstString((QChar*)src.current(), QMIN(16, src.length())).string().latin1());
 #endif
-        if (src->unicode() == '>') {
+
+        if (strict) {
+            if (src->unicode() == '-') {
+                delimiterCount++;
+                if (delimiterCount == 2) {
+                    delimiterCount = 0;
+                    canClose = !canClose;
+                }
+            }
+            else
+                delimiterCount = 0;
+        }
+
+        if ((!strict || canClose) && src->unicode() == '>') {
             bool handleBrokenComments = brokenComments && !(script || style);
             int endCharsCount = 1; // start off with one for the '>' character
             bool handleBrokenComments = brokenComments && !(script || style);
             int endCharsCount = 1; // start off with one for the '>' character
-            if (scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' && scriptCode[scriptCodeSize-2] == '-') {
-                endCharsCount = 3;
-            }
-            else if (scriptCodeSize > 3 && scriptCode[scriptCodeSize-4] == '-' && scriptCode[scriptCodeSize-3] == '-' && 
-                scriptCode[scriptCodeSize-2] == '!') {
-                // Other browsers will accept --!> as a close comment, even though it's
-                // not technically valid.
-                endCharsCount = 4;
+            if (!strict) {
+                // In quirks mode just check for -->
+                if (scriptCodeSize > 2 && scriptCode[scriptCodeSize-3] == '-' && scriptCode[scriptCodeSize-2] == '-') {
+                    endCharsCount = 3;
+                }
+                else if (scriptCodeSize > 3 && scriptCode[scriptCodeSize-4] == '-' && scriptCode[scriptCodeSize-3] == '-' && 
+                    scriptCode[scriptCodeSize-2] == '!') {
+                    // Other browsers will accept --!> as a close comment, even though it's
+                    // not technically valid.
+                    endCharsCount = 4;
+                }
             }
             }
-            if (handleBrokenComments || endCharsCount > 1) {
+            if (canClose || handleBrokenComments || endCharsCount > 1) {
                 ++src;
                 if (!( script || xmp || textarea || style)) {
                     if (includesCommentsInDOM) {
                 ++src;
                 if (!( script || xmp || textarea || style)) {
                     if (includesCommentsInDOM) {