Title: [167850] trunk
Revision
167850
Author
[email protected]
Date
2014-04-26 19:48:19 -0700 (Sat, 26 Apr 2014)

Log Message

Local files should not be allowed to read pasteboard data during drag
https://bugs.webkit.org/show_bug.cgi?id=131767

Reviewed by Sam Weinig.

Source/WebCore:
Test: fast/files/local-file-drag-security.html

* page/DragController.cpp:
(WebCore::DragController::dragExited):
(WebCore::DragController::tryDHTMLDrag):
Make an old Dashboard quirk really Dashboard only.

LayoutTests:
* fast/files/local-file-drag-security-expected.txt: Added.
* fast/files/local-file-drag-security.html: Added.
* platform/wk2/TestExpectations:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (167849 => 167850)


--- trunk/LayoutTests/ChangeLog	2014-04-27 02:43:31 UTC (rev 167849)
+++ trunk/LayoutTests/ChangeLog	2014-04-27 02:48:19 UTC (rev 167850)
@@ -1,3 +1,14 @@
+2014-04-26  Alexey Proskuryakov  <[email protected]>
+
+        Local files should not be allowed to read pasteboard data during drag
+        https://bugs.webkit.org/show_bug.cgi?id=131767
+
+        Reviewed by Sam Weinig.
+
+        * fast/files/local-file-drag-security-expected.txt: Added.
+        * fast/files/local-file-drag-security.html: Added.
+        * platform/wk2/TestExpectations:
+
 2014-04-24  Darin Adler  <[email protected]>
 
         REGRESSION (r164133): Selection doesn't paint when scrolling some pages

Added: trunk/LayoutTests/fast/files/local-file-drag-security-expected.txt (0 => 167850)


--- trunk/LayoutTests/fast/files/local-file-drag-security-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/files/local-file-drag-security-expected.txt	2014-04-27 02:48:19 UTC (rev 167850)
@@ -0,0 +1,9 @@
+Test that files are not accessible while dragging. To test manually, drop an HTML file on the box below.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS event.dataTransfer.files.length is 0
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/files/local-file-drag-security.html (0 => 167850)


--- trunk/LayoutTests/fast/files/local-file-drag-security.html	                        (rev 0)
+++ trunk/LayoutTests/fast/files/local-file-drag-security.html	2014-04-27 02:48:19 UTC (rev 167850)
@@ -0,0 +1,53 @@
+<!DOCTYPE html>
+<head>
+<script src=""
+<style>
+#dropTarget { text-align: center; display: table-cell; vertical-align: middle }
+#dropTarget {width: 256px; height: 256px; border: 1px dashed}
+</style>
+</head>
+<body>
+<div id=description></div>
+<div id=dropTarget webkitdropzone="move file:text/html"></div>
+<div id=console></div>
+<script>
+if (window.testRunner)
+    testRunner.dumpAsText();
+
+description("Test that files are not accessible while dragging. To test manually, drop an HTML file on the box below.");
+jsTestIsAsync = true;
+
+window._onload_ = function()
+{
+    var dropTarget = document.getElementById("dropTarget");
+
+    dropTarget.addEventListener("dragover", ondragover, true);
+    dropTarget.addEventListener("drop", ondrop, true);
+        
+     if (!window.eventSender)
+        return;
+
+    var endX = dropTarget.offsetLeft + dropTarget.offsetWidth / 2;
+    var endY = dropTarget.offsetTop + dropTarget.offsetHeight / 2
+    
+    eventSender.beginDragWithFiles(["resources/file-reader-real.html"]);
+    eventSender.mouseMoveTo(endX, endY);
+    eventSender.mouseUp();
+
+    document.body.removeChild(dropTarget);
+    finishJSTest();
+}
+
+function ondragover(event)
+{
+    shouldBe("event.dataTransfer.files.length", "0");
+}
+
+function ondrop(event)
+{
+    event.preventDefault();
+}
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/LayoutTests/platform/wk2/TestExpectations (167849 => 167850)


--- trunk/LayoutTests/platform/wk2/TestExpectations	2014-04-27 02:43:31 UTC (rev 167849)
+++ trunk/LayoutTests/platform/wk2/TestExpectations	2014-04-27 02:48:19 UTC (rev 167850)
@@ -660,6 +660,7 @@
 fast/files/file-reader-abort.html
 fast/files/file-reader-directory-crash.html
 fast/files/file-reader-event-listener.html
+fast/files/local-file-drag-security.html
 fast/files/null-origin-string.html
 fast/files/read-blob-async.html
 fast/files/read-file-async.html

Modified: trunk/Source/WebCore/ChangeLog (167849 => 167850)


--- trunk/Source/WebCore/ChangeLog	2014-04-27 02:43:31 UTC (rev 167849)
+++ trunk/Source/WebCore/ChangeLog	2014-04-27 02:48:19 UTC (rev 167850)
@@ -1,3 +1,17 @@
+2014-04-26  Alexey Proskuryakov  <[email protected]>
+
+        Local files should not be allowed to read pasteboard data during drag
+        https://bugs.webkit.org/show_bug.cgi?id=131767
+
+        Reviewed by Sam Weinig.
+
+        Test: fast/files/local-file-drag-security.html
+
+        * page/DragController.cpp:
+        (WebCore::DragController::dragExited):
+        (WebCore::DragController::tryDHTMLDrag):
+        Make an old Dashboard quirk really Dashboard only.
+
 2014-04-24  Darin Adler  <[email protected]>
 
         REGRESSION (r164133): Selection doesn't paint when scrolling some pages

Modified: trunk/Source/WebCore/page/DragController.cpp (167849 => 167850)


--- trunk/Source/WebCore/page/DragController.cpp	2014-04-27 02:43:31 UTC (rev 167849)
+++ trunk/Source/WebCore/page/DragController.cpp	2014-04-27 02:48:19 UTC (rev 167850)
@@ -181,7 +181,12 @@
 void DragController::dragExited(DragData& dragData)
 {
     if (RefPtr<FrameView> v = m_page.mainFrame().view()) {
-        DataTransferAccessPolicy policy = (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal()) ? DataTransferAccessPolicy::Readable : DataTransferAccessPolicy::TypesReadable;
+#if ENABLE(DASHBOARD_SUPPORT)
+        DataTransferAccessPolicy policy = (m_page.mainFrame().settings().usesDashboardBackwardCompatibilityMode() && (!m_documentUnderMouse || m_documentUnderMouse->securityOrigin()->isLocal())) ?
+        DataTransferAccessPolicy::Readable : DataTransferAccessPolicy::TypesReadable;
+#else
+        DataTransferAccessPolicy policy = DataTransferAccessPolicy::TypesReadable;
+#endif
         RefPtr<DataTransfer> dataTransfer = DataTransfer::createForDragAndDrop(policy, dragData);
         dataTransfer->setSourceOperation(dragData.draggingSourceOperationMask());
         m_page.mainFrame().eventHandler().cancelDragAndDrop(createMouseEvent(dragData), dataTransfer.get());
@@ -587,7 +592,12 @@
     if (!viewProtector)
         return false;
 
-    DataTransferAccessPolicy policy = m_documentUnderMouse->securityOrigin()->isLocal() ? DataTransferAccessPolicy::Readable : DataTransferAccessPolicy::TypesReadable;
+#if ENABLE(DASHBOARD_SUPPORT)
+    DataTransferAccessPolicy policy = (mainFrame->settings().usesDashboardBackwardCompatibilityMode() && m_documentUnderMouse->securityOrigin()->isLocal()) ?
+        DataTransferAccessPolicy::Readable : DataTransferAccessPolicy::TypesReadable;
+#else
+    DataTransferAccessPolicy policy = DataTransferAccessPolicy::TypesReadable;
+#endif
     RefPtr<DataTransfer> dataTransfer = DataTransfer::createForDragAndDrop(policy, dragData);
     DragOperation srcOpMask = dragData.draggingSourceOperationMask();
     dataTransfer->setSourceOperation(srcOpMask);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to