Admin blacklisted username form doesn't accept UTF-8

VERIFIED FIXED in 5.11.8

Status

VERIFIED FIXED
8 years ago
3 years ago

People

(Reporter: clouserw, Assigned: chenba)

Tracking

unspecified
5.11.8

Details

(Reporter)

Description

8 years ago
If I enter:

pâté en croûte

I get:


  File "/home/clouserw/dev/zamboni/apps/users/admin.py", line 52, in add_view
    if BlacklistedNickname.blocked(n):

  File "/home/clouserw/dev/zamboni/apps/users/models.py", line 207, in blocked
    nick = nick.decode().lower().encode('utf-8')

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe2' in position 1: ordinal not in range(128)
I'm suspicious of anyone saying .decode and .encode.  jsocol once explained this to me, but I promptly forgot.
From: http://docs.python.org/library/stdtypes.html#str.decode

"encoding defaults to the default string encoding."

Is 'nick' a byte string or a unicode string when you decode() it? If it's a byte string, you may want to specify the encoding for decode().
(Assignee)

Comment 3

8 years ago
With a little help from django.utils: http://github.com/chenba/zamboni/commit/b3e06b93006be9d6b198cf25ff0595dd5455a0ae
(Reporter)

Comment 4

8 years ago
Awesome, thanks.  http://github.com/jbalogh/zamboni/commit/b3e06b93006be9d6b198cf25ff0595dd5455a0ae
Status: NEW → RESOLVED
Last Resolved: 8 years ago
Resolution: --- → FIXED
Verified FIXED on https://preview.addons.mozilla.org/z/en-US/admin/models/users/blacklistednickname/add/.
Status: RESOLVED → VERIFIED
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.