Changeset 139111 in webkit
- Timestamp:
- Jan 8, 2013 2:11:02 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r139109 r139111 1 2013-01-08 Tom Sepez <tsepez@chromium.org> 2 3 Copy-paste preserves <embed> tags containing active content. 4 https://bugs.webkit.org/show_bug.cgi?id=77625 5 6 Reviewed by Ryosuke Niwa. 7 8 * editing/pasteboard/paste-noplugin-expected.txt: Added. 9 * editing/pasteboard/paste-noplugin.html: Added. 10 1 11 2013-01-08 Filip Pizlo <fpizlo@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r139106 r139111 1 2013-01-08 Tom Sepez <tsepez@chromium.org> 2 3 Copy-paste preserves <embed> tags containing active content. 4 https://bugs.webkit.org/show_bug.cgi?id=77625 5 6 Reviewed by Ryosuke Niwa. 7 8 Test: editing/pasteboard/paste-noplugin.html 9 10 * dom/FragmentScriptingPermission.h: 11 (WebCore::scriptingContentIsAllowed): 12 (WebCore::pluginContentIsAllowed): 13 Add new permission to restrict plugin pasting. Add inline functions to check 14 the implications of each permission rather than having a list of raw comparisions 15 sprinkled throughout the code. 16 17 * editing/markup.cpp: 18 (WebCore::createFragmentFromMarkup): 19 Revert back to unsafe plugin pasting regardless of caller's intentions when 20 the settings allow it. 21 22 * dom/Element.cpp: 23 (WebCore::Element::parserSetAttributes): 24 * html/parser/HTMLConstructionSite.cpp: 25 (WebCore::HTMLConstructionSite::insertScriptElement): 26 * xml/parser/XMLDocumentParserLibxml2.cpp: 27 (WebCore::XMLDocumentParser::endElementNs): 28 * xml/parser/XMLDocumentParserQt.cpp: 29 (WebCore::XMLDocumentParser::parseEndElement): 30 Use new inline functions to check implications of permissions rather than raw 31 comparisions. 32 33 * html/parser/HTMLTreeBuilder.cpp: 34 (WebCore::HTMLTreeBuilder::processStartTagForInBody): 35 (WebCore::HTMLTreeBuilder::processEndTag): 36 Check if plugin pasting is allowed before inserting applet/embed/oject elements. 37 38 * page/Settings.in: 39 Declaration of new unsafePluginPastingEnabled setting. 40 41 * platform/mac/PasteboardMac.mm: 42 (WebCore::Pasteboard::documentFragment): 43 * platform/blackberry/PasteboardBlackBerry.cpp: 44 (WebCore::Pasteboard::documentFragment): 45 * platform/chromium/DragDataChromium.cpp: 46 (WebCore::DragData::asFragment): 47 * platform/chromium/PasteboardChromium.cpp: 48 (WebCore::Pasteboard::documentFragment): 49 * platform/gtk/PasteboardGtk.cpp: 50 (WebCore::Pasteboard::documentFragment): 51 * platform/qt/DragDataQt.cpp: 52 (WebCore::DragData::asFragment): 53 * platform/qt/PasteboardQt.cpp: 54 (WebCore::Pasteboard::documentFragment): 55 * platform/win/ClipboardUtilitiesWin.cpp: 56 (WebCore::fragmentFromCFHTML): 57 (WebCore::fragmentFromHTML): 58 * platform/wx/PasteboardWx.cpp: 59 (WebCore::Pasteboard::documentFragment): 60 Pass DisallowScriptingAndPluginContent enum value. 61 1 62 2013-01-08 Alexis Menard <alexis@webkit.org> 2 63 -
trunk/Source/WebCore/dom/Element.cpp
r139100 r139111 981 981 // If the element is created as result of a paste or drag-n-drop operation 982 982 // we want to remove all the script and event handlers. 983 if ( scriptingPermission == DisallowScriptingContent) {984 unsignedi = 0;983 if (!scriptingContentIsAllowed(scriptingPermission)) { 984 size_t i = 0; 985 985 while (i < filteredAttributes.size()) { 986 986 Attribute& attribute = filteredAttributes[i]; -
trunk/Source/WebCore/dom/FragmentScriptingPermission.h
r117731 r139111 32 32 // generating DocumentFragments for paste in platform/*/Pasteboard.*. 33 33 enum FragmentScriptingPermission { 34 DisallowScriptingAndPluginContentIfNeeded, 34 35 DisallowScriptingContent, 35 36 AllowScriptingContent, … … 37 38 }; 38 39 39 }; 40 static inline bool scriptingContentIsAllowed(FragmentScriptingPermission scriptingPermission) 41 { 42 return scriptingPermission == AllowScriptingContent || scriptingPermission == AllowScriptingContentAndDoNotMarkAlreadyStarted; 43 } 44 45 static inline bool pluginContentIsAllowed(FragmentScriptingPermission scriptingPermission) 46 { 47 return scriptingPermission != DisallowScriptingAndPluginContentIfNeeded; 48 } 49 50 } // namespace WebCore 40 51 41 52 #endif // FragmentScriptingPermission_h -
trunk/Source/WebCore/editing/markup.cpp
r138811 r139111 55 55 #include "Range.h" 56 56 #include "RenderObject.h" 57 #include "Settings.h" 57 58 #include "StylePropertySet.h" 58 59 #include "StyleResolver.h" … … 664 665 RefPtr<HTMLBodyElement> fakeBody = HTMLBodyElement::create(document); 665 666 RefPtr<DocumentFragment> fragment = DocumentFragment::create(document); 667 668 if (scriptingPermission == DisallowScriptingAndPluginContentIfNeeded && (!document->settings() || document->settings()->unsafePluginPastingEnabled())) 669 scriptingPermission = DisallowScriptingContent; 670 666 671 fragment->parseHTML(markup, fakeBody.get(), scriptingPermission); 667 672 -
trunk/Source/WebCore/html/parser/HTMLConstructionSite.cpp
r139042 r139111 347 347 const bool alreadyStarted = m_isParsingFragment && parserInserted; 348 348 RefPtr<HTMLScriptElement> element = HTMLScriptElement::create(scriptTag, ownerDocumentForCurrentNode(), parserInserted, alreadyStarted); 349 if ( m_fragmentScriptingPermission != DisallowScriptingContent)349 if (scriptingContentIsAllowed(m_fragmentScriptingPermission)) 350 350 element->parserSetAttributes(token->attributes(), m_fragmentScriptingPermission); 351 351 attachLater(currentNode(), element); -
trunk/Source/WebCore/html/parser/HTMLTreeBuilder.cpp
r139042 r139111 819 819 m_tree.insertFormattingElement(token); 820 820 return; 821 } 822 if (token->name() == appletTag 823 || token->name() == embedTag 824 || token->name() == objectTag) { 825 if (isParsingFragment() && !pluginContentIsAllowed(m_fragmentContext.scriptingPermission())) 826 return; 821 827 } 822 828 if (token->name() == appletTag … … 2182 2188 m_scriptToProcess = m_tree.currentElement(); 2183 2189 m_tree.openElements()->pop(); 2184 if (isParsingFragment() && m_fragmentContext.scriptingPermission() == DisallowScriptingContent)2190 if (isParsingFragment() && !scriptingContentIsAllowed(m_fragmentContext.scriptingPermission())) 2185 2191 m_scriptToProcess->removeAllChildren(); 2186 2192 setInsertionMode(m_originalInsertionMode); -
trunk/Source/WebCore/page/Settings.in
r139026 r139111 83 83 84 84 xssAuditorEnabled initial=false 85 unsafePluginPastingEnabled initial=true 85 86 acceleratedCompositingFor3DTransformsEnabled initial=true 86 87 acceleratedCompositingForVideoEnabled initial=true -
trunk/Source/WebCore/platform/blackberry/PasteboardBlackBerry.cpp
r131316 r139111 98 98 if (!html.isEmpty()) { 99 99 String url = BlackBerry::Platform::Clipboard::readURL(); 100 if (fragment = createFragmentFromMarkup(frame->document(), html, url, DisallowScripting Content))100 if (fragment = createFragmentFromMarkup(frame->document(), html, url, DisallowScriptingAndPluginContentIfNeeded)) 101 101 return fragment.release(); 102 102 } -
trunk/Source/WebCore/platform/chromium/DragDataChromium.cpp
r127757 r139111 33 33 #include "ChromiumDataObject.h" 34 34 #include "ClipboardMimeTypes.h" 35 #include "Document.h" 35 36 #include "DocumentFragment.h" 36 37 #include "FileSystem.h" … … 154 155 KURL baseURL; 155 156 m_platformDragData->htmlAndBaseURL(html, baseURL); 156 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, baseURL, DisallowScriptingContent);157 return fragment.release();157 if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, baseURL, DisallowScriptingAndPluginContentIfNeeded)) 158 return fragment.release(); 158 159 } 159 160 -
trunk/Source/WebCore/platform/chromium/PasteboardChromium.cpp
r125247 r139111 183 183 184 184 if (WebKit::Platform::current()->clipboard()->isFormatAvailable(WebKit::WebClipboard::FormatHTML, buffer)) { 185 WebKit::WebString markup;186 185 unsigned fragmentStart = 0; 187 186 unsigned fragmentEnd = 0; 188 187 WebKit::WebURL url; 189 markup = WebKit::Platform::current()->clipboard()->readHTML(buffer, &url, &fragmentStart, &fragmentEnd);188 WebKit::WebString markup = WebKit::Platform::current()->clipboard()->readHTML(buffer, &url, &fragmentStart, &fragmentEnd); 190 189 if (!markup.isEmpty()) { 191 RefPtr<DocumentFragment> fragment = 192 createFragmentFromMarkupWithContext(frame->document(), markup, fragmentStart, fragmentEnd, KURL(url), DisallowScriptingContent); 193 if (fragment) 194 return fragment.release(); 190 if (RefPtr<DocumentFragment> fragment = createFragmentFromMarkupWithContext(frame->document(), markup, fragmentStart, fragmentEnd, KURL(url), DisallowScriptingAndPluginContentIfNeeded)) 191 return fragment.release(); 195 192 } 196 193 } … … 200 197 if (!markup.isEmpty()) { 201 198 chosePlainText = true; 202 203 RefPtr<DocumentFragment> fragment = 204 createFragmentFromText(context.get(), markup); 205 if (fragment) 199 if (RefPtr<DocumentFragment> fragment = createFragmentFromText(context.get(), markup)) 206 200 return fragment.release(); 207 201 } -
trunk/Source/WebCore/platform/gtk/PasteboardGtk.cpp
r127862 r139111 172 172 173 173 if (dataObject->hasMarkup()) { 174 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", DisallowScripting Content);174 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), dataObject->markup(), "", DisallowScriptingAndPluginContentIfNeeded); 175 175 if (fragment) 176 176 return fragment.release(); -
trunk/Source/WebCore/platform/mac/PasteboardMac.mm
r130947 r139111 467 467 if (DocumentLoader* loader = frame->loader()->documentLoader()) 468 468 loader->addAllArchiveResources(coreArchive.get()); 469 470 fragment = createFragmentFromMarkup(frame->document(), markupString, mainResource->url(), DisallowScripting Content);469 470 fragment = createFragmentFromMarkup(frame->document(), markupString, mainResource->url(), DisallowScriptingAndPluginContentIfNeeded); 471 471 [markupString release]; 472 472 } else if (MIMETypeRegistry::isSupportedImageMIMEType(MIMEType)) … … 507 507 } 508 508 if ([HTMLString length] != 0 && 509 (fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", DisallowScripting Content)))509 (fragment = createFragmentFromMarkup(frame->document(), HTMLString, "", DisallowScriptingAndPluginContentIfNeeded))) 510 510 return fragment.release(); 511 511 } -
trunk/Source/WebCore/platform/qt/DragDataQt.cpp
r117731 r139111 138 138 { 139 139 if (m_platformDragData && m_platformDragData->hasHtml()) 140 return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", DisallowScripting Content);140 return createFragmentFromMarkup(frame->document(), m_platformDragData->html(), "", DisallowScriptingAndPluginContentIfNeeded); 141 141 142 142 return 0; -
trunk/Source/WebCore/platform/qt/PasteboardQt.cpp
r130636 r139111 112 112 QString html = mimeData->html(); 113 113 if (!html.isEmpty()) { 114 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", DisallowScripting Content);114 RefPtr<DocumentFragment> fragment = createFragmentFromMarkup(frame->document(), html, "", DisallowScriptingAndPluginContentIfNeeded); 115 115 if (fragment) 116 116 return fragment.release(); -
trunk/Source/WebCore/platform/win/ClipboardUtilitiesWin.cpp
r135763 r139111 642 642 643 643 String markup = extractMarkupFromCFHTML(cfhtml); 644 return createFragmentFromMarkup(doc, markup, srcURL, DisallowScripting Content);644 return createFragmentFromMarkup(doc, markup, srcURL, DisallowScriptingAndPluginContentIfNeeded); 645 645 } 646 646 … … 659 659 String srcURL; 660 660 if (!html.isEmpty()) 661 return createFragmentFromMarkup(doc, html, srcURL, DisallowScripting Content);661 return createFragmentFromMarkup(doc, html, srcURL, DisallowScriptingAndPluginContentIfNeeded); 662 662 663 663 return 0; … … 677 677 String srcURL; 678 678 if (getDataMapItem(data, texthtmlFormat(), stringData)) 679 return createFragmentFromMarkup(document, stringData, srcURL, DisallowScripting Content);679 return createFragmentFromMarkup(document, stringData, srcURL, DisallowScriptingAndPluginContentIfNeeded); 680 680 681 681 return 0; -
trunk/Source/WebCore/platform/wx/PasteboardWx.cpp
r127757 r139111 100 100 wxTheClipboard->GetData(data); 101 101 chosePlainText = false; 102 fragment = createFragmentFromMarkup(frame->document(), data.GetHTML(), "", DisallowScripting Content);102 fragment = createFragmentFromMarkup(frame->document(), data.GetHTML(), "", DisallowScriptingAndPluginContentIfNeeded); 103 103 } else 104 104 #endif -
trunk/Source/WebCore/xml/parser/XMLDocumentParserLibxml2.cpp
r138863 r139111 853 853 setDepthTriggeringEntityExpansion(-1); 854 854 855 if ( m_scriptingPermission == DisallowScriptingContent&& n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {855 if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) { 856 856 popCurrentNode(); 857 857 ExceptionCode ec; -
trunk/Source/WebCore/xml/parser/XMLDocumentParserQt.cpp
r138863 r139111 507 507 n->finishParsingChildren(); 508 508 509 if ( m_scriptingPermission == DisallowScriptingContent&& n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) {509 if (!scriptingContentIsAllowed(m_scriptingPermission) && n->isElementNode() && toScriptElement(static_cast<Element*>(n.get()))) { 510 510 popCurrentNode(); 511 511 ExceptionCode ec; -
trunk/Source/WebKit/chromium/ChangeLog
r139078 r139111 1 2013-01-08 Tom Sepez <tsepez@chromium.org> 2 3 Copy-paste preserves <embed> tags containing active content. 4 https://bugs.webkit.org/show_bug.cgi?id=77625 5 6 Reviewed by Ryosuke Niwa. 7 8 Adds chromium API to new unsafePluginPastingEnabled setting. 9 10 * public/WebSettings.h: 11 * src/WebSettingsImpl.cpp: 12 (WebKit::WebSettingsImpl::setUnsafePluginPastingEnabled): 13 (WebKit): 14 * src/WebSettingsImpl.h: 15 (WebSettingsImpl): 16 1 17 2013-01-08 Mark Lam <mark.lam@apple.com> 2 18 -
trunk/Source/WebKit/chromium/public/WebSettings.h
r139028 r139111 162 162 virtual void setTouchDragDropEnabled(bool) = 0; 163 163 virtual void setUnifiedTextCheckerEnabled(bool) = 0; 164 virtual void setUnsafePluginPastingEnabled(bool) = 0; 164 165 virtual void setUserStyleSheetLocation(const WebURL&) = 0; 165 166 virtual void setUsesEncodingDetector(bool) = 0; -
trunk/Source/WebKit/chromium/src/WebSettingsImpl.cpp
r139028 r139111 294 294 } 295 295 296 void WebSettingsImpl::setUnsafePluginPastingEnabled(bool enabled) 297 { 298 m_settings->setUnsafePluginPastingEnabled(enabled); 299 } 300 296 301 void WebSettingsImpl::setDNSPrefetchingEnabled(bool enabled) 297 302 { -
trunk/Source/WebKit/chromium/src/WebSettingsImpl.h
r139028 r139111 159 159 virtual void setTouchDragDropEnabled(bool); 160 160 virtual void setUnifiedTextCheckerEnabled(bool); 161 virtual void setUnsafePluginPastingEnabled(bool); 161 162 virtual void setUserStyleSheetLocation(const WebURL&); 162 163 virtual void setUsesEncodingDetector(bool);
Note: See TracChangeset
for help on using the changeset viewer.