Closed Bug 585494 Opened 14 years ago Closed 14 years ago

Admin blacklisted username form doesn't accept UTF-8

Categories

(addons.mozilla.org Graveyard :: Admin/Editor Tools, defect)

defect
Not set
normal

Tracking

(Not tracked)

VERIFIED FIXED
5.11.8

People

(Reporter: clouserw, Assigned: chenba)

Details

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().
Awesome, thanks.  http://github.com/jbalogh/zamboni/commit/b3e06b93006be9d6b198cf25ff0595dd5455a0ae
Status: NEW → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Product: addons.mozilla.org → addons.mozilla.org Graveyard
You need to log in before you can comment on or make changes to this bug.