Title: [139111] trunk
Revision
139111
Author
[email protected]
Date
2013-01-08 14:11:02 -0800 (Tue, 08 Jan 2013)

Log Message

Copy-paste preserves <embed> tags containing active content.
https://bugs.webkit.org/show_bug.cgi?id=77625

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: editing/pasteboard/paste-noplugin.html

* dom/FragmentScriptingPermission.h:
(WebCore::scriptingContentIsAllowed):
(WebCore::pluginContentIsAllowed):
Add new permission to restrict plugin pasting.  Add inline functions to check
the implications of each permission rather than having a list of raw comparisions
sprinkled throughout the code.

* editing/markup.cpp:
(WebCore::createFragmentFromMarkup):
Revert back to unsafe plugin pasting regardless of caller's intentions when
the settings allow it.

* dom/Element.cpp:
(WebCore::Element::parserSetAttributes):
* html/parser/HTMLConstructionSite.cpp:
(WebCore::HTMLConstructionSite::insertScriptElement):
* xml/parser/XMLDocumentParserLibxml2.cpp:
(WebCore::XMLDocumentParser::endElementNs):
* xml/parser/XMLDocumentParserQt.cpp:
(WebCore::XMLDocumentParser::parseEndElement):
Use new inline functions to check implications of permissions rather than raw
comparisions.

* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::processStartTagForInBody):
(WebCore::HTMLTreeBuilder::processEndTag):
Check if plugin pasting is allowed before inserting applet/embed/oject elements.

* page/Settings.in:
Declaration of new unsafePluginPastingEnabled setting.

* platform/mac/PasteboardMac.mm:
(WebCore::Pasteboard::documentFragment):
* platform/blackberry/PasteboardBlackBerry.cpp:
(WebCore::Pasteboard::documentFragment):
* platform/chromium/DragDataChromium.cpp:
(WebCore::DragData::asFragment):
* platform/chromium/PasteboardChromium.cpp:
(WebCore::Pasteboard::documentFragment):
* platform/gtk/PasteboardGtk.cpp:
(WebCore::Pasteboard::documentFragment):
* platform/qt/DragDataQt.cpp:
(WebCore::DragData::asFragment):
* platform/qt/PasteboardQt.cpp:
(WebCore::Pasteboard::documentFragment):
* platform/win/ClipboardUtilitiesWin.cpp:
(WebCore::fragmentFromCFHTML):
(WebCore::fragmentFromHTML):
* platform/wx/PasteboardWx.cpp:
(WebCore::Pasteboard::documentFragment):
Pass DisallowScriptingAndPluginContent enum value.

Source/WebKit/chromium:

Adds chromium API to new unsafePluginPastingEnabled setting.

* public/WebSettings.h:
* src/WebSettingsImpl.cpp:
(WebKit::WebSettingsImpl::setUnsafePluginPastingEnabled):
(WebKit):
* src/WebSettingsImpl.h:
(WebSettingsImpl):

LayoutTests:

* editing/pasteboard/paste-noplugin-expected.txt: Added.
* editing/pasteboard/paste-noplugin.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (139110 => 139111)


--- trunk/LayoutTests/ChangeLog	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/LayoutTests/ChangeLog	2013-01-08 22:11:02 UTC (rev 139111)
@@ -1,3 +1,13 @@
+2013-01-08  Tom Sepez  <[email protected]>
+
+        Copy-paste preserves <embed> tags containing active content.
+        https://bugs.webkit.org/show_bug.cgi?id=77625
+
+        Reviewed by Ryosuke Niwa.
+
+        * editing/pasteboard/paste-noplugin-expected.txt: Added.
+        * editing/pasteboard/paste-noplugin.html: Added.
+
 2013-01-08  Filip Pizlo  <[email protected]>
 
         REGRESSION (r138921): Crash in JSC::Arguments::create

Added: trunk/LayoutTests/editing/pasteboard/paste-noplugin-expected.txt (0 => 139111)


--- trunk/LayoutTests/editing/pasteboard/paste-noplugin-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-noplugin-expected.txt	2013-01-08 22:11:02 UTC (rev 139111)
@@ -0,0 +1,27 @@
+This test copies embed and object elements, pastes them into an editable area, and verifies that unsafe tags are not pasted when the setting prohibits this.
+
+Original contents:
+| "
+"
+| <p>
+|   "Some text to paste."
+| "
+"
+| <embed>
+|   src=""
+| "
+"
+| <object>
+|   data=""
+|   <param>
+|     name="src"
+|     value="http://localhost:8000/evil.swf"
+|   <embed>
+|     src=""
+| "
+"
+
+Pasted contents:
+| <p>
+|   "Some text to paste."
+| " <#selection-caret>"

Added: trunk/LayoutTests/editing/pasteboard/paste-noplugin.html (0 => 139111)


--- trunk/LayoutTests/editing/pasteboard/paste-noplugin.html	                        (rev 0)
+++ trunk/LayoutTests/editing/pasteboard/paste-noplugin.html	2013-01-08 22:11:02 UTC (rev 139111)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<script>
+if (window.testRunner) {
+   testRunner.dumpAsText();
+   internals.settings.setUnsafePluginPastingEnabled(false);
+}
+</script>
+<script src=""
+<div id="source">
+<p>Some text to paste.</p>
+<embed src=""
+<object data="" name="src" value="http://localhost:8000/evil.swf"><embed src=""
+</div>
+<div id="destination" contenteditable="true"></div>
+<ul id="console"></ul>
+<script>
+var source = document.getElementById("source");
+var destination = document.getElementById("destination");
+var selection = window.getSelection();
+selection.setBaseAndExtent(source, 0, source, 5);
+document.execCommand("Copy");
+selection.setPosition(destination, 0);
+document.execCommand("Paste");
+Markup.description("This test copies embed and object elements, pastes them into an editable area, and verifies that unsafe tags are not pasted when the setting prohibits this.");
+Markup.dump("source", "Original contents");
+Markup.dump("destination", "Pasted contents");
+</script>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (139110 => 139111)


--- trunk/Source/WebCore/ChangeLog	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/ChangeLog	2013-01-08 22:11:02 UTC (rev 139111)
@@ -1,3 +1,64 @@
+2013-01-08  Tom Sepez  <[email protected]>
+
+        Copy-paste preserves <embed> tags containing active content.
+        https://bugs.webkit.org/show_bug.cgi?id=77625
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: editing/pasteboard/paste-noplugin.html
+
+        * dom/FragmentScriptingPermission.h:
+        (WebCore::scriptingContentIsAllowed):
+        (WebCore::pluginContentIsAllowed):
+        Add new permission to restrict plugin pasting.  Add inline functions to check
+        the implications of each permission rather than having a list of raw comparisions
+        sprinkled throughout the code. 
+        
+        * editing/markup.cpp:
+        (WebCore::createFragmentFromMarkup):
+        Revert back to unsafe plugin pasting regardless of caller's intentions when
+        the settings allow it.
+
+        * dom/Element.cpp:
+        (WebCore::Element::parserSetAttributes):
+        * html/parser/HTMLConstructionSite.cpp:
+        (WebCore::HTMLConstructionSite::insertScriptElement):
+        * xml/parser/XMLDocumentParserLibxml2.cpp:
+        (WebCore::XMLDocumentParser::endElementNs):
+        * xml/parser/XMLDocumentParserQt.cpp:
+        (WebCore::XMLDocumentParser::parseEndElement):
+        Use new inline functions to check implications of permissions rather than raw
+        comparisions.
+        
+        * html/parser/HTMLTreeBuilder.cpp:
+        (WebCore::HTMLTreeBuilder::processStartTagForInBody):
+        (WebCore::HTMLTreeBuilder::processEndTag):
+        Check if plugin pasting is allowed before inserting applet/embed/oject elements.
+
+        * page/Settings.in:
+        Declaration of new unsafePluginPastingEnabled setting.
+
+        * platform/mac/PasteboardMac.mm:
+        (WebCore::Pasteboard::documentFragment):
+        * platform/blackberry/PasteboardBlackBerry.cpp:
+        (WebCore::Pasteboard::documentFragment):
+        * platform/chromium/DragDataChromium.cpp:
+        (WebCore::DragData::asFragment):
+        * platform/chromium/PasteboardChromium.cpp:
+        (WebCore::Pasteboard::documentFragment):
+        * platform/gtk/PasteboardGtk.cpp:
+        (WebCore::Pasteboard::documentFragment):
+        * platform/qt/DragDataQt.cpp:
+        (WebCore::DragData::asFragment):
+        * platform/qt/PasteboardQt.cpp:
+        (WebCore::Pasteboard::documentFragment):
+        * platform/win/ClipboardUtilitiesWin.cpp:
+        (WebCore::fragmentFromCFHTML):
+        (WebCore::fragmentFromHTML):
+        * platform/wx/PasteboardWx.cpp:
+        (WebCore::Pasteboard::documentFragment):
+        Pass DisallowScriptingAndPluginContent enum value.
+        
 2013-01-08  Alexis Menard  <[email protected]>
 
         WebKit does not reject some cubic-bezier form values for transition-timing-function.

Modified: trunk/Source/WebCore/dom/Element.cpp (139110 => 139111)


--- trunk/Source/WebCore/dom/Element.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/dom/Element.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -980,8 +980,8 @@
 
     // If the element is created as result of a paste or drag-n-drop operation
     // we want to remove all the script and event handlers.
-    if (scriptingPermission == DisallowScriptingContent) {
-        unsigned i = 0;
+    if (!scriptingContentIsAllowed(scriptingPermission)) {
+        size_t i = 0;
         while (i < filteredAttributes.size()) {
             Attribute& attribute = filteredAttributes[i];
             if (isEventHandlerAttribute(attribute.name())) {

Modified: trunk/Source/WebCore/dom/FragmentScriptingPermission.h (139110 => 139111)


--- trunk/Source/WebCore/dom/FragmentScriptingPermission.h	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/dom/FragmentScriptingPermission.h	2013-01-08 22:11:02 UTC (rev 139111)
@@ -31,11 +31,22 @@
 // FIXME: This enum is poorly named.  It is used to remove script contents when
 // generating DocumentFragments for paste in platform/*/Pasteboard.*.
 enum FragmentScriptingPermission {
+    DisallowScriptingAndPluginContentIfNeeded,
     DisallowScriptingContent,
     AllowScriptingContent,
     AllowScriptingContentAndDoNotMarkAlreadyStarted,
 };
 
-};
+static inline bool scriptingContentIsAllowed(FragmentScriptingPermission scriptingPermission) 
+{
+    return scriptingPermission == AllowScriptingContent || scriptingPermission == AllowScriptingContentAndDoNotMarkAlreadyStarted;
+}
 
+static inline bool pluginContentIsAllowed(FragmentScriptingPermission scriptingPermission)
+{
+    return scriptingPermission != DisallowScriptingAndPluginContentIfNeeded;
+}
+
+} // namespace WebCore
+
 #endif // FragmentScriptingPermission_h

Modified: trunk/Source/WebCore/editing/markup.cpp (139110 => 139111)


--- trunk/Source/WebCore/editing/markup.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/editing/markup.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -54,6 +54,7 @@
 #include "NodeTraversal.h"
 #include "Range.h"
 #include "RenderObject.h"
+#include "Settings.h"
 #include "StylePropertySet.h"
 #include "StyleResolver.h"
 #include "TextIterator.h"
@@ -663,6 +664,10 @@
     // We use a fake body element here to trick the HTML parser to using the InBody insertion mode.
     RefPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(document);
     RefPtr<DocumentFragment> fragment = DocumentFragment::create(document);
+
+    if (scriptingPermission == DisallowScriptingAndPluginContentIfNeeded && (!document->settings() || document->settings()->unsafePluginPastingEnabled()))
+        scriptingPermission = DisallowScriptingContent;
+
     fragment->parseHTML(markup, fakeBody.get(), scriptingPermission);
 
     if (!baseURL.isEmpty() && baseURL != blankURL() && baseURL != document->baseURL())

Modified: trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp (139110 => 139111)


--- trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -346,7 +346,7 @@
     const bool parserInserted = m_fragmentScriptingPermission != AllowScriptingContentAndDoNotMarkAlreadyStarted;
     const bool alreadyStarted = m_isParsingFragment && parserInserted;
     RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, ownerDocumentForCurrentNode(), parserInserted, alreadyStarted);
-    if (m_fragmentScriptingPermission != DisallowScriptingContent)
+    if (scriptingContentIsAllowed(m_fragmentScriptingPermission))
         element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission);
     attachLater(currentNode(), element);
     m_openElements.push(HTMLStackItem::create(element.release(), token));

Modified: trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp (139110 => 139111)


--- trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -820,6 +820,12 @@
         return;
     }
     if (token->name() == appletTag
+        || token->name() == embedTag
+        || token->name() == objectTag) {
+        if (isParsingFragment() && !pluginContentIsAllowed(m_fragmentContext.scriptingPermission()))
+            return;
+    }
+    if (token->name() == appletTag
         || token->name() == marqueeTag
         || token->name() == objectTag) {
         m_tree.reconstructTheActiveFormattingElements();
@@ -2181,7 +2187,7 @@
             ASSERT(m_tree.currentStackItem()->hasTagName(scriptTag));
             m_scriptToProcess = m_tree.currentElement();
             m_tree.openElements()->pop();
-            if (isParsingFragment() && m_fragmentContext.scriptingPermission() == DisallowScriptingContent)
+            if (isParsingFragment() && !scriptingContentIsAllowed(m_fragmentContext.scriptingPermission()))
                 m_scriptToProcess->removeAllChildren();
             setInsertionMode(m_originalInsertionMode);
 

Modified: trunk/Source/WebCore/page/Settings.in (139110 => 139111)


--- trunk/Source/WebCore/page/Settings.in	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/page/Settings.in	2013-01-08 22:11:02 UTC (rev 139111)
@@ -82,6 +82,7 @@
 downloadableBinaryFontsEnabled initial=true
 
 xssAuditorEnabled initial=false
+unsafePluginPastingEnabled initial=true
 acceleratedCompositingFor3DTransformsEnabled initial=true
 acceleratedCompositingForVideoEnabled initial=true
 acceleratedCompositingForPluginsEnabled initial=true

Modified: trunk/Source/WebCore/platform/blackberry/PasteboardBlackBerry.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/blackberry/PasteboardBlackBerry.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/blackberry/PasteboardBlackBerry.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -97,7 +97,7 @@
     RefPtr<DocumentFragment> fragment;
     if (!html.isEmpty()) {
         String url = ""
-        if (fragment = createFragmentFromMarkup(frame->document(), html, url, DisallowScriptingContent))
+        if (fragment = createFragmentFromMarkup(frame->document(), html, url, DisallowScriptingAndPluginContentIfNeeded))
             return fragment.release();
     }
 

Modified: trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -32,6 +32,7 @@
 
 #include "ChromiumDataObject.h"
 #include "ClipboardMimeTypes.h"
+#include "Document.h"
 #include "DocumentFragment.h"
 #include "FileSystem.h"
 #include "Frame.h"
@@ -153,8 +154,8 @@
         String html;
         KURL baseURL;
         m_platformDragData->htmlAndBaseURL(html, baseURL);
-        RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, baseURL, DisallowScriptingContent);
-        return fragment.release();
+        if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, baseURL, DisallowScriptingAndPluginContentIfNeeded))
+            return fragment.release();
     }
 
     return 0;

Modified: trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -182,16 +182,13 @@
     WebKit::WebClipboard::Buffer buffer = m_selectionMode ? WebKit::WebClipboard::BufferSelection : WebKit::WebClipboard::BufferStandard;
 
     if (WebKit::Platform::current()->clipboard()->isFormatAvailable(WebKit::WebClipboard::FormatHTML, buffer)) {
-        WebKit::WebString markup;
         unsigned fragmentStart = 0;
         unsigned fragmentEnd = 0;
         WebKit::WebURL url;
-        markup = WebKit::Platform::current()->clipboard()->readHTML(buffer, &url, &fragmentStart, &fragmentEnd);
+        WebKit::WebString markup = WebKit::Platform::current()->clipboard()->readHTML(buffer, &url, &fragmentStart, &fragmentEnd);
         if (!markup.isEmpty()) {
-          RefPtr<DocumentFragment> fragment =
-              createFragmentFromMarkupWithContext(frame->document(), markup, fragmentStart, fragmentEnd, KURL(url), DisallowScriptingContent);
-          if (fragment)
-              return fragment.release();
+            if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkupWithContext(frame->document(), markup, fragmentStart, fragmentEnd, KURL(url), DisallowScriptingAndPluginContentIfNeeded))
+                return fragment.release();
         }
     }
 
@@ -199,10 +196,7 @@
         String markup = WebKit::Platform::current()->clipboard()->readPlainText(buffer);
         if (!markup.isEmpty()) {
             chosePlainText = true;
-
-            RefPtr<DocumentFragment> fragment =
-                createFragmentFromText(context.get(), markup);
-            if (fragment)
+            if (RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), markup))
                 return fragment.release();
         }
     }

Modified: trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -171,7 +171,7 @@
     chosePlainText = false;
 
     if (dataObject->hasMarkup()) {
-        RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", DisallowScriptingContent);
+        RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", DisallowScriptingAndPluginContentIfNeeded);
         if (fragment)
             return fragment.release();
     }

Modified: trunk/Source/WebCore/platform/mac/PasteboardMac.mm (139110 => 139111)


--- trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/mac/PasteboardMac.mm	2013-01-08 22:11:02 UTC (rev 139111)
@@ -466,8 +466,8 @@
                     // FIXME: seems poor form to do this as a side effect of getting a document fragment
                     if (DocumentLoader* loader = frame->loader()->documentLoader())
                         loader->addAllArchiveResources(coreArchive.get());
-                    
-                    fragment = createFragmentFromMarkup(frame->document(), markupString, mainResource->url(), DisallowScriptingContent);
+
+                    fragment = createFragmentFromMarkup(frame->document(), markupString, mainResource->url(), DisallowScriptingAndPluginContentIfNeeded);
                     [markupString release];
                 } else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType))
                    fragment = documentFragmentWithImageResource(frame, mainResource);                    
@@ -506,7 +506,7 @@
             }
         }
         if ([HTMLString length] != 0 &&
-            (fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", DisallowScriptingContent)))
+            (fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", DisallowScriptingAndPluginContentIfNeeded)))
             return fragment.release();
     }
 

Modified: trunk/Source/WebCore/platform/qt/DragDataQt.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/qt/DragDataQt.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/qt/DragDataQt.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -137,7 +137,7 @@
 PassRefPtr<DocumentFragment> DragData::asFragment(Frame* frame, PassRefPtr<Range>, bool, bool&) const
 {
     if (m_platformDragData && m_platformDragData->hasHtml())
-        return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", DisallowScriptingContent);
+        return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", DisallowScriptingAndPluginContentIfNeeded);
 
     return 0;
 }

Modified: trunk/Source/WebCore/platform/qt/PasteboardQt.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/qt/PasteboardQt.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/qt/PasteboardQt.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -111,7 +111,7 @@
     if (mimeData->hasHtml()) {
         QString html = mimeData->html();
         if (!html.isEmpty()) {
-            RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", DisallowScriptingContent);
+            RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", DisallowScriptingAndPluginContentIfNeeded);
             if (fragment)
                 return fragment.release();
         }

Modified: trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -641,7 +641,7 @@
     }
 
     String markup = extractMarkupFromCFHTML(cfhtml);
-    return createFragmentFromMarkup(doc, markup, srcURL, DisallowScriptingContent);
+    return createFragmentFromMarkup(doc, markup, srcURL, DisallowScriptingAndPluginContentIfNeeded);
 }
 
 PassRefPtr<DocumentFragment> fragmentFromHTML(Document* doc, IDataObject* data) 
@@ -658,7 +658,7 @@
     String html = getTextHTML(data);
     String srcURL;
     if (!html.isEmpty())
-        return createFragmentFromMarkup(doc, html, srcURL, DisallowScriptingContent);
+        return createFragmentFromMarkup(doc, html, srcURL, DisallowScriptingAndPluginContentIfNeeded);
 
     return 0;
 }
@@ -676,7 +676,7 @@
 
     String srcURL;
     if (getDataMapItem(data, texthtmlFormat(), stringData))
-        return createFragmentFromMarkup(document, stringData, srcURL, DisallowScriptingContent);
+        return createFragmentFromMarkup(document, stringData, srcURL, DisallowScriptingAndPluginContentIfNeeded);
 
     return 0;
 }

Modified: trunk/Source/WebCore/platform/wx/PasteboardWx.cpp (139110 => 139111)


--- trunk/Source/WebCore/platform/wx/PasteboardWx.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/platform/wx/PasteboardWx.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -99,7 +99,7 @@
             wxHTMLDataObject data;
             wxTheClipboard->GetData(data);
             chosePlainText = false;
-            fragment = createFragmentFromMarkup(frame->document(), data.GetHTML(), "", DisallowScriptingContent);
+            fragment = createFragmentFromMarkup(frame->document(), data.GetHTML(), "", DisallowScriptingAndPluginContentIfNeeded);
         } else
 #endif
         {

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp (139110 => 139111)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -852,7 +852,7 @@
     if (hackAroundLibXMLEntityParsingBug() && context()->depth <= depthTriggeringEntityExpansion())
         setDepthTriggeringEntityExpansion(-1);
 
-    if (m_scriptingPermission == DisallowScriptingContent && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
+    if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
         popCurrentNode();
         ExceptionCode ec;
         n->remove(ec);

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParserQt.cpp (139110 => 139111)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParserQt.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParserQt.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -506,7 +506,7 @@
     RefPtr<ContainerNode> n = m_currentNode;
     n->finishParsingChildren();
 
-    if (m_scriptingPermission == DisallowScriptingContent && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
+    if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {
         popCurrentNode();
         ExceptionCode ec;
         n->remove(ec);

Modified: trunk/Source/WebKit/chromium/ChangeLog (139110 => 139111)


--- trunk/Source/WebKit/chromium/ChangeLog	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebKit/chromium/ChangeLog	2013-01-08 22:11:02 UTC (rev 139111)
@@ -1,3 +1,19 @@
+2013-01-08  Tom Sepez  <[email protected]>
+
+        Copy-paste preserves <embed> tags containing active content.
+        https://bugs.webkit.org/show_bug.cgi?id=77625
+
+        Reviewed by Ryosuke Niwa.
+
+        Adds chromium API to new unsafePluginPastingEnabled setting.
+
+        * public/WebSettings.h:
+        * src/WebSettingsImpl.cpp:
+        (WebKit::WebSettingsImpl::setUnsafePluginPastingEnabled):
+        (WebKit):
+        * src/WebSettingsImpl.h:
+        (WebSettingsImpl):
+
 2013-01-08  Mark Lam  <[email protected]>
 
         Removed the need for the ProposedDatabase mechanism.

Modified: trunk/Source/WebKit/chromium/public/WebSettings.h (139110 => 139111)


--- trunk/Source/WebKit/chromium/public/WebSettings.h	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebKit/chromium/public/WebSettings.h	2013-01-08 22:11:02 UTC (rev 139111)
@@ -161,6 +161,7 @@
     virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded() = 0;
     virtual void setTouchDragDropEnabled(bool) = 0;
     virtual void setUnifiedTextCheckerEnabled(bool) = 0;
+    virtual void setUnsafePluginPastingEnabled(bool) = 0;
     virtual void setUserStyleSheetLocation(const WebURL&) = 0;
     virtual void setUsesEncodingDetector(bool) = 0;
     virtual void setUsesPageCache(bool) = 0;

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp (139110 => 139111)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp	2013-01-08 22:11:02 UTC (rev 139111)
@@ -293,6 +293,11 @@
     m_settings->setXSSAuditorEnabled(enabled);
 }
 
+void WebSettingsImpl::setUnsafePluginPastingEnabled(bool enabled)
+{
+    m_settings->setUnsafePluginPastingEnabled(enabled);
+}
+
 void WebSettingsImpl::setDNSPrefetchingEnabled(bool enabled)
 {
     m_settings->setDNSPrefetchingEnabled(enabled);

Modified: trunk/Source/WebKit/chromium/src/WebSettingsImpl.h (139110 => 139111)


--- trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2013-01-08 22:03:24 UTC (rev 139110)
+++ trunk/Source/WebKit/chromium/src/WebSettingsImpl.h	2013-01-08 22:11:02 UTC (rev 139111)
@@ -158,6 +158,7 @@
     virtual void setTextDirectionSubmenuInclusionBehaviorNeverIncluded();
     virtual void setTouchDragDropEnabled(bool);
     virtual void setUnifiedTextCheckerEnabled(bool);
+    virtual void setUnsafePluginPastingEnabled(bool);
     virtual void setUserStyleSheetLocation(const WebURL&);
     virtual void setUsesEncodingDetector(bool);
     virtual void setUsesPageCache(bool);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to