From defa04dc806b7941f03d24b1f27b3c65e726aec2 Mon Sep 17 00:00:00 2001 From: Ben Kelly Date: Tue, 18 Jan 2022 20:08:33 +0000 Subject: [PATCH] Fix pathname encoding for isolated '.' and '..' values. (#156) 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. --- spec.bs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/spec.bs b/spec.bs index 85de9e8..2f13e84 100644 --- a/spec.bs +++ b/spec.bs @@ -1618,7 +1618,13 @@ To convert a modifier to a string given a [=part/modifier=] |modifier
To canonicalize a pathname given a string |value|: - 1. If |value| is the empty string, return |value|. + 1. If |value| is one of the following: + + 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 [=basic URL parser/url=] and [=path start state=] as [=basic URL parser/state override=]. 1. If |parseResult| is failure, then throw a {{TypeError}}.