summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIb Lundgren <ib.lundgren@gmail.com>2012-06-29 13:57:39 +0200
committerIb Lundgren <ib.lundgren@gmail.com>2012-06-29 13:57:39 +0200
commitb765eb5ba4b8ce40fcbb6f76fbccb0285b0d87cd (patch)
treeb16af64a66e10143525725e23a1a65a733acbf62
parent4116c81fb1f9b591008db6b805d81ca6aca521c4 (diff)
downloadoauthlib-b765eb5ba4b8ce40fcbb6f76fbccb0285b0d87cd.tar.gz
add_params_to_qs now support dict queries
-rw-r--r--oauthlib/common.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/oauthlib/common.py b/oauthlib/common.py
index 70fb6a0..109e4bb 100644
--- a/oauthlib/common.py
+++ b/oauthlib/common.py
@@ -169,7 +169,10 @@ def generate_token(length=30, chars=UNICODE_ASCII_CHARACTER_SET):
def add_params_to_qs(query, params):
"""Extend a query with a list of two-tuples."""
- queryparams = urlparse.parse_qsl(query, keep_blank_values=True)
+ if isinstance(query, dict):
+ queryparams = query.items()
+ else:
+ queryparams = urlparse.parse_qsl(query, keep_blank_values=True)
queryparams.extend(params)
return urlencode(queryparams)
@@ -181,13 +184,13 @@ def add_params_to_uri(uri, params):
return urlparse.urlunparse((sch, net, path, par, query, fra))
def safe_string_equals(a, b):
- """ Near-constant time string comparison.
+ """ Near-constant time string comparison.
Used in order to avoid timing attacks on sensitive information such
as secret keys during request verification (`rootLabs`_).
.. _`rootLabs`: http://rdist.root.org/2010/01/07/timing-independent-array-comparison/
-
+
"""
if len(a) != len(b):
return False