Title: [211636] trunk
Revision
211636
Author
achristen...@apple.com
Date
2017-02-03 09:21:43 -0800 (Fri, 03 Feb 2017)

Log Message

Align URL setters with spec for URLs that cannot be a base URL
https://bugs.webkit.org/show_bug.cgi?id=167783

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/url/url-setters-expected.txt:

Source/WebCore:

Setting things like credentials on mailto URLs doesn't make sense.
It's forbidden by the spec.

Covered by newly passing web platform tests.

* html/URLUtils.h:
(WebCore::URLUtils<T>::setUsername):
(WebCore::URLUtils<T>::setPassword):
(WebCore::URLUtils<T>::setHost):
(WebCore::URLUtils<T>::setHostname):
(WebCore::URLUtils<T>::setPort):
(WebCore::URLUtils<T>::setPathname):
* platform/URL.cpp:
(WebCore::URL::serialize):
* platform/URL.h:
(WebCore::URL::cannotBeABaseURL):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (211635 => 211636)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2017-02-03 17:21:43 UTC (rev 211636)
@@ -1,3 +1,12 @@
+2017-02-03  Alex Christensen  <achristen...@webkit.org>
+
+        Align URL setters with spec for URLs that cannot be a base URL
+        https://bugs.webkit.org/show_bug.cgi?id=167783
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/url/url-setters-expected.txt:
+
 2017-02-02  Alex Christensen  <achristen...@webkit.org>
 
         Update URL web platform tests

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt (211635 => 211636)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2017-02-03 17:21:43 UTC (rev 211636)
@@ -63,9 +63,9 @@
 PASS URL: Setting <unix:/run/foo.socket>.username = 'me' No host means no username 
 FAIL <a>: Setting <unix:/run/foo.socket>.username = 'me' No host means no username assert_equals: expected "unix:/run/foo.socket" but got "unix://me@/run/foo.socket"
 FAIL <area>: Setting <unix:/run/foo.socket>.username = 'me' No host means no username assert_equals: expected "unix:/run/foo.socket" but got "unix://me@/run/foo.socket"
-FAIL URL: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username assert_equals: expected "mailto:y...@example.net" but got "mailto://me%40...@example.net"
-FAIL <a>: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username assert_equals: expected "mailto:y...@example.net" but got "mailto://me%40...@example.net"
-FAIL <area>: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username assert_equals: expected "mailto:y...@example.net" but got "mailto://me%40...@example.net"
+PASS URL: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username 
+PASS <a>: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username 
+PASS <area>: Setting <mailto:y...@example.net>.username = 'me' Cannot-be-a-base means no username 
 PASS URL: Setting <http://example.net>.username = 'me' 
 PASS <a>: Setting <http://example.net>.username = 'me' 
 PASS <area>: Setting <http://example.net>.username = 'me' 
@@ -93,9 +93,9 @@
 PASS URL: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password 
 FAIL <a>: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password assert_equals: expected "unix:/run/foo.socket" but got "unix://:secret@/run/foo.socket"
 FAIL <area>: Setting <unix:/run/foo.socket>.password = 'secret' No host means no password assert_equals: expected "unix:/run/foo.socket" but got "unix://:secret@/run/foo.socket"
-FAIL URL: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password assert_equals: expected "mailto:m...@example.net" but got "mailto://:secret%4...@example.net"
-FAIL <a>: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password assert_equals: expected "mailto:m...@example.net" but got "mailto://:secret%4...@example.net"
-FAIL <area>: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password assert_equals: expected "mailto:m...@example.net" but got "mailto://:secret%4...@example.net"
+PASS URL: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password 
+PASS <a>: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password 
+PASS <area>: Setting <mailto:m...@example.net>.password = 'secret' Cannot-be-a-base means no password 
 PASS URL: Setting <http://example.net>.password = 'secret' 
 PASS <a>: Setting <http://example.net>.password = 'secret' 
 PASS <area>: Setting <http://example.net>.password = 'secret' 

Modified: trunk/Source/WebCore/ChangeLog (211635 => 211636)


--- trunk/Source/WebCore/ChangeLog	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/Source/WebCore/ChangeLog	2017-02-03 17:21:43 UTC (rev 211636)
@@ -1,3 +1,27 @@
+2017-02-03  Alex Christensen  <achristen...@webkit.org>
+
+        Align URL setters with spec for URLs that cannot be a base URL
+        https://bugs.webkit.org/show_bug.cgi?id=167783
+
+        Reviewed by Chris Dumez.
+
+        Setting things like credentials on mailto URLs doesn't make sense.
+        It's forbidden by the spec.
+
+        Covered by newly passing web platform tests.
+
+        * html/URLUtils.h:
+        (WebCore::URLUtils<T>::setUsername):
+        (WebCore::URLUtils<T>::setPassword):
+        (WebCore::URLUtils<T>::setHost):
+        (WebCore::URLUtils<T>::setHostname):
+        (WebCore::URLUtils<T>::setPort):
+        (WebCore::URLUtils<T>::setPathname):
+        * platform/URL.cpp:
+        (WebCore::URL::serialize):
+        * platform/URL.h:
+        (WebCore::URL::cannotBeABaseURL):
+
 2017-02-03  Eric Carlson  <eric.carl...@apple.com>
 
         [Mac] Add classes to manage audio samples

Modified: trunk/Source/WebCore/html/URLUtils.h (211635 => 211636)


--- trunk/Source/WebCore/html/URLUtils.h	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/Source/WebCore/html/URLUtils.h	2017-02-03 17:21:43 UTC (rev 211636)
@@ -104,6 +104,8 @@
 void URLUtils<T>::setUsername(const String& user)
 {
     URL url = ""
+    if (url.cannotBeABaseURL())
+        return;
     url.setUser(user);
     setHref(url);
 }
@@ -118,6 +120,8 @@
 void URLUtils<T>::setPassword(const String& pass)
 {
     URL url = ""
+    if (url.cannotBeABaseURL())
+        return;
     url.setPass(pass);
     setHref(url);
 }
@@ -143,6 +147,8 @@
     if (value.isEmpty())
         return;
     URL url = ""
+    if (url.cannotBeABaseURL())
+        return;
     if (!url.canSetHostOrPort())
         return;
 
@@ -190,6 +196,8 @@
         return;
 
     URL url = ""
+    if (url.cannotBeABaseURL())
+        return;
     if (!url.canSetHostOrPort())
         return;
 
@@ -210,6 +218,8 @@
 void URLUtils<T>::setPort(const String& value)
 {
     URL url = ""
+    if (url.cannotBeABaseURL() || url.protocolIs("file"))
+        return;
     if (!url.canSetHostOrPort())
         return;
 
@@ -236,6 +246,8 @@
 void URLUtils<T>::setPathname(const String& value)
 {
     URL url = ""
+    if (url.cannotBeABaseURL())
+        return;
     if (!url.canSetPathname())
         return;
 

Modified: trunk/Source/WebCore/platform/URL.cpp (211635 => 211636)


--- trunk/Source/WebCore/platform/URL.cpp	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/Source/WebCore/platform/URL.cpp	2017-02-03 17:21:43 UTC (rev 211636)
@@ -1377,7 +1377,7 @@
         }
     } else if (protocolIs("file"))
         urlBuilder.appendLiteral("//");
-    if (cannotBeABaseURL(*this))
+    if (WebCore::cannotBeABaseURL(*this))
         urlBuilder.append(m_string, m_portEnd, m_pathEnd - m_portEnd);
     else {
         urlBuilder.appendLiteral("/");

Modified: trunk/Source/WebCore/platform/URL.h (211635 => 211636)


--- trunk/Source/WebCore/platform/URL.h	2017-02-03 17:21:21 UTC (rev 211635)
+++ trunk/Source/WebCore/platform/URL.h	2017-02-03 17:21:43 UTC (rev 211636)
@@ -136,6 +136,7 @@
     bool protocolIsInHTTPFamily() const;
     WEBCORE_EXPORT bool isLocalFile() const;
     bool isBlankURL() const;
+    bool cannotBeABaseURL() const { return m_cannotBeABaseURL; }
 
     WEBCORE_EXPORT bool setProtocol(const String&);
     void setHost(const String&);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to