From 56c6c38a99bb35b1065fa650fa8937122e47ab57 Mon Sep 17 00:00:00 2001 From: Ib Lundgren Date: Wed, 28 May 2014 13:51:50 +0100 Subject: Improve urldecode error message on incorrectly encoded strings. CC #227. --- oauthlib/common.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'oauthlib/common.py') 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 -- cgit v1.2.1