Title: [213284] trunk
Revision
213284
Author
cdu...@apple.com
Date
2017-03-02 09:55:13 -0800 (Thu, 02 Mar 2017)

Log Message

Download attribute set to "*\" save file with name "example.com"
https://bugs.webkit.org/show_bug.cgi?id=169066
<rdar://problem/30740875>

Reviewed by Alex Christensen.

Source/WebCore:

The issue is that a backslash in recognized as an escaping character in
a quoted string as per RFC2616:
"
The backslash character ("\") MAY be used as a single-character
quoting mechanism only within quoted-string and comment constructs.
"

We therefore need to escape the backslashes in the filename before
using it in the Content-Disposition header, inside the quoted string.

Test: fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html

* platform/network/ResourceResponseBase.cpp:
(WebCore::ResourceResponseBase::sanitizeSuggestedFilename):

LayoutTests:

Add layout test coverage.

* fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash-expected.txt: Added.
* fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (213283 => 213284)


--- trunk/LayoutTests/ChangeLog	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/LayoutTests/ChangeLog	2017-03-02 17:55:13 UTC (rev 213284)
@@ -1,3 +1,16 @@
+2017-03-02  Chris Dumez  <cdu...@apple.com>
+
+        Download attribute set to "*\" save file with name "example.com"
+        https://bugs.webkit.org/show_bug.cgi?id=169066
+        <rdar://problem/30740875>
+
+        Reviewed by Alex Christensen.
+
+        Add layout test coverage.
+
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash-expected.txt: Added.
+        * fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html: Added.
+
 2017-03-02  Youenn Fablet  <you...@apple.com>
 
         [WebRTC] Activate ICE candidate privacy policy

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash-expected.txt (0 => 213284)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash-expected.txt	2017-03-02 17:55:13 UTC (rev 213284)
@@ -0,0 +1,6 @@
+Download started.
+Downloading URL with suggested filename "*\.png"
+Download completed.
+The suggested filename above should be "*\.png" and the download should succeed.
+
+File backed blob URL

Added: trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html (0 => 213284)


--- trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html	                        (rev 0)
+++ trunk/LayoutTests/fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html	2017-03-02 17:55:13 UTC (rev 213284)
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/_javascript_'>
+if (window.testRunner) {
+  testRunner.dumpAsText();
+  testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>The suggested filename above should be "*\.png" and the download should succeed.</p>
+<a id="blob-url" download="*\">File backed blob URL</a>
+<script>
+function click(elmt)
+{
+    if (!window.eventSender) {
+        alert('Click the link to run the test.');
+        return;
+    }
+    eventSender.mouseMoveTo(elmt.offsetLeft + 5, elmt.offsetTop + 5);
+    eventSender.mouseDown();
+    eventSender.mouseUp();
+}
+
+function runTest()
+{
+    file = internals.createFile("../resources/abe.png");
+    var link = document.getElementById("blob-url");
+    link.href = ""
+    click(link);
+}
+runTest();
+</script>
+</body>
+</html>

Modified: trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations (213283 => 213284)


--- trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/LayoutTests/platform/ios-simulator-wk1/TestExpectations	2017-03-02 17:55:13 UTC (rev 213284)
@@ -1331,6 +1331,7 @@
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]

Modified: trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations (213283 => 213284)


--- trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/LayoutTests/platform/ios-simulator-wk2/TestExpectations	2017-03-02 17:55:13 UTC (rev 213284)
@@ -1812,6 +1812,7 @@
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-download.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-convert-to-download.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
 webkit.org/b/156067 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]

Modified: trunk/LayoutTests/platform/mac-wk1/TestExpectations (213283 => 213284)


--- trunk/LayoutTests/platform/mac-wk1/TestExpectations	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/LayoutTests/platform/mac-wk1/TestExpectations	2017-03-02 17:55:13 UTC (rev 213284)
@@ -215,6 +215,7 @@
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
 webkit.org/b/156069 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]

Modified: trunk/LayoutTests/platform/win/TestExpectations (213283 => 213284)


--- trunk/LayoutTests/platform/win/TestExpectations	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/LayoutTests/platform/win/TestExpectations	2017-03-02 17:55:13 UTC (rev 213284)
@@ -445,6 +445,7 @@
 fast/dom/HTMLAnchorElement/anchor-download-synthetic-click.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-download-user-triggered-synthetic-click.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download.html [ Skip ]
+fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-doublequote.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-slashes.html [ Skip ]
 fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-unicode.html [ Skip ]

Modified: trunk/Source/WebCore/ChangeLog (213283 => 213284)


--- trunk/Source/WebCore/ChangeLog	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/Source/WebCore/ChangeLog	2017-03-02 17:55:13 UTC (rev 213284)
@@ -1,3 +1,26 @@
+2017-03-02  Chris Dumez  <cdu...@apple.com>
+
+        Download attribute set to "*\" save file with name "example.com"
+        https://bugs.webkit.org/show_bug.cgi?id=169066
+        <rdar://problem/30740875>
+
+        Reviewed by Alex Christensen.
+
+        The issue is that a backslash in recognized as an escaping character in
+        a quoted string as per RFC2616:
+        "
+        The backslash character ("\") MAY be used as a single-character
+        quoting mechanism only within quoted-string and comment constructs.
+        "
+
+        We therefore need to escape the backslashes in the filename before
+        using it in the Content-Disposition header, inside the quoted string.
+
+        Test: fast/dom/HTMLAnchorElement/anchor-file-blob-download-includes-backslash.html
+
+        * platform/network/ResourceResponseBase.cpp:
+        (WebCore::ResourceResponseBase::sanitizeSuggestedFilename):
+
 2017-03-02  Youenn Fablet  <you...@apple.com>
 
         [WebRTC] Activate ICE candidate privacy policy

Modified: trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp (213283 => 213284)


--- trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2017-03-02 16:24:30 UTC (rev 213283)
+++ trunk/Source/WebCore/platform/network/ResourceResponseBase.cpp	2017-03-02 17:55:13 UTC (rev 213284)
@@ -231,7 +231,7 @@
 
     ResourceResponse response(URL(ParsedURLString, "http://example.com/"), String(), -1, String());
     response.setHTTPStatusCode(200);
-    String escapedSuggestedFilename = String(suggestedFilename).replace('\"', "\\\"");
+    String escapedSuggestedFilename = String(suggestedFilename).replace('\\', "\\\\").replace('\"', "\\\"");
     String value = makeString("attachment; filename=\"", escapedSuggestedFilename, '"');
     response.setHTTPHeaderField(HTTPHeaderName::ContentDisposition, value);
     return response.suggestedFilename();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to