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

VERIFIED FIXED in 1.9

Status

developer.mozilla.org
Wiki pages
VERIFIED FIXED
7 years ago
6 years ago

People

(Reporter: retornam, Assigned: groovecoder)

Tracking

unspecified
x86
Mac OS X

Details

(Whiteboard: u=user c=auth p=1, URL)

(Reporter)

Description

7 years ago
Traceback (most recent call last):

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/core/handlers/base.py", line 100, in get_response
    response = callback(request, *callback_args, **callback_kwargs)

  File "/data/www/django/developer.mozilla.org/kuma/apps/sumo/decorators.py", line 15, in _checkssl
    return view_func(request, *args, **kwargs)

  File "/data/www/django/developer.mozilla.org/kuma/apps/users/views.py", line 37, in login
    form = handle_login(request)

  File "/data/www/django/developer.mozilla.org/kuma/apps/users/utils.py", line 12, in handle_login
    if form.is_valid():

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/forms/forms.py", line 121, in is_valid
    return self.is_bound and not bool(self.errors)

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/forms/forms.py", line 112, in _get_errors
    self.full_clean()

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/forms/forms.py", line 268, in full_clean
    self._clean_form()

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/forms/forms.py", line 296, in _clean_form
    self.cleaned_data = self.clean()

  File "/data/www/django/developer.mozilla.org/kuma/apps/users/forms.py", line 119, in clean
    password=password)

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/django/django/contrib/auth/__init__.py", line 52, in authenticate
    user = backend.authenticate(**credentials)

  File "/data/www/django/developer.mozilla.org/kuma/apps/dekicompat/backends.py", line 43, in authenticate
    password=password)

  File "/data/www/django/developer.mozilla.org/kuma/apps/dekicompat/backends.py", line 161, in mindtouch_login
    r = requests.post(auth_url, auth=(username.encode('utf-8'), password))

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/requests/requests/api.py", line 135, in post
    return request('POST', url, data=data, **kwargs)

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/requests/requests/api.py", line 72, in request
    r.send()

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/requests/requests/models.py", line 339, in send
    resp = opener(req, timeout=self.timeout)

  File "/usr/lib/python2.6/urllib2.py", line 397, in open
    response = meth(req, response)

  File "/usr/lib/python2.6/urllib2.py", line 510, in http_response
    'http', request, response, code, msg, hdrs)

  File "/usr/lib/python2.6/urllib2.py", line 429, in error
    result = self._call_chain(*args)

  File "/usr/lib/python2.6/urllib2.py", line 369, in _call_chain
    result = func(*args)

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/requests/requests/monkeys.py", line 80, in http_error_401
    response = self._http_error_auth_reqed('www-authenticate', url, req, headers)

  File "/data/www/django/developer.mozilla.org/kuma/vendor/src/requests/requests/monkeys.py", line 106, in _http_error_auth_reqed
    response = self.retry_http_basic_auth(host, req, realm)

  File "/usr/lib/python2.6/urllib2.py", line 839, in retry_http_basic_auth
    auth = 'Basic %s' % base64.b64encode(raw).strip()

  File "/usr/lib/python2.6/base64.py", line 53, in b64encode
    encoded = binascii.b2a_base64(s)[:-1]

UnicodeEncodeError: 'ascii' codec can't encode character u'\xe1' in position 23: ordinal not in range(128)
(Assignee)

Comment 1

7 years ago
There's no way to base64 encode utf8 characters for MindTouch authentication API. This essentially forces anyone with a utf8 character in their password into a password reset flow.

This bug should be to catch this exception and maybe show a friendly message directing the user into the password reset flow.
Whiteboard: u=user c=auth p=
Target Milestone: --- → 1.9
(Assignee)

Updated

7 years ago
Whiteboard: u=user c=auth p= → u=user c=auth p=1
(Assignee)

Updated

7 years ago
Assignee: nobody → lcrouch
(Assignee)

Comment 2

7 years ago
Added code to catch potential errors and direct the user to the pwreset flow, but also added code to prevent errors. Should be able to use passwords with high-value unicode characters now.

See https://github.com/mozilla/kuma/commit/b126322d7fdec52f749cfd5d59fe3990ccef54d3 for code.
Status: NEW → RESOLVED
Last Resolved: 7 years ago
Resolution: --- → FIXED
(Reporter)

Comment 3

6 years ago
I haven't seen this in a while so closing bug
Status: RESOLVED → VERIFIED
Version: Kuma → unspecified
Component: Website → Landing pages
Product: Mozilla Developer Network → Mozilla Developer Network
You need to log in before you can comment on or make changes to this bug.