This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.

Bug 21210 - Changes to make "." and ".." parse properly
Summary: Changes to make "." and ".." parse properly
Status: RESOLVED FIXED
Alias: None
Product: WHATWG
Classification: Unclassified
Component: URL (show other bugs)
Version: unspecified
Hardware: PC Windows NT
: P2 normal
Target Milestone: Unsorted
Assignee: Anne
QA Contact: sideshowbarker+urlspec
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-03-07 11:02 UTC by Peter Occil
Modified: 2013-03-07 14:27 UTC (History)
1 user (show)

See Also:


Attachments

Description Peter Occil 2013-03-07 11:02:12 UTC
http://url.spec.whatwg.org/#relative-path-start-state

[[
relative path start state
1. If c is "\", parse error.

2. Set state to relative path state and if c is neither "/" nor "\", decrease pointer by one.

relative path state
1. If either c is one of EOF code point, "/", and "\", or state override is not given and c is one of "?" and "#", run these substeps:

  1. If buffer is ".." and c is one of EOF code point, "/", and "\", pop url's path, if non-empty, and then append the empty string to it.

  2. Otherwise, if buffer is "..", pop url's path, if non-empty.

  3. Otherwise, if buffer is "." and c is one of EOF code point, "/", and "\", append an empty string to url's path.

  4. Otherwise, if buffer is not ".", run these subsubsteps:
]]

I suggest the following changes to that text:

-----------------------
relative path start state

2. Set state to relative path state and decrease pointer by one.
-----
relative path state

1. [...]

   1. If buffer is "..", pop url's path, if non-empty, then if c 
       is neither "/" nor "\", append the empty string to url's path.

   2.  Otherwise, if buffer is "." and c is neither "/", nor "\", append an 
        empty string to url's path.

   3.  Otherwise, if buffer is neither ".." nor ".", run these subsubsteps [...]
-----------------------

With these changes, I believe the following test cases will pass:
   
/x/w/../y -> /x/y
/x/w/.. -> /x/
/x/w/..#z -> /x/#z

////../.. -> //
/x/x/x/../.. -> /x/

/x/../y -> /y
/x/.. -> /
/x/..#z -> /#z

/../y -> /y
/.. -> /
/..#z -> /#z

/x/./y -> /x/y
/x/. -> /x/
/x/.#z -> /x/#z
/./y -> /y
/. -> /
/.#z -> /#z
Comment 1 Peter Occil 2013-03-07 13:08:24 UTC
I take back the changes to the relative path start state. The rest of my message still stands.
Comment 2 Anne 2013-03-07 14:27:03 UTC
So the \ and / should've been ? and #. But your proposed text is shorter so I've gone with that.

Also added the missing parse error for \.

I did not add the additional check for ".." as that's redundant with the usage of otherwise.

https://github.com/whatwg/url/commit/b3fd683a3907e379ffc1469beee79d8e469b61a8