Skip to content

Commit

Permalink
Fix pathname encoding for isolated '.' and '..' values. (#156)
Browse files Browse the repository at this point in the history
This commit fixes an issue where '.' and '..' could be incorrectly
removed from a pathname during parsing.  This would happen in cases
where the encoding callback saw the '.' or '..' individually without
surrounding characters.  This would cause the algorithm to encode
them as '/.' or '/..' which the URL parser collapses to just '/'.

To avoid this behavior we explicitly check for '.' and '..' values
so they can be immediately returned without encoding.
  • Loading branch information
wanderview committed Jan 18, 2022
1 parent 7336960 commit defa04d
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion spec.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1618,7 +1618,13 @@ To <dfn>convert a modifier to a string</dfn> given a [=part/modifier=] |modifier
<div algorithm>
To <dfn>canonicalize a pathname</dfn> given a string |value|:

1. If |value| is the empty string, return |value|.
1. If |value| is one of the following:
<ul>
<li>the empty string; or</li>
<li>"`.`"; or</li>
<li>"`..`"
</ul>
then return |value|.
1. Let |dummyURL| be a new [=URL record=].
1. Let |parseResult| be the result of running [=basic URL parser=] given |value| with |dummyURL| as </i>[=basic URL parser/url=]</i> and [=path start state=] as <i>[=basic URL parser/state override=]</i>.
1. If |parseResult| is failure, then throw a {{TypeError}}.
Expand Down

0 comments on commit defa04d

Please sign in to comment.