Skip to content

Commit 83adf0c

Browse files
authored
Non-special URLs were not idempotent
Adjust the URL serializer so it does not output something which during the next parse operation would yield a host. whatwg-url: jsdom/whatwg-url#148. Tests: web-platform-tests/wpt#25113. Fixes #415.
1 parent cf05fda commit 83adf0c

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

url.bs

+19-4
Original file line numberDiff line numberDiff line change
@@ -2542,8 +2542,22 @@ then runs these steps, returning an <a>ASCII string</a>:
25422542
<li><p>If <var>url</var>'s <a for=url>cannot-be-a-base-URL flag</a> is set, append <var>url</var>'s
25432543
<a for=url>path</a>[0] to <var>output</var>.
25442544

2545-
<li><p>Otherwise, then <a for=list>for each</a> string in <var>url</var>'s <a for=url>path</a>,
2546-
append U+002F (/) followed by the string to <var>output</var>.
2545+
<li>
2546+
<p>Otherwise:
2547+
2548+
<ol>
2549+
<li><p>If <var>url</var>'s <a for=url>host</a> is null, <var>url</var>'s <a for=url>path</a>'s
2550+
<a for=list>size</a> is greater than 1, and <var>url</var>'s <a for=url>path</a>[0] is the empty
2551+
string, then append U+002F (/) followed by U+002E (.) to <var>output</var>.
2552+
2553+
<li><p><a for=list>For each</a> <var>segment</var> of <var>url</var>'s <a for=url>path</a>:
2554+
append U+002F (/) followed by <var>segment</var> to <var>output</var>.
2555+
</ol>
2556+
2557+
<p class=note>This prevents <code>web+demo:/.//not-a-host/</code> or
2558+
<code>web+demo:/path/..//not-a-host/</code>, when <a lt="URL parser">parsed</a> and then
2559+
<a lt="URL serializer">serialized</a>, from ending up as <code>web+demo://not-a-host/</code> (they
2560+
end up as <code>web+demo:/.//not-a-host/</code>).
25472561

25482562
<li><p>If <var>url</var>'s <a for=url>query</a> is non-null, append
25492563
U+003F (?), followed by <var>url</var>'s <a for=url>query</a>, to
@@ -3480,8 +3494,9 @@ Valentin Gosu,
34803494
Vyacheslav Matva,
34813495
Wei Wang,
34823496
山岸和利 (Yamagishi Kazutoshi),
3483-
Yongsheng Zhang, and
3484-
成瀬ゆい (Yui Naruse)
3497+
Yongsheng Zhang,
3498+
成瀬ゆい (Yui Naruse), and
3499+
zealousidealroll
34853500
for being awesome!
34863501

34873502
<p>This standard is written by

0 commit comments

Comments
 (0)