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

URL path with "/../" #297

Closed
kkaiser opened this issue Mar 27, 2019 · 5 comments
Closed

URL path with "/../" #297

kkaiser opened this issue Mar 27, 2019 · 5 comments
Labels

Comments

@kkaiser
Copy link

kkaiser commented Mar 27, 2019

yarl==1.2.6 converts a URL like https://www.example.com/../example.jpg to https://www.example.com/example.jpg just fine.

In yarl==1.3.0 that was changed and now throws a ValueError instead.

>>> from yarl import URL
>>> URL('https://www.example.com/../example.jpg')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/kkaiser/.pyenv/versions/ocean_ai/lib/python3.7/site-packages/yarl/__init__.py", line 174, in __new__
    cls._validate_authority_uri_abs_path(host=host, path=path)
  File "/Users/kkaiser/.pyenv/versions/ocean_ai/lib/python3.7/site-packages/yarl/__init__.py", line 623, in _validate_authority_uri_abs_path
    "Path in a URL with authority " "should start with a slash ('/') if set"
ValueError: Path in a URL with authority should start with a slash ('/') if set

Should that be the expected behaviour? It was already closed once: #84

@aio-libs-bot
Copy link

GitMate.io thinks possibly related issues are #138 (Question: how could I join to URL list path parts?), #185 (Allow joining URL and pathlib.Path), #84 (Incorrect handling of '..' in url path), #33 (Parse URL parameter), and #242 (Handle path argument of URL.build, which doesn't start from /).

@Soniyanayak51
Copy link

Hi, is this issue still open?

@asvetlov
Copy link
Member

I think https://www.example.com/../example.jpg is an invalid path; there is no parent folder in /../example.jpg path context.

@kkaiser
Copy link
Author

kkaiser commented Oct 15, 2019

It is invalid but unfortunately appears on some websites that is why all browsers seem to convert it. Shouldn't yarl do the same?

@asvetlov
Copy link
Member

yarl shouldn't be as forgiving as a human-oriented web browser.
Consider it as dividing by zero.

@asvetlov asvetlov reopened this Jul 26, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants