Skip to content

When encoding URLs, don't encode elements of iterables twice#156

Open
poqoid wants to merge 2 commits intotheelous3:masterfrom
poqoid:master
Open

When encoding URLs, don't encode elements of iterables twice#156
poqoid wants to merge 2 commits intotheelous3:masterfrom
poqoid:master

Conversation

@poqoid
Copy link

@poqoid poqoid commented Jan 23, 2020

Formerly, the code would run each element through quote_plus twice:

import asks
test_data = [{'foo': 'abc', 'bar': 'jkl'}, {'foo': ['abc def', 'ghi'], 'bar baz': 'jkl'}]

for row in test_data:
    print(asks.request_object.RequestProcessor._dict_to_query(row))
?foo=abc&bar=jkl
?foo=abc%252Bdef&foo=ghi&bar+baz=jkl

Note that %252B is + encoded twice:

>>> from urllib.parse import quote_plus
>>> quote_plus('+')
'%2B'
>>> quote_plus('%2B')
'%252B'

This pull request makes it so that each element is only encoded once.

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

Successfully merging this pull request may close these issues.

1 participant