Title: [251422] trunk
Revision
251422
Author
commit-qu...@webkit.org
Date
2019-10-22 01:20:34 -0700 (Tue, 22 Oct 2019)

Log Message

https://bugs.webkit.org/show_bug.cgi?id=169667
URL: protocol setter needs to be more restrictive around file

Patch by Rob Buis <rb...@igalia.com> on 2019-10-22
Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Update test result.

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

Source/WTF:

Restrict setting protocol to "file" as indictaed in the spec [1].

Test: imported/w3c/web-platform-tests/url/url-setters.html

[1] https://url.spec.whatwg.org/#scheme-state steps 2.1.3 and 2.1.4.

* wtf/URL.cpp:
(WTF::URL::setProtocol):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (251421 => 251422)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2019-10-22 07:22:19 UTC (rev 251421)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2019-10-22 08:20:34 UTC (rev 251422)
@@ -1,3 +1,14 @@
+2019-10-22  Rob Buis  <rb...@igalia.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=169667
+        URL: protocol setter needs to be more restrictive around file
+
+        Reviewed by Alex Christensen.
+
+        Update test result.
+
+        * web-platform-tests/url/url-setters-expected.txt:
+
 2019-10-21  Myles C. Maxfield  <mmaxfi...@apple.com>
 
         Update Web Platform Test css/css-lists/content-property/marker-text-matches-armenian.html

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2019-10-22 07:22:19 UTC (rev 251421)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-expected.txt	2019-10-22 08:20:34 UTC (rev 251422)
@@ -31,23 +31,23 @@
 PASS <a>: Setting <a://example.net>.protocol = 'bé' Non-ASCII is rejected 
 PASS <area>: Setting <a://example.net>.protocol = 'bé' Non-ASCII is rejected 
 PASS URL: Setting <http://t...@example.net>.protocol = 'file' Can’t switch from URL containing username/password/port to file 
-FAIL <a>: Setting <http://t...@example.net>.protocol = 'file' Can’t switch from URL containing username/password/port to file assert_equals: expected "http://t...@example.net/" but got "file://t...@example.net/"
-FAIL <area>: Setting <http://t...@example.net>.protocol = 'file' Can’t switch from URL containing username/password/port to file assert_equals: expected "http://t...@example.net/" but got "file://t...@example.net/"
-FAIL URL: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "file://example.net:1234/"
-FAIL <a>: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "file://example.net:1234/"
-FAIL <area>: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "file://example.net:1234/"
+PASS <a>: Setting <http://t...@example.net>.protocol = 'file' Can’t switch from URL containing username/password/port to file 
+PASS <area>: Setting <http://t...@example.net>.protocol = 'file' Can’t switch from URL containing username/password/port to file 
+FAIL URL: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "gopher://example.net:1234"
+FAIL <a>: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "gopher://example.net:1234"
+FAIL <area>: Setting <gopher://example.net:1234>.protocol = 'file' assert_equals: expected "gopher://example.net:1234/" but got "gopher://example.net:1234"
 PASS URL: Setting <wss://x:x...@example.net:1234>.protocol = 'file' 
-FAIL <a>: Setting <wss://x:x...@example.net:1234>.protocol = 'file' assert_equals: expected "wss://x:x...@example.net:1234/" but got "file://x:x...@example.net:1234/"
-FAIL <area>: Setting <wss://x:x...@example.net:1234>.protocol = 'file' assert_equals: expected "wss://x:x...@example.net:1234/" but got "file://x:x...@example.net:1234/"
+PASS <a>: Setting <wss://x:x...@example.net:1234>.protocol = 'file' 
+PASS <area>: Setting <wss://x:x...@example.net:1234>.protocol = 'file' 
 PASS URL: Setting <file://localhost/>.protocol = 'http' Can’t switch from file URL with no host 
-FAIL <a>: Setting <file://localhost/>.protocol = 'http' Can’t switch from file URL with no host assert_equals: expected "file:///" but got "http:///"
-FAIL <area>: Setting <file://localhost/>.protocol = 'http' Can’t switch from file URL with no host assert_equals: expected "file:///" but got "http:///"
-FAIL URL: Setting <file:///test>.protocol = 'gopher' assert_equals: expected "file:///test" but got "gopher:///test"
-FAIL <a>: Setting <file:///test>.protocol = 'gopher' assert_equals: expected "file:///test" but got "gopher:///test"
-FAIL <area>: Setting <file:///test>.protocol = 'gopher' assert_equals: expected "file:///test" but got "gopher:///test"
+PASS <a>: Setting <file://localhost/>.protocol = 'http' Can’t switch from file URL with no host 
+PASS <area>: Setting <file://localhost/>.protocol = 'http' Can’t switch from file URL with no host 
+PASS URL: Setting <file:///test>.protocol = 'gopher' 
+PASS <a>: Setting <file:///test>.protocol = 'gopher' 
+PASS <area>: Setting <file:///test>.protocol = 'gopher' 
 PASS URL: Setting <file:>.protocol = 'wss' 
-FAIL <a>: Setting <file:>.protocol = 'wss' assert_equals: expected "file:///" but got "wss:///"
-FAIL <area>: Setting <file:>.protocol = 'wss' assert_equals: expected "file:///" but got "wss:///"
+PASS <a>: Setting <file:>.protocol = 'wss' 
+PASS <area>: Setting <file:>.protocol = 'wss' 
 FAIL URL: Setting <http://example.net>.protocol = 'b' Can’t switch from special scheme to non-special assert_equals: expected "http://example.net/" but got "b://example.net/"
 FAIL <a>: Setting <http://example.net>.protocol = 'b' Can’t switch from special scheme to non-special assert_equals: expected "http://example.net/" but got "b://example.net/"
 FAIL <area>: Setting <http://example.net>.protocol = 'b' Can’t switch from special scheme to non-special assert_equals: expected "http://example.net/" but got "b://example.net/"
@@ -70,8 +70,8 @@
 FAIL <a>: Setting <ssh://m...@example.net>.protocol = 'gopher' assert_equals: expected "ssh://m...@example.net" but got "gopher://m...@example.net"
 FAIL <area>: Setting <ssh://m...@example.net>.protocol = 'gopher' assert_equals: expected "ssh://m...@example.net" but got "gopher://m...@example.net"
 PASS URL: Setting <ssh://m...@example.net>.protocol = 'file' 
-FAIL <a>: Setting <ssh://m...@example.net>.protocol = 'file' assert_equals: expected "ssh://m...@example.net" but got "file://m...@example.net"
-FAIL <area>: Setting <ssh://m...@example.net>.protocol = 'file' assert_equals: expected "ssh://m...@example.net" but got "file://m...@example.net"
+PASS <a>: Setting <ssh://m...@example.net>.protocol = 'file' 
+PASS <area>: Setting <ssh://m...@example.net>.protocol = 'file' 
 FAIL URL: Setting <ssh://example.net>.protocol = 'file' assert_equals: expected "ssh://example.net" but got "file://example.net/"
 FAIL <a>: Setting <ssh://example.net>.protocol = 'file' assert_equals: expected "ssh://example.net" but got "file://example.net/"
 FAIL <area>: Setting <ssh://example.net>.protocol = 'file' assert_equals: expected "ssh://example.net" but got "file://example.net/"

Modified: trunk/Source/WTF/ChangeLog (251421 => 251422)


--- trunk/Source/WTF/ChangeLog	2019-10-22 07:22:19 UTC (rev 251421)
+++ trunk/Source/WTF/ChangeLog	2019-10-22 08:20:34 UTC (rev 251422)
@@ -1,3 +1,19 @@
+2019-10-22  Rob Buis  <rb...@igalia.com>
+
+        https://bugs.webkit.org/show_bug.cgi?id=169667
+        URL: protocol setter needs to be more restrictive around file
+
+        Reviewed by Alex Christensen.
+
+        Restrict setting protocol to "file" as indictaed in the spec [1].
+
+        Test: imported/w3c/web-platform-tests/url/url-setters.html
+
+        [1] https://url.spec.whatwg.org/#scheme-state steps 2.1.3 and 2.1.4.
+
+        * wtf/URL.cpp:
+        (WTF::URL::setProtocol):
+
 2019-10-21  Tim Horton  <timothy_hor...@apple.com>
 
         macCatalyst: Swipe navigation gestures do not work

Modified: trunk/Source/WTF/wtf/URL.cpp (251421 => 251422)


--- trunk/Source/WTF/wtf/URL.cpp	2019-10-22 07:22:19 UTC (rev 251421)
+++ trunk/Source/WTF/wtf/URL.cpp	2019-10-22 08:20:34 UTC (rev 251422)
@@ -378,6 +378,12 @@
         return true;
     }
 
+    if ((m_passwordEnd != m_userStart || port()) && *canonicalized == "file")
+        return true;
+
+    if (isLocalFile() && host().isEmpty())
+        return true;
+
     URLParser parser(makeString(*canonicalized, m_string.substring(m_schemeEnd)));
     *this = parser.result();
     return true;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to