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

Path component in url constructed by Route.url() is not quoted #623

Closed
mfya opened this issue Nov 5, 2015 · 3 comments
Closed

Path component in url constructed by Route.url() is not quoted #623

mfya opened this issue Nov 5, 2015 · 3 comments
Labels

Comments

@mfya
Copy link

mfya commented Nov 5, 2015

The url returned by StaticRoute.url() and DynamicRoute.url() can not be properly split, if the parameters contain reserved chars.
I'm not sure if this is intended, but considering that the query is urlencoded, it appears to be inconsistent and may render the result useless unless the caller always performs additional steps.

>>> urllib.parse.urlparse(route.url(filename='te st?x&y#z', query={'a':'b&c'}))
ParseResult(scheme='', netloc='', path='/static/te st', params='', query='x&y', fragment='z?a=b%26c')
>>> urllib.parse.urlparse(route.url(filename=urllib.parse.quote('te st?x&y#z'), query={'a':'b&c'}))
ParseResult(scheme='', netloc='', path='/static/te%20st%3Fx%26y%23z', params='', query='a=b%26c', fragment='')

Adding calls to urllib.parse.quote before joining the path and the urlencoded query should fix this.

@asvetlov
Copy link
Member

asvetlov commented Nov 7, 2015

I feel your need but have no strong opinion how to do it.
Say, for URL matching we have two parameters: path and raw_path.
Maybe adding .raw_url() makes sense also?
Need to sleep on it anyway.

@asvetlov
Copy link
Member

Fixed by introducing url_for() returning YARL instance.

@lock
Copy link

lock bot commented Oct 29, 2019

This thread has been automatically locked since there has not been
any recent activity after it was closed. Please open a new issue for
related bugs.

If you feel like there's important points made in this discussion,
please include those exceprts into that new issue.

@lock lock bot added the outdated label Oct 29, 2019
@lock lock bot locked as resolved and limited conversation to collaborators Oct 29, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants