Changeset 19949 in webkit


Ignore:
Timestamp:
Mar 2, 2007 3:02:49 PM (17 years ago)
Author:
justing
Message:

LayoutTests:

Reviewed by harrison


<rdar://problem/4545040>
innerHTML does not HTML-escape text nodes inside PRE elements
<rdar://problem/5027857>
Pasting into Mail from Safari's view-source window renders the HTML

  • editing/pasteboard/5027857-expected.checksum: Added.
  • editing/pasteboard/5027857-expected.png: Added.
  • editing/pasteboard/5027857-expected.txt: Added.
  • editing/pasteboard/5027857.html: Added.

WebCore:

Reviewed by harrison

<rdar://problem/4545040>
innerHTML does not HTML-escape text nodes inside PRE elements
<rdar://problem/5027857>
Pasting into Mail from Safari's view-source window renders the HTML

  • editing/HTMLInterchange.cpp: (WebCore::convertHTMLTextToInterchangeFormat): Send this function the node that the text comes from as a parameter. It shouldn't convert '\n's to spaces/nbsps if the text is coming from text where newlines are preserved.
  • editing/HTMLInterchange.h:
  • editing/markup.cpp: (WebCore::startMarkup): Escape text inside the children of PREs.
Location:
trunk
Files:
4 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19944 r19949  
     12007-03-02  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4       
     5        <rdar://problem/4545040>
     6        innerHTML does not HTML-escape text nodes inside PRE elements
     7        <rdar://problem/5027857>
     8        Pasting into Mail from Safari's view-source window renders the HTML
     9
     10        * editing/pasteboard/5027857-expected.checksum: Added.
     11        * editing/pasteboard/5027857-expected.png: Added.
     12        * editing/pasteboard/5027857-expected.txt: Added.
     13        * editing/pasteboard/5027857.html: Added.
     14
    1152007-03-02  Justin Garcia  <justin.garcia@apple.com>
    216
  • trunk/WebCore/ChangeLog

    r19948 r19949  
     12007-03-02  Justin Garcia  <justin.garcia@apple.com>
     2
     3        Reviewed by harrison
     4
     5        <rdar://problem/4545040>
     6        innerHTML does not HTML-escape text nodes inside PRE elements
     7        <rdar://problem/5027857>
     8        Pasting into Mail from Safari's view-source window renders the HTML
     9
     10        * editing/HTMLInterchange.cpp:
     11        (WebCore::convertHTMLTextToInterchangeFormat): Send this function
     12        the node that the text comes from as a parameter.  It shouldn't convert
     13        '\n's to spaces/nbsps if the text is coming from text where newlines are
     14        preserved.
     15        * editing/HTMLInterchange.h:
     16        * editing/markup.cpp:
     17        (WebCore::startMarkup): Escape text inside the children of PREs.
     18
    1192007-03-02  Sam Weinig  <sam@webkit.org>
    220
  • trunk/WebCore/editing/HTMLInterchange.cpp

    r18712 r19949  
    2929#include "CharacterNames.h"
    3030#include "Document.h"
     31#include "Text.h"
    3132#include "TextIterator.h"
    3233
     
    5051} // end anonymous namespace
    5152
    52 // FIXME: Can't really do this work without taking whitespace mode into account.
    53 // This means that eventually this function needs to be eliminated or at least have
    54 // its parameters changed because it can't do its work on the string without knowing
    55 // what parts are in what whitespace mode.
    56 DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString &in)
     53DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString& in, const Text* node)
    5754{
     55    // Assume all the text comes from node.
     56    if (node->renderer() && node->renderer()->style()->preserveNewline())
     57        return in;
     58       
    5859    DeprecatedString s;
    5960
  • trunk/WebCore/editing/HTMLInterchange.h

    r15286 r19949  
    3030
    3131class DeprecatedString;
     32class Text;
    3233
    3334#define AppleInterchangeNewline   "Apple-interchange-newline"
     
    3940enum EAnnotateForInterchange { DoNotAnnotateForInterchange, AnnotateForInterchange };
    4041
    41 DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&);
     42DeprecatedString convertHTMLTextToInterchangeFormat(const DeprecatedString&, const Text*);
    4243
    4344}
  • trunk/WebCore/editing/markup.cpp

    r19926 r19949  
    161161            if (Node* parent = node->parentNode()) {
    162162                if (parent->hasTagName(listingTag)
    163                         || parent->hasTagName(preTag)
    164163                        || parent->hasTagName(scriptTag)
    165164                        || parent->hasTagName(styleTag)
     
    169168            }
    170169            bool useRenderedText = annotate && !enclosingNodeWithTag(const_cast<Node*>(node), selectTag);
    171            
    172170            DeprecatedString markup = useRenderedText ? escapeTextForMarkup(renderedText(node, range), false) : escapeTextForMarkup(stringValueForRange(node, range).deprecatedString(), false);
    173171            if (defaultStyle) {
     
    189187                }           
    190188            }
    191             return annotate ? convertHTMLTextToInterchangeFormat(markup) : markup;
     189            return annotate ? convertHTMLTextToInterchangeFormat(markup, static_cast<const Text*>(node)) : markup;
    192190        }
    193191        case Node::COMMENT_NODE:
Note: See TracChangeset for help on using the changeset viewer.