Fix for 3752542, stack overflow that crashes Safari at www.dr.dk. This bug is a...
authorhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Aug 2004 21:54:45 +0000 (21:54 +0000)
committerhyatt <hyatt@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 5 Aug 2004 21:54:45 +0000 (21:54 +0000)
attempted to repair <caption> behavior to make it behave like Panther.  This fix was incorrect, and in addition
even our <caption> behavior on Panther was incorrect.

The patch that fixes this bug also makes <caption> handling work when <caption>s are contained inside a <td>, a <tr>,
a <th>, or various table section tags (<tbody>, <tfoot>, <thead>).  The <caption> is pulled out and inserted just before
the relevant ancestor table section.  This behavior matches other browsers.

        Reviewed by mjs

        * khtml/html/htmlparser.cpp:
        (KHTMLParser::insertNode):

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

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

index 4b0b072..8edf169 100644 (file)
@@ -1,3 +1,18 @@
+2004-08-05  David Hyatt  <hyatt@apple.com>
+
+       Fix for 3752542, stack overflow that crashes Safari at www.dr.dk.  This bug is a regression caused by a fix that
+       attempted to repair <caption> behavior to make it behave like Panther.  This fix was incorrect, and in addition
+       even our <caption> behavior on Panther was incorrect.
+
+       The patch that fixes this bug also makes <caption> handling work when <caption>s are contained inside a <td>, a <tr>,
+       a <th>, or various table section tags (<tbody>, <tfoot>, <thead>).  The <caption> is pulled out and inserted just before
+       the relevant ancestor table section.  This behavior matches other browsers.
+       
+        Reviewed by mjs
+
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::insertNode):
+
 2004-08-04  David Hyatt  <hyatt@apple.com>
 
        The top-level XSL sheet is now loaded and shows up in the activity window.  It is not yet parsed.
index 80d2f8c..bd8c28d 100644 (file)
@@ -506,6 +506,33 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
                 return false;
             return true;
         }
+        case ID_CAPTION: {
+            switch (current->id()) {
+                case ID_THEAD:
+                case ID_TBODY:
+                case ID_TFOOT:
+                case ID_TR:
+                case ID_TH:
+                case ID_TD: {
+                    NodeImpl* tsection = current;
+                    if (current->id() == ID_TR)
+                        tsection = current->parent();
+                    else if (current->id() == ID_TD || current->id() == ID_TH)
+                        tsection = current->parent()->parent();
+                    NodeImpl* table = tsection->parent();
+                    int exceptioncode = 0;
+                    table->insertBefore(n, tsection, exceptioncode);
+                    pushBlock(id, tagPriority[id]);
+                    setCurrent(n);
+                    inStrayTableContent++;
+                    blockStack->strayTableContent = true;
+                    return true;
+                }
+                default:
+                    break;
+            }
+            break;
+        }
         default:
             break;
         }
@@ -581,18 +608,13 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
         case ID_TFOOT:
         case ID_TBODY:
         case ID_TR:
-       case ID_TD:
             switch(id)
             {
             case ID_TABLE:
                 popBlock(ID_TABLE); // end the table
                 handled = true;      // ...and start a new one
                 break;
-           case ID_CAPTION:
-               popBlock(current->id());
-               handled = true;
-               break;
-            case ID_TEXT:
+           case ID_TEXT:
             {
                 TextImpl *t = static_cast<TextImpl *>(n);
                 if (t->containsOnlyWhitespace())