Skip to content

"%" is not escaped in path, user and password in URL.build() #502

@serhiy-storchaka

Description

@serhiy-storchaka
>>> from yarl import URL
>>> URL.build(scheme="http", host="example.com", path="/%25")
URL('http://example.com/%25')
>>> URL.build(scheme="http", host="example.com", path="/%25").path
'/%'
>>> URL.build(scheme="http", host="example.com", user="%25")
URL('http://%25@example.com')
>>> URL.build(scheme="http", host="example.com", user="%25").user
'%'
>>> URL.build(scheme="http", host="example.com", password="%25")
URL('http://:%25@example.com')
>>> URL.build(scheme="http", host="example.com", password="%25").password
'%'

All other parts are properly escaped. For example:

>>> URL.build(scheme="http", host="example.com", fragment="%25")
URL('http://example.com/#%25')
>>> URL.build(scheme="http", host="example.com", fragment="%25").fragment
'%'
>>> URL.build(scheme="http", host="example.com", query={"%25": "%25"})
URL('http://example.com/?%2525=%2525')
>>> URL.build(scheme="http", host="example.com", query={"%25": "%25"}).query
<MultiDictProxy('%25': '%25')>

yarl 1.5.1

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions