[webkit-changes] cvs commit: WebCore/khtml/xml dom_docimpl.cpp

Anders andersca at opensource.apple.com
Tue Jan 3 02:05:45 PST 2006


andersca    06/01/03 02:05:45

  Modified:    .        ChangeLog
               khtml/ecma kjs_dom.cpp
               khtml/xml dom_docimpl.cpp
  Log:
  2006-01-03  Anders Carlsson  <andersca at mac.com>
  
          Reviewed by Maciej.
  
          - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5378
          createDocument fails with DOM Exception 5 when passed empty qname
  
          * khtml/ecma/kjs_dom.cpp:
          (KJS::DOMDOMImplementationProtoFunc::callAsFunction):
          When passing null to createDocument, pass a null DOMString, and not
          a DOMString containing the text "null".
  
          * khtml/xml/dom_docimpl.cpp:
          (DOMImplementationImpl::createDocument):
          Only validate the qualifiedName if it's not null or empty. Also, do not
          create the document element if the qualifiedName is null or empty.
  
  Revision  Changes    Path
  1.77      +17 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.76
  retrieving revision 1.77
  diff -u -r1.76 -r1.77
  --- ChangeLog	3 Jan 2006 09:19:02 -0000	1.76
  +++ ChangeLog	3 Jan 2006 10:05:43 -0000	1.77
  @@ -1,3 +1,20 @@
  +2006-01-03  Anders Carlsson  <andersca at mac.com>
  +
  +        Reviewed by Maciej.
  +
  +        - fix http://bugzilla.opendarwin.org/show_bug.cgi?id=5378
  +        createDocument fails with DOM Exception 5 when passed empty qname
  +        
  +        * khtml/ecma/kjs_dom.cpp:
  +        (KJS::DOMDOMImplementationProtoFunc::callAsFunction):
  +        When passing null to createDocument, pass a null DOMString, and not
  +        a DOMString containing the text "null".
  +        
  +        * khtml/xml/dom_docimpl.cpp:
  +        (DOMImplementationImpl::createDocument):
  +        Only validate the qualifiedName if it's not null or empty. Also, do not
  +        create the document element if the qualifiedName is null or empty.
  +
   2006-01-03  Eric Seidel  <eseidel at apple.com>
   
           Reviewed by darin.
  
  
  
  1.123     +2 -2      WebCore/khtml/ecma/kjs_dom.cpp
  
  Index: kjs_dom.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/ecma/kjs_dom.cpp,v
  retrieving revision 1.122
  retrieving revision 1.123
  diff -u -r1.122 -r1.123
  --- kjs_dom.cpp	23 Dec 2005 18:44:08 -0000	1.122
  +++ kjs_dom.cpp	3 Jan 2006 10:05:43 -0000	1.123
  @@ -1346,8 +1346,8 @@
       return getDOMNode(exec, implementation.createDocumentType(args[0]->toString(exec).domString(),
           args[1]->toString(exec).domString(), args[2]->toString(exec).domString(), exception));
     case DOMDOMImplementation::CreateDocument: // DOM2
  -    return getDOMNode(exec, implementation.createDocument(args[0]->toString(exec).domString(),
  -        args[1]->toString(exec).domString(), toDocumentType(args[2]), exception));
  +    return getDOMNode(exec, implementation.createDocument(valueToStringWithNullCheck(exec, args[0]),
  +        valueToStringWithNullCheck(exec, args[1]), toDocumentType(args[2]), exception));
     case DOMDOMImplementation::CreateCSSStyleSheet: // DOM2
       return getDOMStyleSheet(exec, implementation.createCSSStyleSheet(args[0]->toString(exec).domString(), args[1]->toString(exec).domString(), exception));
     case DOMDOMImplementation::CreateHTMLDocument: // DOM2-HTML
  
  
  
  1.297     +32 -34    WebCore/khtml/xml/dom_docimpl.cpp
  
  Index: dom_docimpl.cpp
  ===================================================================
  RCS file: /cvs/root/WebCore/khtml/xml/dom_docimpl.cpp,v
  retrieving revision 1.296
  retrieving revision 1.297
  diff -u -r1.296 -r1.297
  --- dom_docimpl.cpp	3 Jan 2006 08:12:29 -0000	1.296
  +++ dom_docimpl.cpp	3 Jan 2006 10:05:44 -0000	1.297
  @@ -263,41 +263,37 @@
   {
       exceptioncode = 0;
   
  -    // Not mentioned in spec: throw NAMESPACE_ERR if no qualifiedName supplied
  -    if (qualifiedName.isNull()) {
  -        exceptioncode = DOMException::NAMESPACE_ERR;
  -        return 0;
  -    }
  -
  -    // INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
  -    DOMString prefix, localName;
  -    if (!DocumentImpl::parseQualifiedName(qualifiedName, prefix, localName)) {
  -        exceptioncode = DOMException::INVALID_CHARACTER_ERR;
  -        return 0;
  -    }
  +    if (!qualifiedName.isEmpty()) {
  +        // INVALID_CHARACTER_ERR: Raised if the specified qualified name contains an illegal character.
  +        DOMString prefix, localName;
  +        if (!DocumentImpl::parseQualifiedName(qualifiedName, prefix, localName)) {
  +            exceptioncode = DOMException::INVALID_CHARACTER_ERR;
  +            return 0;
  +        }
   
  -    // NAMESPACE_ERR:
  -    // - Raised if the qualifiedName is malformed,
  -    // - if the qualifiedName has a prefix and the namespaceURI is null, or
  -    // - if the qualifiedName has a prefix that is "xml" and the namespaceURI is different
  -    //   from "http://www.w3.org/XML/1998/namespace" [Namespaces].
  -    int colonpos = -1;
  -    uint i;
  -    DOMStringImpl *qname = qualifiedName.impl();
  -    for (i = 0; i < qname->l && colonpos < 0; i++) {
  -        if ((*qname)[i] == ':')
  -            colonpos = i;
  -    }
  -
  -    if (qualifiedNameIsMalformed(qualifiedName) ||
  -        (colonpos >= 0 && namespaceURI.isNull()) ||
  -        (colonpos == 3 && qualifiedName[0] == 'x' && qualifiedName[1] == 'm' && qualifiedName[2] == 'l' &&
  -         namespaceURI != "http://www.w3.org/XML/1998/namespace")) {
  +        // NAMESPACE_ERR:
  +        // - Raised if the qualifiedName is malformed,
  +        // - if the qualifiedName has a prefix and the namespaceURI is null, or
  +        // - if the qualifiedName has a prefix that is "xml" and the namespaceURI is different
  +        //   from "http://www.w3.org/XML/1998/namespace" [Namespaces].
  +        int colonpos = -1;
  +        uint i;
  +        DOMStringImpl *qname = qualifiedName.impl();
  +        for (i = 0; i < qname->l && colonpos < 0; i++) {
  +            if ((*qname)[i] == ':')
  +                colonpos = i;
  +        }
  +    
  +        if (qualifiedNameIsMalformed(qualifiedName) ||
  +            (colonpos >= 0 && namespaceURI.isNull()) ||
  +            (colonpos == 3 && qualifiedName[0] == 'x' && qualifiedName[1] == 'm' && qualifiedName[2] == 'l' &&
  +             namespaceURI != "http://www.w3.org/XML/1998/namespace")) {
   
  -        exceptioncode = DOMException::NAMESPACE_ERR;
  -        return 0;
  +            exceptioncode = DOMException::NAMESPACE_ERR;
  +            return 0;
  +        }
       }
  -
  +    
       // WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different document or was
       // created from a different implementation.
       if (doctype && (doctype->getDocument() || doctype->implementation() != this)) {
  @@ -312,8 +308,10 @@
       if (doctype)
           doc->setDocType(new DocumentTypeImpl(doc, *doctype));
   
  -    ElementImpl *rootElement = doc->createElementNS(namespaceURI, qualifiedName, exceptioncode);
  -    doc->addChild(rootElement);
  +    if (!qualifiedName.isEmpty()) {
  +        ElementImpl *rootElement = doc->createElementNS(namespaceURI, qualifiedName, exceptioncode);
  +        doc->addChild(rootElement);
  +    }
       
       return doc;
   }
  
  
  



More information about the webkit-changes mailing list