Skip to content

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

Closed
@mfya

Description

@mfya

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions