<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[206478] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/206478">206478</a></dd>
<dt>Author</dt> <dd>cdumez@apple.com</dd>
<dt>Date</dt> <dd>2016-09-27 17:37:01 -0700 (Tue, 27 Sep 2016)</dd>
</dl>

<h3>Log Message</h3>
<pre>&lt;a download&gt; does not honor the same-origin requirement
https://bugs.webkit.org/show_bug.cgi?id=156100

Reviewed by Alex Christensen.

Source/WebCore:

We now completely ignore the &quot;download&quot; attribute on anchors if the
href URL is cross-origin. We therefore navigate to the URL instead
of forcefully downloading it in this case and leave it up to the server
to give us the right headers if it should be downloaded. This is
conservative and matches Firefox.

Chrome and the HTML specification ignore only the suggested filename
if the URL is cross-origin but still download the file.

No new tests, updated existing test.

* html/HTMLAnchorElement.cpp:
(WebCore::HTMLAnchorElement::handleClick):

LayoutTests:

Update existing cross origin test as it expected the suggested filename to
be ignored but the file to still be downloaded (Chrome behavior) instead
of the download attribute to be completely ignored and therefore navigate
(Firefox behavior).

* TestExpectations:
* http/tests/resources/pass-notify-done.html: Added.
* http/tests/security/anchor-download-block-crossorigin-expected.txt:
* http/tests/security/anchor-download-block-crossorigin.html:</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsTestExpectations">trunk/LayoutTests/TestExpectations</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginexpectedtxt">trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt</a></li>
<li><a href="#trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginhtml">trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorehtmlHTMLAnchorElementcpp">trunk/Source/WebCore/html/HTMLAnchorElement.cpp</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkLayoutTestshttptestsresourcespassnotifydonehtml">trunk/LayoutTests/http/tests/resources/pass-notify-done.html</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/LayoutTests/ChangeLog        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -1,3 +1,20 @@
</span><ins>+2016-09-27  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        &lt;a download&gt; does not honor the same-origin requirement
+        https://bugs.webkit.org/show_bug.cgi?id=156100
+
+        Reviewed by Alex Christensen.
+
+        Update existing cross origin test as it expected the suggested filename to
+        be ignored but the file to still be downloaded (Chrome behavior) instead
+        of the download attribute to be completely ignored and therefore navigate
+        (Firefox behavior).
+
+        * TestExpectations:
+        * http/tests/resources/pass-notify-done.html: Added.
+        * http/tests/security/anchor-download-block-crossorigin-expected.txt:
+        * http/tests/security/anchor-download-block-crossorigin.html:
+
</ins><span class="cx"> 2016-09-27  Ryan Haddad  &lt;ryanhaddad@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Marking http/tests/xmlhttprequest/onabort-response-getters.html as failing on Sierra.
</span></span></pre></div>
<a id="trunkLayoutTestsTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/TestExpectations (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/TestExpectations        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/LayoutTests/TestExpectations        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -898,9 +898,6 @@
</span><span class="cx"> fast/scrolling/rtl-scrollbars-alternate-iframe-body-dir-attr-does-not-update-scrollbar-placement.html [ ImageOnlyFailure ]
</span><span class="cx"> fast/scrolling/rtl-scrollbars-animation-property.html [ Failure ]
</span><span class="cx"> 
</span><del>-# &lt;a download&gt; does not honor cross-origin restrictions
-webkit.org/b/156100 http/tests/security/anchor-download-block-crossorigin.html [ Failure ]
-
</del><span class="cx"> webkit.org/b/157849 fast/frames/crash-during-iframe-load-stop.html [ Pass Timeout ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/158085 http/tests/css/shared-stylesheet-mutation.html [ Pass Failure ]
</span></span></pre></div>
<a id="trunkLayoutTestshttptestsresourcespassnotifydonehtml"></a>
<div class="addfile"><h4>Added: trunk/LayoutTests/http/tests/resources/pass-notify-done.html (0 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/resources/pass-notify-done.html                                (rev 0)
+++ trunk/LayoutTests/http/tests/resources/pass-notify-done.html        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -0,0 +1,7 @@
</span><ins>+&lt;script&gt;
+function loaded() {
+    if (window.testRunner)
+        setTimeout(&quot;testRunner.notifyDone();&quot;, 0);
+}
+&lt;/script&gt;
+&lt;body onload=&quot;loaded();&quot;&gt;PASS&lt;/body&gt;
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin-expected.txt        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -1,4 +1 @@
</span><del>-Downloading URL with suggested filename &quot;&quot;
-Tests that a suggested filename on a download attribute is ignored if the link is cross origin.
-
-The suggested filename at the top should be empty.
</del><ins>+PASS
</ins></span></pre></div>
<a id="trunkLayoutTestshttptestssecurityanchordownloadblockcrossoriginhtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/LayoutTests/http/tests/security/anchor-download-block-crossorigin.html        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -4,15 +4,15 @@
</span><span class="cx"> &lt;script src=&quot;../../../resources/js-test-pre.js&quot;&gt;&lt;/script&gt;
</span><span class="cx"> &lt;script&gt;
</span><span class="cx">     if (window.testRunner)
</span><del>-        testRunner.waitUntilDownloadFinished();
</del><ins>+        testRunner.waitUntilDone();
</ins><span class="cx"> &lt;/script&gt;
</span><span class="cx"> &lt;/head&gt;
</span><span class="cx"> &lt;body&gt;
</span><span class="cx"> &lt;p&gt;
</span><del>-Tests that a suggested filename on a download attribute is ignored if 
-&lt;a id=&quot;dl&quot; href=&quot;http://localhost:8080/security/resources/attachment.php&quot; download=&quot;foo.pdf&quot;&gt;the link&lt;/a&gt; is cross origin.
</del><ins>+Tests that the download attribute is ignored if 
+&lt;a id=&quot;dl&quot; href=&quot;http://localhost:8080/resources/pass-notify-done.html&quot; download=&quot;FAIL.pdf&quot;&gt;the link&lt;/a&gt; is cross origin.
</ins><span class="cx"> &lt;p&gt;
</span><del>-The suggested filename at the top should be empty.
</del><ins>+It should navigate instead of downloading the file.
</ins><span class="cx"> &lt;script&gt;
</span><span class="cx">     function click(elmt)
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/Source/WebCore/ChangeLog        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -1,3 +1,24 @@
</span><ins>+2016-09-27  Chris Dumez  &lt;cdumez@apple.com&gt;
+
+        &lt;a download&gt; does not honor the same-origin requirement
+        https://bugs.webkit.org/show_bug.cgi?id=156100
+
+        Reviewed by Alex Christensen.
+
+        We now completely ignore the &quot;download&quot; attribute on anchors if the
+        href URL is cross-origin. We therefore navigate to the URL instead
+        of forcefully downloading it in this case and leave it up to the server
+        to give us the right headers if it should be downloaded. This is
+        conservative and matches Firefox.
+
+        Chrome and the HTML specification ignore only the suggested filename
+        if the URL is cross-origin but still download the file.
+
+        No new tests, updated existing test.
+
+        * html/HTMLAnchorElement.cpp:
+        (WebCore::HTMLAnchorElement::handleClick):
+
</ins><span class="cx"> 2016-09-27  Alex Christensen  &lt;achristensen@webkit.org&gt;
</span><span class="cx"> 
</span><span class="cx">         URLParser: Handle windows drive letters after two slashes in relative URLs according to spec
</span></span></pre></div>
<a id="trunkSourceWebCorehtmlHTMLAnchorElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/html/HTMLAnchorElement.cpp (206477 => 206478)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-09-28 00:31:44 UTC (rev 206477)
+++ trunk/Source/WebCore/html/HTMLAnchorElement.cpp        2016-09-28 00:37:01 UTC (rev 206478)
</span><span class="lines">@@ -363,12 +363,15 @@
</span><span class="cx">     StringBuilder url;
</span><span class="cx">     url.append(stripLeadingAndTrailingHTMLSpaces(attributeWithoutSynchronization(hrefAttr)));
</span><span class="cx">     appendServerMapMousePosition(url, event);
</span><del>-    URL kurl = document().completeURL(url.toString());
</del><ins>+    URL completedURL = document().completeURL(url.toString());
</ins><span class="cx"> 
</span><span class="cx">     auto downloadAttribute = nullAtom;
</span><span class="cx"> #if ENABLE(DOWNLOAD_ATTRIBUTE)
</span><span class="cx">     if (RuntimeEnabledFeatures::sharedFeatures().downloadAttributeEnabled()) {
</span><del>-        downloadAttribute = attributeWithoutSynchronization(downloadAttr);
</del><ins>+        // Ignore the download attribute completely if the href URL is cross origin.
+        bool isSameOrigin = completedURL.protocolIsData() || document().securityOrigin()-&gt;canRequest(completedURL);
+        if (isSameOrigin)
+            downloadAttribute = attributeWithoutSynchronization(downloadAttr);
</ins><span class="cx">         // If the a element has a download attribute and the algorithm is not triggered by user activation
</span><span class="cx">         // then abort these steps.
</span><span class="cx">         // https://html.spec.whatwg.org/#the-a-element:triggered-by-user-activation
</span><span class="lines">@@ -377,9 +380,9 @@
</span><span class="cx">     }
</span><span class="cx"> #endif
</span><span class="cx"> 
</span><del>-    frame-&gt;loader().urlSelected(kurl, target(), &amp;event, LockHistory::No, LockBackForwardList::No, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), downloadAttribute);
</del><ins>+    frame-&gt;loader().urlSelected(completedURL, target(), &amp;event, LockHistory::No, LockBackForwardList::No, hasRel(RelationNoReferrer) ? NeverSendReferrer : MaybeSendReferrer, document().shouldOpenExternalURLsPolicyToPropagate(), downloadAttribute);
</ins><span class="cx"> 
</span><del>-    sendPings(kurl);
</del><ins>+    sendPings(completedURL);
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> HTMLAnchorElement::EventType HTMLAnchorElement::eventType(Event&amp; event)
</span></span></pre>
</div>
</div>

</body>
</html>