Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLs containing no host and a path starting with ./ or ../ are not serialized idempotently #601

Closed
jdm opened this issue Jun 10, 2020 · 8 comments

Comments

@jdm
Copy link
Member

jdm commented Jun 10, 2020

Parsing a url like scheme:/.//path internally removes the ./ in the serialization (per the spec), so parsing the serialized URL of scheme://path yields a URL that is parsed differently than the original one (ie. path is treated as a host now, instead of part of the URL's path).

Cases to consider:

  • scheme:/.//path
  • scheme:/..//path
  • scheme:/./..//path (any leading mixed collection of ./ and ../)

My reading of the spec is that this might be a shortcoming that needs to be addressed there, rather than just an implementation bug. I can envision a couple possible solutions:

  • don't truncate ./ or ../ if it's the first component of a path, avoiding the issue entirely
  • truncate / when the previous segment is empty (resulting in scheme:/path)
@jdm jdm changed the title URLs containing no host and a path starting with ./ are not serialized idempotently URLs containing no host and a path starting with ./ or ../ are not serialized idempotently Jun 10, 2020
@SimonSapin
Copy link
Member

Should this be filed in https://github.com/whatwg/url/issues ?

@jdm
Copy link
Member Author

jdm commented Jun 10, 2020

Maybe! I haven't spent a lot of time verifying that the spec doesn't handle it yet.

@dan-da
Copy link

dan-da commented Jun 10, 2020

possibly related: I am noticing today that "../" are normalized in (to me) a strange way, ie:

http://host/somedir/../file.txt   --->  /file.txt         (ok)
http://host/somedir/../../file.txt   --->  /file.txt         (seems wrong)
http://host/somedir/../../../file.txt   --->  /file.txt         (seems wrong)
http://host/../../../file.txt   --->  /file.txt         (seems wrong)
http://host/../file.txt   --->  /file.txt         (seems wrong)

I haven't checked the spec, maybe this is correct behavior. Personally I would expect a parse error for the "seems wrong" cases.

edit: I checked the spec. The behavior appears "correct".

I am wanting/needing a way to access the "raw" path without any such normalization. Filed #602

@valenting
Copy link
Collaborator

Probably a dupe of #459

Anne pointed me to whatwg/url#505

@djc
Copy link
Contributor

djc commented Aug 24, 2020

whatwg/url#505 just landed, tests in web-platform-tests/wpt#25113. @valenting has some patches in https://github.com/valenting/rust-url/tree/non-special-idempotent -- I will see about rebasing these onto current master.

@djc
Copy link
Contributor

djc commented Aug 24, 2020

I've pulled in the new tests and rebased @valenting's patch on top of current master. Unfortunately the patch increases the number of failed tests by 1 rather than improving the situation, so this will still need some more work.

Draft PR here: #629. Any help is appreciated!

@qsantos
Copy link
Contributor

qsantos commented Mar 19, 2023

I think this is the same thing as #799, which was resolved by #817

@valenting
Copy link
Collaborator

Yes, thank you @qsantos

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants