summaryrefslogtreecommitdiff
path: root/oauthlib/common.py
diff options
context:
space:
mode:
authorIb Lundgren <ib.lundgren@gmail.com>2014-05-28 13:51:50 +0100
committerIb Lundgren <ib.lundgren@gmail.com>2014-05-28 13:51:50 +0100
commit56c6c38a99bb35b1065fa650fa8937122e47ab57 (patch)
tree2bbf106cb26f70d74f5a660c7f092b18dd480b28 /oauthlib/common.py
parent1d9dd252a0761be7cfbce5ef0c0f749d963b35d4 (diff)
downloadoauthlib-56c6c38a99bb35b1065fa650fa8937122e47ab57.tar.gz
Improve urldecode error message on incorrectly encoded strings. CC #227.
Diffstat (limited to 'oauthlib/common.py')
-rw-r--r--oauthlib/common.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/oauthlib/common.py b/oauthlib/common.py
index 23fc23f..c1e36dc 100644
--- a/oauthlib/common.py
+++ b/oauthlib/common.py
@@ -133,7 +133,12 @@ def urldecode(query):
"""
# Check if query contains invalid characters
if query and not set(query) <= urlencoded:
- raise ValueError('Not a valid urlencoded string.')
+ error = ("Error trying to decode a non urlencoded string. "
+ "Found invalid characters: %s "
+ "in the string: '%s'. "
+ "Please ensure the request/response body is "
+ "x-www-form-urlencoded.")
+ raise ValueError(error % (set(query) - urlencoded, query))
# Check for correctly hex encoded values using a regular expression
# All encoded values begin with % followed by two hex characters