Diff
Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/ChangeLog 2017-05-08 10:38:31 UTC (rev 216379)
@@ -1,3 +1,26 @@
+2017-04-25 Chris Dumez <[email protected]>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ * http/tests/security/anchor-download-allow-sameorigin.html:
+ Stop using attachment.php as resource for this download attribute test because attachment.php
+ returns a Content-Disposition header with a filename. Given the behavior change in this patch,
+ this resource is no longer suitable for testing the download attribute.
+
+ * http/tests/download/anchor-download-attribute-content-disposition-expected.txt: Added.
+ * http/tests/download/anchor-download-attribute-content-disposition.html: Added.
+ * http/tests/download/resources/content-disposition-pass.php: Added.
+ Add layout test coverage.
+
+ * platform/ios-wk2/TestExpectations:
+ * platform/mac-wk1/TestExpectations:
+ * platform/win/TestExpectations:
+ Skip new test on platforms where the download attribute is not supported.
+
2017-04-21 Zalan Bujtas <[email protected]>
REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
Added: releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt (0 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition-expected.txt 2017-05-08 10:38:31 UTC (rev 216379)
@@ -0,0 +1,8 @@
+Download started.
+Downloading URL with suggested filename "PASS.txt"
+Download completed.
+Tests that the filename from the Content-Disposition header is used even if a download attribute is specified in HTML.
+
+The suggested filename above should be "PASS.txt" and the download should succeed.
+
+Link with download attribute.
Added: releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html (0 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/anchor-download-attribute-content-disposition.html 2017-05-08 10:38:31 UTC (rev 216379)
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script type='text/_javascript_'>
+if (window.testRunner) {
+ testRunner.dumpAsText();
+ testRunner.waitUntilDone();
+}
+</script>
+</head>
+<body>
+<p>Tests that the filename from the Content-Disposition header is used even if a download attribute is specified in HTML.</p>
+<p>The suggested filename above should be "PASS.txt" and the download should succeed.</p>
+<a id="download-url" href="" download="FAIL.txt">Link with download attribute.</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()
+{
+ var link = document.getElementById("download-url");
+ click(link);
+}
+runTest();
+</script>
+</body>
+</html>
Added: releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/resources/content-disposition-pass.php (0 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/resources/content-disposition-pass.php (rev 0)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/download/resources/content-disposition-pass.php 2017-05-08 10:38:31 UTC (rev 216379)
@@ -0,0 +1,6 @@
+<?php
+header("Content-Disposition: Attachment; filename=PASS.txt");
+header("Content-Type: text/plain");
+?>
+
+Test file content.
Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/http/tests/security/anchor-download-allow-sameorigin.html 2017-05-08 10:38:31 UTC (rev 216379)
@@ -10,7 +10,7 @@
<body>
<p>
Tests that a suggested filename on a download attribute is allowed if
-<a id="dl" href="" download="foo.pdf">the link</a> is in the same origin.
+<a id="dl" href="" download="foo.pdf">the link</a> is in the same origin.
<p>
The suggested filename at the top should be foo.pdf.
<script>
Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/platform/mac-wk1/TestExpectations (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/platform/mac-wk1/TestExpectations 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/platform/mac-wk1/TestExpectations 2017-05-08 10:38:31 UTC (rev 216379)
@@ -213,6 +213,7 @@
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-no-extension.html [ Skip ]
+webkit.org/b/156069 http/tests/download/anchor-download-attribute-content-disposition.html [ Skip ]
webkit.org/b/156069 http/tests/download/anchor-download-no-extension.html [ Skip ]
webkit.org/b/156069 http/tests/download/area-download.html [ Skip ]
webkit.org/b/156069 http/tests/security/anchor-download-allow-blob.html [ Skip ]
Modified: releases/WebKitGTK/webkit-2.16/LayoutTests/platform/win/TestExpectations (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/LayoutTests/platform/win/TestExpectations 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/LayoutTests/platform/win/TestExpectations 2017-05-08 10:38:31 UTC (rev 216379)
@@ -446,6 +446,7 @@
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-no-extension.html [ Skip ]
+http/tests/download/anchor-download-attribute-content-disposition.html [ Skip ]
http/tests/download/anchor-download-no-extension.html [ Skip ]
http/tests/download/area-download.html [ Skip ]
http/tests/security/anchor-download-allow-data.html [ Skip ]
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/ChangeLog 2017-05-08 10:38:31 UTC (rev 216379)
@@ -1,3 +1,20 @@
+2017-04-25 Chris Dumez <[email protected]>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ Add isAttachmentWithFilename() utility method to ResourceResponse to implement:
+ - https://html.spec.whatwg.org/#as-a-download (Step 2)
+
+ Test: http/tests/download/anchor-download-attribute-content-disposition.html
+
+ * platform/network/ResourceResponseBase.cpp:
+ (WebCore::ResourceResponseBase::isAttachmentWithFilename):
+ * platform/network/ResourceResponseBase.h:
+
2017-04-21 Zalan Bujtas <[email protected]>
REGRESSION(r205374): <li> content inside <ul> should mid-word wrap when word-break: break-word is present.
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.cpp (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.cpp 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.cpp 2017-05-08 10:38:31 UTC (rev 216379)
@@ -545,6 +545,21 @@
return equalLettersIgnoringASCIICase(value.left(value.find(';')).stripWhiteSpace(), "attachment");
}
+bool ResourceResponseBase::isAttachmentWithFilename() const
+{
+ lazyInit(AllFields);
+
+ String contentDisposition = m_httpHeaderFields.get(HTTPHeaderName::ContentDisposition);
+ if (contentDisposition.isNull())
+ return false;
+
+ if (!equalLettersIgnoringASCIICase(contentDisposition.left(contentDisposition.find(';')).stripWhiteSpace(), "attachment"))
+ return false;
+
+ String filename = filenameFromHTTPContentDisposition(contentDisposition);
+ return !filename.isNull();
+}
+
ResourceResponseBase::Source ResourceResponseBase::source() const
{
lazyInit(AllFields);
Modified: releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.h (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.h 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebCore/platform/network/ResourceResponseBase.h 2017-05-08 10:38:31 UTC (rev 216379)
@@ -113,6 +113,7 @@
bool isMultipart() const { return mimeType() == "multipart/x-mixed-replace"; }
WEBCORE_EXPORT bool isAttachment() const;
+ WEBCORE_EXPORT bool isAttachmentWithFilename() const;
WEBCORE_EXPORT String suggestedFilename() const;
WEBCORE_EXPORT void includeCertificateInfo() const;
Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/ChangeLog 2017-05-08 10:38:31 UTC (rev 216379)
@@ -1,3 +1,24 @@
+2017-04-25 Chris Dumez <[email protected]>
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML
+ https://bugs.webkit.org/show_bug.cgi?id=171239
+ <rdar://problem/31789855>
+
+ Reviewed by Alex Christensen.
+
+ Content-Disposition header filename is ignored when 'download' attribute is specified in HTML.
+ This is not as per HTML specification:
+ - https://html.spec.whatwg.org/#as-a-download (Step 2)
+
+ Content-Disposition header filename is supposed to override the value of the download attribute.
+
+ Firefox and Chrome follow the specification.
+
+ * NetworkProcess/NetworkProcess.cpp:
+ (WebKit::NetworkProcess::findPendingDownloadLocation):
+ * UIProcess/Downloads/DownloadProxy.cpp:
+ (WebKit::DownloadProxy::didReceiveResponse):
+
2017-04-20 Alex Christensen <[email protected]>
Fix assertions in webProcessProxyFromConnection
Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/NetworkProcess/NetworkProcess.cpp (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/NetworkProcess/NetworkProcess.cpp 2017-05-08 10:38:31 UTC (rev 216379)
@@ -511,7 +511,12 @@
downloadProxyConnection()->send(Messages::DownloadProxy::DidReceiveResponse(response), destinationID);
downloadManager().willDecidePendingDownloadDestination(networkDataTask, WTFMove(completionHandler));
- String suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(networkDataTask.suggestedFilename(), response.mimeType());
+
+ // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header
+ // should override the suggested filename from the download attribute.
+ String suggestedFilename = response.isAttachmentWithFilename() ? response.suggestedFilename() : networkDataTask.suggestedFilename();
+ suggestedFilename = MIMETypeRegistry::appendFileExtensionIfNecessary(suggestedFilename, response.mimeType());
+
downloadProxyConnection()->send(Messages::DownloadProxy::DecideDestinationWithSuggestedFilenameAsync(networkDataTask.pendingDownloadID(), suggestedFilename), destinationID);
}
#endif
Modified: releases/WebKitGTK/webkit-2.16/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (216378 => 216379)
--- releases/WebKitGTK/webkit-2.16/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-05-08 10:23:19 UTC (rev 216378)
+++ releases/WebKitGTK/webkit-2.16/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp 2017-05-08 10:38:31 UTC (rev 216379)
@@ -154,6 +154,13 @@
if (!m_processPool)
return;
+#if !USE(NETWORK_SESSION)
+ // As per https://html.spec.whatwg.org/#as-a-download (step 2), the filename from the Content-Disposition header
+ // should override the suggested filename from the download attribute.
+ if (!m_suggestedFilename.isNull() && response.isAttachmentWithFilename())
+ m_suggestedFilename = String();
+#endif
+
m_processPool->downloadClient().didReceiveResponse(m_processPool.get(), this, response);
}