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

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

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