Exceptions with UTF-8 OpenID URLs

Bug #1363804 reported by François Marier on 2014-09-01
12
This bug affects 2 people
Affects Status Importance Assigned to Milestone
Libravatar (obsolete)
Fix Released
Medium
François Marier

Bug Description

When the OpenID discovery fails with a "consumer.DiscoveryFailure", an error message is printed to the logs.

However, that error message causes an exception if the OpenID URL contains non-ASCII characters like this one:

  https://plus.google.com/Exämple

Here's the error from the Django logs (/account/483/redirect_openid/):

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/usr/share/libravatar/libravatar/account/views.py", line 289, in redirect_openid
    print "OpenID discovery failed (userid=%s) for %s" % (request.user.id, user_url)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 73: ordinal not in range(128)

François Marier (fmarier) wrote :

Here's another exception, this time when deleting a photo (/account/3789/delete_photo/):

Traceback (most recent call last):

  File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 109, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/usr/lib/python2.7/dist-packages/django/db/transaction.py", line 224, in inner
    return func(*args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
    response = view_func(request, *args, **kwargs)

  File "/usr/lib/python2.7/dist-packages/django/contrib/auth/decorators.py", line 20, in _wrapped_view
    return view_func(request, *args, **kwargs)

  File "/usr/share/libravatar/libravatar/account/views.py", line 601, in delete_photo
    photo.delete()

  File "/usr/share/libravatar/libravatar/account/models.py", line 162, in delete
    openid.set_photo(None)

  File "/usr/share/libravatar/libravatar/account/models.py", line 401, in set_photo
    change_photo(photo, None, self.public_hash())

  File "/usr/share/libravatar/libravatar/account/models.py", line 388, in public_hash
    hash_object.update(lowercase_value)

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe4' in position 32: ordinal not in range(128)

summary: - Exception while logging OpenID error with UTF-8 URLs
+ Exceptions with UTF-8 OpenID URLs
description: updated
Changed in libravatar:
status: Confirmed → Fix Committed
Changed in libravatar:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers