summaryrefslogtreecommitdiff
path: root/openid/urinorm.py
diff options
context:
space:
mode:
authorVlastimil Zíma <ziima@users.noreply.github.com>2020-09-02 10:21:22 +0200
committerGitHub <noreply@github.com>2020-09-02 10:21:22 +0200
commitafa6adacbe1a41d8f614c8bce2264dfbe9e76489 (patch)
treef416b7c2af02dd04f9b3c70fc1b06c063082d65f /openid/urinorm.py
parentd093a0919198eb53826ae5753e517af10ad95d5b (diff)
parenta2cb8bc70a12ad89a62a010fbe1569d21eed21d5 (diff)
downloadopenid-master.tar.gz
Merge pull request #47 from cjwatson/urinorm-query-unicodeHEADmaster
Fix normalization of non-ASCII query strings on Python 2
Diffstat (limited to 'openid/urinorm.py')
-rw-r--r--openid/urinorm.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/openid/urinorm.py b/openid/urinorm.py
index 9678741..22b3dad 100644
--- a/openid/urinorm.py
+++ b/openid/urinorm.py
@@ -132,8 +132,14 @@ def urinorm(uri):
path = '/'
_check_disallowed_characters(path, 'path')
- # Normalize query
- data = parse_qsl(split_uri.query)
+ # Normalize query. On Python 2, `urlencode` without `doseq=True`
+ # requires values to be convertible to native strings using `str()`.
+ if isinstance(split_uri.query, str):
+ # Python 3 branch
+ data = parse_qsl(split_uri.query)
+ else:
+ # Python 2 branch
+ data = parse_qsl(split_uri.query.encode('utf-8'))
query = urlencode(data)
_check_disallowed_characters(query, 'query')