Title: [279662] trunk
Revision
279662
Author
achristen...@apple.com
Date
2021-07-07 13:20:06 -0700 (Wed, 07 Jul 2021)

Log Message

URL path setter should add "./" before non-empty path and after empty host for URLs with non-special schemes
https://bugs.webkit.org/show_bug.cgi?id=227750

Reviewed by Chris Dumez.

LayoutTests/imported/w3c:

* web-platform-tests/url/url-setters-a-area.window-expected.txt:
* web-platform-tests/url/url-setters.any-expected.txt:
* web-platform-tests/url/url-setters.any.worker-expected.txt:

Source/WTF:

This is related to r267837 but in the path setter, too.
This helps preserve idempotence in parsed URLs.
This is an edge case that will rarely be hit in practice, but now the path setter matches the parser.

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

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (279661 => 279662)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-07-07 20:20:06 UTC (rev 279662)
@@ -1,3 +1,14 @@
+2021-07-07  Alex Christensen  <achristen...@webkit.org>
+
+        URL path setter should add "./" before non-empty path and after empty host for URLs with non-special schemes
+        https://bugs.webkit.org/show_bug.cgi?id=227750
+
+        Reviewed by Chris Dumez.
+
+        * web-platform-tests/url/url-setters-a-area.window-expected.txt:
+        * web-platform-tests/url/url-setters.any-expected.txt:
+        * web-platform-tests/url/url-setters.any.worker-expected.txt:
+
 2021-07-07  Chris Dumez  <cdu...@apple.com>
 
         REGRESSION (r279427): [ Mac wk2 ] imported/w3c/web-platform-tests/html/semantics/scripting-1/the-script-element/css-module/import-css-module-basic.html is a flaky failure

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt (279661 => 279662)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters-a-area.window-expected.txt	2021-07-07 20:20:06 UTC (rev 279662)
@@ -378,8 +378,8 @@
 PASS <area>: Setting <non-spec:/>.pathname = '/.//p' Serialize /. in path
 PASS <a>: Setting <non-spec:/>.pathname = '/..//p'
 PASS <area>: Setting <non-spec:/>.pathname = '/..//p'
-FAIL <a>: Setting <non-spec:/>.pathname = '//p' assert_equals: expected "non-spec:/.//p" but got "non-spec://p"
-FAIL <area>: Setting <non-spec:/>.pathname = '//p' assert_equals: expected "non-spec:/.//p" but got "non-spec://p"
+PASS <a>: Setting <non-spec:/>.pathname = '//p'
+PASS <area>: Setting <non-spec:/>.pathname = '//p'
 PASS <a>: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path
 PASS <area>: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path
 PASS <a>: Setting <https://example.net#nav>.search = 'lang=fr'

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


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any-expected.txt	2021-07-07 20:20:06 UTC (rev 279662)
@@ -189,7 +189,7 @@
 PASS URL: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes
 PASS URL: Setting <non-spec:/>.pathname = '/.//p' Serialize /. in path
 PASS URL: Setting <non-spec:/>.pathname = '/..//p'
-FAIL URL: Setting <non-spec:/>.pathname = '//p' assert_equals: expected "non-spec:/.//p" but got "non-spec://p"
+PASS URL: Setting <non-spec:/>.pathname = '//p'
 PASS URL: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path
 PASS URL: Setting <https://example.net#nav>.search = 'lang=fr'
 PASS URL: Setting <https://example.net?lang=en-US#nav>.search = 'lang=fr'

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt (279661 => 279662)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/url/url-setters.any.worker-expected.txt	2021-07-07 20:20:06 UTC (rev 279662)
@@ -189,7 +189,7 @@
 PASS URL: Setting <file:///unicorn>.pathname = '//monkey/..//' File URLs and (back)slashes
 PASS URL: Setting <non-spec:/>.pathname = '/.//p' Serialize /. in path
 PASS URL: Setting <non-spec:/>.pathname = '/..//p'
-FAIL URL: Setting <non-spec:/>.pathname = '//p' assert_equals: expected "non-spec:/.//p" but got "non-spec://p"
+PASS URL: Setting <non-spec:/>.pathname = '//p'
 PASS URL: Setting <non-spec:/.//>.pathname = 'p' Drop /. from path
 PASS URL: Setting <https://example.net#nav>.search = 'lang=fr'
 PASS URL: Setting <https://example.net?lang=en-US#nav>.search = 'lang=fr'

Modified: trunk/Source/WTF/ChangeLog (279661 => 279662)


--- trunk/Source/WTF/ChangeLog	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/Source/WTF/ChangeLog	2021-07-07 20:20:06 UTC (rev 279662)
@@ -1,3 +1,17 @@
+2021-07-07  Alex Christensen  <achristen...@webkit.org>
+
+        URL path setter should add "./" before non-empty path and after empty host for URLs with non-special schemes
+        https://bugs.webkit.org/show_bug.cgi?id=227750
+
+        Reviewed by Chris Dumez.
+
+        This is related to r267837 but in the path setter, too.
+        This helps preserve idempotence in parsed URLs.
+        This is an edge case that will rarely be hit in practice, but now the path setter matches the parser.
+
+        * wtf/URL.cpp:
+        (WTF::URL::setPath):
+
 2021-07-07  Christopher Reid  <chris.r...@sony.com>
 
         [PlayStation] Don't assume 4KB block size when estimating Network Cache disk usage

Modified: trunk/Source/WTF/wtf/URL.cpp (279661 => 279662)


--- trunk/Source/WTF/wtf/URL.cpp	2021-07-07 19:57:03 UTC (rev 279661)
+++ trunk/Source/WTF/wtf/URL.cpp	2021-07-07 20:20:06 UTC (rev 279662)
@@ -683,6 +683,7 @@
     parse(makeString(
         StringView(m_string).left(pathStart()),
         path.startsWith('/') || (path.startsWith('\\') && (hasSpecialScheme() || protocolIs("file"))) ? "" : "/",
+        !hasSpecialScheme() && host().isEmpty() && path.startsWith("//") && path.length() > 2 ? "/." : "",
         escapePathWithoutCopying(path),
         StringView(m_string).substring(m_pathEnd)
     ));
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to