Changeset 33577

Show
Ignore:
Timestamp:
2008-05-19 12:12:55 (6 months ago)
Author:
ap@webkit.org
Message:

Reviewed by Darin.

https://bugs.webkit.org/show_bug.cgi?id=18421
<rdar://problem/5857369> XMLHttpRequest does not properly encode & and < in outgoing messages

Test: http/tests/xmlhttprequest/serialize-document.html

  • bindings/js/JSXMLHttpRequestCustom.cpp: (WebCore::JSXMLHttpRequest::send): Use createMarkup() instead of Document::toString().
  • dom/Attr.cpp:
  • dom/Attr.h:
  • dom/Document.cpp:
  • dom/Document.h:
  • dom/DocumentFragment.cpp:
  • dom/DocumentFragment.h:
  • dom/Element.cpp:
  • dom/Element.h:
  • dom/Entity.cpp:
  • dom/Entity.h:
  • dom/EntityReference.cpp:
  • dom/EntityReference.h:
  • dom/Node.h:
  • dom/Text.cpp:
  • dom/Text.h:
  • html/HTMLElement.cpp:
  • html/HTMLElement.h: Removed most Node::toString() methods, which were massively wrong, and only used for XMLHttpRequest::send(). The remanining ones are still used in markup.cpp, but should probably be folded into it for consistency.
Location:
trunk
Files:
2 added
20 modified

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r33567 r33577  
     12008-05-19  Alexey Proskuryakov  <ap@webkit.org> 
     2 
     3        Reviewed by Darin. 
     4 
     5        https://bugs.webkit.org/show_bug.cgi?id=18421 
     6        <rdar://problem/5857369> XMLHttpRequest does not properly encode & and < in outgoing messages 
     7 
     8        * http/tests/xmlhttprequest/serialize-document-expected.txt: Added. 
     9        * http/tests/xmlhttprequest/serialize-document.html: Added. 
     10 
    1112008-05-18  Darin Adler  <darin@apple.com> 
    212 
  • trunk/WebCore/ChangeLog

    r33576 r33577  
     12008-05-19  Alexey Proskuryakov  <ap@webkit.org> 
     2 
     3        Reviewed by Darin. 
     4 
     5        https://bugs.webkit.org/show_bug.cgi?id=18421 
     6        <rdar://problem/5857369> XMLHttpRequest does not properly encode & and < in outgoing messages 
     7 
     8        Test: http/tests/xmlhttprequest/serialize-document.html 
     9 
     10        * bindings/js/JSXMLHttpRequestCustom.cpp: 
     11        (WebCore::JSXMLHttpRequest::send): Use createMarkup() instead of Document::toString(). 
     12 
     13        * dom/Attr.cpp: 
     14        * dom/Attr.h: 
     15        * dom/Document.cpp: 
     16        * dom/Document.h: 
     17        * dom/DocumentFragment.cpp: 
     18        * dom/DocumentFragment.h: 
     19        * dom/Element.cpp: 
     20        * dom/Element.h: 
     21        * dom/Entity.cpp: 
     22        * dom/Entity.h: 
     23        * dom/EntityReference.cpp: 
     24        * dom/EntityReference.h: 
     25        * dom/Node.h: 
     26        * dom/Text.cpp: 
     27        * dom/Text.h: 
     28        * html/HTMLElement.cpp: 
     29        * html/HTMLElement.h: 
     30        Removed most Node::toString() methods, which were massively wrong, and only used for 
     31        XMLHttpRequest::send(). The remanining ones are still used in markup.cpp, but should probably 
     32        be folded into it for consistency. 
     33 
    1342008-05-19  Anders Carlsson  <andersca@apple.com> 
    235 
  • trunk/WebCore/bindings/js/JSXMLHttpRequestCustom.cpp

    r33038 r33577  
    4141#include "JSEvent.h" 
    4242#include "kjs_events.h" 
     43#include "markup.h" 
    4344 
    4445using namespace KJS; 
     
    167168    if (args.size() >= 1) { 
    168169        if (args[0]->toObject(exec)->inherits(&JSDocument::s_info)) 
    169             body = static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl())->toString(); 
     170            body = createMarkup(static_cast<Document*>(static_cast<JSDocument*>(args[0]->toObject(exec))->impl())); 
    170171        else { 
    171172            // converting certain values (like null) to object can set an exception 
  • trunk/WebCore/dom/Attr.cpp

    r33442 r33577  
    169169} 
    170170 
    171 String Attr::toString() const 
    172 { 
    173     String result; 
    174  
    175     result += nodeName(); 
    176  
    177     // FIXME: substitute entities for any instances of " or ' -- 
    178     // maybe easier to just use text value and ignore existing 
    179     // entity refs? 
    180  
    181     if (firstChild() != NULL) { 
    182         result += "=\""; 
    183  
    184         for (Node *child = firstChild(); child != NULL; child = child->nextSibling()) { 
    185             result += child->toString(); 
    186         } 
    187          
    188         result += "\""; 
    189     } 
    190  
    191     return result; 
    192171} 
    193  
    194 } 
  • trunk/WebCore/dom/Attr.h

    r30633 r33577  
    7979 
    8080    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0); 
    81     virtual String toString() const; 
    8281 
    8382    Attribute* attr() const { return m_attribute.get(); } 
  • trunk/WebCore/dom/Document.cpp

    r33538 r33577  
    30773077} 
    30783078 
    3079 String Document::toString() const 
    3080 { 
    3081     String result; 
    3082  
    3083     for (Node *child = firstChild(); child != NULL; child = child->nextSibling()) { 
    3084         result += child->toString(); 
    3085     } 
    3086  
    3087     return result; 
    3088 } 
    3089  
    30903079// Support for Javascript execCommand, and related methods 
    30913080 
  • trunk/WebCore/dom/Document.h

    r33538 r33577  
    637637    HTMLHeadElement* head(); 
    638638 
    639     String toString() const; 
    640      
    641639    bool execCommand(const String& command, bool userInterface = false, const String& value = String()); 
    642640    bool queryCommandEnabled(const String& command); 
  • trunk/WebCore/dom/DocumentFragment.cpp

    r25754 r33577  
    5959} 
    6060 
    61 String DocumentFragment::toString() const 
    62 { 
    63     String result; 
    64     for (Node *child = firstChild(); child != NULL; child = child->nextSibling()) 
    65         result += child->toString(); 
    66     return result; 
    67 } 
    68  
    6961PassRefPtr<Node> DocumentFragment::cloneNode(bool deep) 
    7062{ 
  • trunk/WebCore/dom/DocumentFragment.h

    r25754 r33577  
    4040    virtual PassRefPtr<Node> cloneNode(bool deep); 
    4141    virtual bool childTypeAllowed(NodeType); 
    42     virtual String toString() const; 
    4342}; 
    4443 
  • trunk/WebCore/dom/Element.cpp

    r33510 r33577  
    998998} 
    999999 
    1000 String Element::toString() const 
    1001 { 
    1002     String result = openTagStartToString(); 
    1003  
    1004     if (hasChildNodes()) { 
    1005         result += ">"; 
    1006  
    1007         for (Node *child = firstChild(); child != NULL; child = child->nextSibling()) { 
    1008             result += child->toString(); 
    1009         } 
    1010  
    1011         result += "</"; 
    1012         result += nodeName(); 
    1013         result += ">"; 
    1014     } else { 
    1015         result += " />"; 
    1016     } 
    1017  
    1018     return result; 
    1019 } 
    1020  
    10211000void Element::updateId(const AtomicString& oldId, const AtomicString& newId) 
    10221001{ 
  • trunk/WebCore/dom/Element.h

    r33510 r33577  
    157157    virtual void accessKeyAction(bool sendToAnyEvent) { } 
    158158 
    159     virtual String toString() const; 
    160  
    161159    virtual bool isURLAttribute(Attribute*) const; 
    162160    virtual const QualifiedName& imageSourceAttributeName() const; 
  • trunk/WebCore/dom/Entity.cpp

    r25754 r33577  
    7777} 
    7878 
    79 String Entity::toString() const 
    80 { 
    81     String result = "<!ENTITY' "; 
    82  
    83     if (!m_name.isEmpty()) { 
    84         result += " "; 
    85         result += m_name; 
    86     } 
    87  
    88     if (!m_publicId.isEmpty()) { 
    89         result += " PUBLIC \""; 
    90         result += m_publicId; 
    91         result += "\" \""; 
    92         result += m_systemId; 
    93         result += "\""; 
    94     } else if (!m_systemId.isEmpty()) { 
    95         result += " SYSTEM \""; 
    96         result += m_systemId; 
    97         result += "\""; 
    98     } 
    99  
    100     if (!m_notationName.isEmpty()) { 
    101         result += " NDATA "; 
    102         result += m_notationName; 
    103     } 
    104  
    105     result += ">"; 
    106  
    107     return result; 
    108 } 
    109  
    11079} // namespace 
  • trunk/WebCore/dom/Entity.h

    r25754 r33577  
    4545    virtual PassRefPtr<Node> cloneNode(bool deep); 
    4646    virtual bool childTypeAllowed(NodeType); 
    47     virtual String toString() const; 
    4847 
    4948private: 
  • trunk/WebCore/dom/EntityReference.cpp

    r25754 r33577  
    7373} 
    7474 
    75 String EntityReference::toString() const 
    76 { 
    77     String result = "&"; 
    78     result += m_entityName; 
    79     result += ";"; 
    80  
    81     return result; 
    82 } 
    83  
    8475} // namespace 
  • trunk/WebCore/dom/EntityReference.h

    r25754 r33577  
    3939    virtual PassRefPtr<Node> cloneNode(bool deep); 
    4040    virtual bool childTypeAllowed(NodeType); 
    41     virtual String toString() const; 
    4241 
    4342private: 
  • trunk/WebCore/dom/Node.h

    r32664 r33577  
    439439    virtual void childrenChanged(bool changedByParser = false, Node* beforeChange = 0, Node* afterChange = 0, int childCountDelta = 0) {}; 
    440440 
    441     virtual String toString() const = 0; 
    442  
    443441#ifndef NDEBUG 
    444442    virtual void formatForDebugger(char* buffer, unsigned length) const; 
  • trunk/WebCore/dom/Text.cpp

    r31075 r33577  
    274274} 
    275275 
    276 String Text::toString() const 
    277 { 
    278     return nodeValue(); 
    279 } 
    280  
    281276PassRefPtr<Text> Text::createWithLengthLimit(Document* doc, const String& text, unsigned& charsLeft, unsigned maxChars) 
    282277{ 
  • trunk/WebCore/dom/Text.h

    r30097 r33577  
    5959    virtual bool childTypeAllowed(NodeType); 
    6060 
    61     virtual String toString() const; 
    62      
    6361    static PassRefPtr<Text> createWithLengthLimit(Document*, const String&, unsigned& charsLeft, unsigned maxChars = cTextNodeLengthLimit); 
    6462 
  • trunk/WebCore/html/HTMLElement.cpp

    r33524 r33577  
    640640} 
    641641 
    642 String HTMLElement::toString() const 
    643 { 
    644     if (!hasChildNodes() && document()->isHTMLDocument()) { 
    645         String result = openTagStartToString(); 
    646         result += ">"; 
    647  
    648         if (endTagRequirement() == TagStatusRequired) { 
    649             result += "</"; 
    650             result += nodeName(); 
    651             result += ">"; 
    652         } 
    653  
    654         return result; 
    655     } 
    656  
    657     return Element::toString(); 
    658 } 
    659  
    660642String HTMLElement::id() const 
    661643{ 
  • trunk/WebCore/html/HTMLElement.h

    r32664 r33577  
    8484    virtual bool isGenericFormElement() const { return false; } 
    8585 
    86     virtual String toString() const; 
    87  
    8886    virtual HTMLTagStatus endTagRequirement() const; 
    8987    virtual int tagPriority() const;