Changeset 18085 in webkit for trunk/WebCore/xml/XMLSerializer.cpp


Ignore:
Timestamp:
Dec 8, 2006, 1:12:48 PM (18 years ago)
Author:
weinig
Message:

LayoutTests:

Reviewed by Geoff.

Testcases for http://bugs.webkit.org/show_bug.cgi?id=11777
Crash when using XMLSerializer.serializeToString() on
documentless, DocumentType nodes.

  • fast/dom/XMLSerializer-doctype-expected.txt: Added.
  • fast/dom/XMLSerializer-doctype.html: Added.
  • fast/dom/XMLSerializer-doctype2-expected.txt: Added.
  • fast/dom/XMLSerializer-doctype2.html: Added.

WebCore:

Reviewed by Geoff.

Fix for http://bugs.webkit.org/show_bug.cgi?id=11777
Crash when using XMLSerializer.serializeToString() on
documentless, DocumentType nodes.

Test: fast/dom/XMLSerializer-doctype.html
Test: fast/dom/XMLSerializer-doctype2.html

  • dom/DOMImplementation.cpp: (WebCore::DOMImplementation::createDocument): set the document of the DocumentType node to the new document.
  • xml/XMLSerializer.cpp: Cleanup. (WebCore::XMLSerializer::serializeToString): now throws an exception for documentless nodes.
  • xml/XMLSerializer.h: cleanup
  • xml/XMLSerializer.idl: add exception
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/xml/XMLSerializer.cpp

    r16245 r18085  
    22 *  This file is part of the KDE libraries
    33 *  Copyright (C) 2003, 2006 Apple Computer, Inc.
     4 *  Copyright (C) 2006 Samuel Weinig ([email protected])
    45 *
    56 *  This library is free software; you can redistribute it and/or
     
    2223
    2324#include "Document.h"
     25#include "ExceptionCode.h"
    2426#include "markup.h"
    2527
    2628namespace WebCore {
    2729
    28 String XMLSerializer::serializeToString(Node* node)
     30String XMLSerializer::serializeToString(Node* node, ExceptionCode& ec)
    2931{
    3032    if (!node)
    3133        return String();
    32    
     34
     35    if (!node->document()) {
     36        // Due to the fact that DocumentType nodes are created by the DOMImplementation
     37        // and not the Document, it is possible for it to not have a Document associated
     38        // with it.  It should be the only type of node where this is possible.
     39        ASSERT(node->nodeType() == Node::DOCUMENT_TYPE_NODE);
     40
     41        ec = INVALID_ACCESS_ERR;
     42        return String();
     43    }
     44
    3345    return createMarkup(node);
    3446}
    3547
    36 }
     48} // namespace WebCore
Note: See TracChangeset for help on using the changeset viewer.