Changeset 48037 in webkit


Ignore:
Timestamp:
Sep 3, 2009 5:27:48 PM (15 years ago)
Author:
ap@apple.com
Message:

Reviewed by Darin Adler.

<rdar://problem/7180197>, https://bugs.webkit.org/show_bug.cgi?id=28822
REGRESSION(r31231): Creating document with current document's DOCTYPE causes crashes

Test: fast/dom/DOMImplementation/createDocument-with-used-doctype.html

  • dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocument): Even though we cannot raise an exception immediately out of fear of breaking Acid3, we shouldn't use a DocumentType node in two documents.
Location:
trunk
Files:
3 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r48036 r48037  
     12009-09-03  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7180197>, https://bugs.webkit.org/show_bug.cgi?id=28822
     6        REGRESSION(r31231): Creating document with current document's DOCTYPE causes crashes
     7
     8        This bug demonstrates itself with a crash later on, not in the current test.
     9
     10        * fast/dom/DOMImplementation/createDocument-with-used-doctype-expected.txt: Added.
     11        * fast/dom/DOMImplementation/createDocument-with-used-doctype.html: Added.
     12        * fast/dom/DOMImplementation/resources/createDocument-with-used-doctype-frame.html: Added.
     13
    1142009-09-03  Brady Eidson  <beidson@apple.com>
    215
  • trunk/WebCore/ChangeLog

    r48036 r48037  
     12009-09-03  Alexey Proskuryakov  <ap@apple.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        <rdar://problem/7180197>, https://bugs.webkit.org/show_bug.cgi?id=28822
     6        REGRESSION(r31231): Creating document with current document's DOCTYPE causes crashes
     7
     8        Test: fast/dom/DOMImplementation/createDocument-with-used-doctype.html
     9
     10        * dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocument): Even though we
     11        cannot raise an exception immediately out of fear of breaking Acid3, we shouldn't use a
     12        DocumentType node in two documents.
     13
    1142009-09-03  Brady Eidson  <beidson@apple.com>
    215
  • trunk/WebCore/dom/DOMImplementation.cpp

    r45255 r48037  
    224224    const String& qualifiedName, DocumentType* doctype, ExceptionCode& ec)
    225225{
    226     // WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was
    227     // created from a different implementation.
    228     bool shouldThrowWrongDocErr = false;
    229     if (doctype && doctype->document())
    230         shouldThrowWrongDocErr = true;
    231 
    232226    RefPtr<Document> doc;
    233227#if ENABLE(SVG)
     
    246240        doc = Document::create(0);
    247241
    248     // now get the interesting parts of the doctype
     242    RefPtr<Node> documentElement;
     243    if (!qualifiedName.isEmpty()) {
     244        documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec);
     245        if (ec)
     246            return 0;
     247    }
     248
     249    // WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was
     250    // created from a different implementation.
     251    // Hixie's interpretation of the DOM Core spec suggests we should prefer
     252    // other exceptions to WRONG_DOCUMENT_ERR (based on order mentioned in spec).
     253    if (doctype && doctype->document()) {
     254        ec = WRONG_DOCUMENT_ERR;
     255        return 0;
     256    }
     257
    249258    if (doctype)
    250259        doc->addChild(doctype);
    251 
    252     if (!qualifiedName.isEmpty()) {
    253         RefPtr<Node> documentElement = doc->createElementNS(namespaceURI, qualifiedName, ec);
    254         if (ec)
    255             return 0;
     260    if (documentElement)
    256261        doc->addChild(documentElement.release());
    257     }
    258 
    259     // Hixie's interpretation of the DOM Core spec suggests we should prefer
    260     // other exceptions to WRONG_DOCUMENT_ERR (based on order mentioned in spec)
    261     if (shouldThrowWrongDocErr) {
    262         ec = WRONG_DOCUMENT_ERR;
    263         return 0;
    264     }
    265262
    266263    return doc.release();
Note: See TracChangeset for help on using the changeset viewer.