You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This result is incorrect; the standardized path should actually be "//blow".
The first ".." component is discarded since it is at the start of the path and can't pop anything
The path then starts with "///..", which is 2 empty components and a ".." component. The ".." pops one of the empties, leaving one remaining empty component
Finally, the "/blow" component should be added (including its leading slash)
The older RFCs which URL conforms to don't typically specify how ".." components should be resolved in an absolute URL, so it's unclear which behaviour Foundation is attempting to implement, but they do define how those should work when resolving a relative URL:
> The pseudocode also refers to a "remove_dot_segments" routine for
interpreting and removing the special "." and ".." complete path
segments from a referenced path. This is done after the path is
extracted from a reference, whether or not the path was relative, in
order to remove any invalid or extraneous dot-segments prior to
forming the target URI.
Perhaps this is what Foundation is attempting to implement?
All of these references appear to confirm my belief that Foundation is in error, and the correctly-resolved path should be "//blow". Additionally, this is the result returned by the WHATWG URL Standard and modern browsers, including Safari 15 (JSDOM Live URL Viewer)
Additionally, if we add a component, a rather curious thing happens:
dumpURL(URL(string: "http://example.com/..///../blow")!)
dumpURL(URL(string: "http://example.com/../x///../blow")!) // Add a component before triple slashes, now they are not collapsed?!?!?
So if we add a path component before the triple slashes, for some reason they no longer get collapsed. This is just bizarre; I have no idea what's going on here.
The text was updated successfully, but these errors were encountered:
It's hard to find another library which implements the same standard as Foundation (most of them use newer standards), but I did find one: "URL Toolkit" in JS (https://github.com/tjenkinson/url-toolkit).
Testing it on jsfiddle, it agrees that there should be 2 slashes before "blow". It keeps the first ".." component, because RFC-1808 isn't specific about what implementations should do if there are too many ".." components at the start and says they may be kept, but later standards are clearer and say they should be discarded. Either way is fine, but what isn't fine is dropping the slash after the ".." component.
Attachment: Download
Environment
macOS 11.6, Xcode 13.1 (13A1030d)
Additional Detail from JIRA
md5: 0ac46f29cce8a652173171b7f80cac07
Issue Description:
This example is adapted from Foundation's test suite (NSURLWithString-parse-absolute-with-relative-029)
Outputs the following:
This result is incorrect; the standardized path should actually be "//blow".
The first ".." component is discarded since it is at the start of the path and can't pop anything
The path then starts with "///..", which is 2 empty components and a ".." component. The ".." pops one of the empties, leaving one remaining empty component
Finally, the "/blow" component should be added (including its leading slash)
The older RFCs which URL conforms to don't typically specify how ".." components should be resolved in an absolute URL, so it's unclear which behaviour Foundation is attempting to implement, but they do define how those should work when resolving a relative URL:
RFC-1808, Section 4: Resolving relative URLs
RFC-2396, Section 5.2: Resolving Relative References to Absolute Form (also has examples in Appendix C)
Additionally, the more recent RFC-3986 does define a more general algorithm:
> The pseudocode also refers to a "remove_dot_segments" routine for
interpreting and removing the special "." and ".." complete path
segments from a referenced path. This is done after the path is
extracted from a reference, whether or not the path was relative, in
order to remove any invalid or extraneous dot-segments prior to
forming the target URI.
Perhaps this is what Foundation is attempting to implement?
All of these references appear to confirm my belief that Foundation is in error, and the correctly-resolved path should be "//blow". Additionally, this is the result returned by the WHATWG URL Standard and modern browsers, including Safari 15 (JSDOM Live URL Viewer)
Additionally, if we add a component, a rather curious thing happens:
So if we add a path component before the triple slashes, for some reason they no longer get collapsed. This is just bizarre; I have no idea what's going on here.
The text was updated successfully, but these errors were encountered: