Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion oauth2_provider/views/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,17 @@ def error_response(self, error, **kwargs):
:param error: :attr:`OAuthToolkitError`
"""
oauthlib_error = error.oauthlib_error

separator = '?'
try:
if '?' in oauthlib_error.redirect_uri:
separator = '&'
except:
pass
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry for being pedantic but I don't like except: pass very much ;)
What about something like:

redirect_uri = oauthlib_error.redirect_uri or ""
separator = '&' if '?' in redirect_uri else '?'

Also, I guess a test case checking the double ? problem (a test that fails without your patch) should be added


error_response = {
'error': oauthlib_error,
'url': "{0}?{1}".format(oauthlib_error.redirect_uri, oauthlib_error.urlencoded)
'url': "{0}{1}{2}".format(oauthlib_error.redirect_uri, separator, oauthlib_error.urlencoded)
}
error_response.update(kwargs)

Expand Down