exceptions.UnicodeEncodeError when setting password with utf8 character

Issue #89 resolved
Robert Kánia
created an issue
bug: <type 'exceptions.UnicodeEncodeError'>: 'ascii' codec can't encode character u'\xed' in position 4: ordinal not in range(128) (/create/user/domain.com)
POST https://iredmail/iredadmin/create/user/domain.com

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/site-packages/web/application.py", line 239, in process
    return self.handle()
  File "/usr/local/lib/python2.7/site-packages/web/application.py", line 230, in handle
    return self._delegate(fn, self.fvars, args)
  File "/usr/local/lib/python2.7/site-packages/web/application.py", line 420, in _delegate
    return handle_class(cls)
  File "/usr/local/lib/python2.7/site-packages/web/application.py", line 396, in handle_class
    return tocall(*args)
  File "/usr/local/www/iRedAdmin-Pro-LDAP-2.6.0/controllers/decorators.py", line 91, in decorated
    return f(*args, **kw)
  File "/usr/local/www/iRedAdmin-Pro-LDAP-2.6.0/libs/ldaplib/decorators.py", line 92, in proxyfunc
    return func(*args, **kw)
  File "/usr/local/www/iRedAdmin-Pro-LDAP-2.6.0/controllers/ldap/user.py", line 437, in POST
    result = userLib.add(domain=domain, form=form)
  File "/usr/local/www/iRedAdmin-Pro-LDAP-2.6.0/libs/ldaplib/decorators.py", line 66, in proxyfunc
    return func(*args, **kw)
  File "/usr/local/www/iRedAdmin-Pro-LDAP-2.6.0/libs/ldaplib/user.py", line 226, in add
    newpw = str(form.get('newpw')).strip()
UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 4: ordinal not in range(128)

Comments (5)

  1. Zhang Huangbin repo owner

    iRedAdmin accepts password with ASCII characters, unicode characters are not supported.

    Do you mean we should return a useful error message instead of this technical error page? I will fix it in next release.

  2. Zhang Huangbin repo owner

    I cannot reproduce this error with the latest development edition of iRedAdmin-Pro-LDAP, while creating a new mail user or resetting password for an existing user, i got this "user-friendly" error message:

    Error: Please do not use non-ascii character in password.
  3. Robert Kánia reporter

    I am using ver. 2.6.0, the exception is thrown on line 225 in the libs/ldaplib/user.py file:

    224            # Check password.
    225            newpw = str(form.get('newpw')).strip()
    226            confirmpw = str(form.get('confirmpw')).strip()

    I see that in iredadmin-ose the password is checked with safestr:

    128        # Check password.
    129        self.newpw = web.safestr(data.get('newpw'))
    130        self.confirmpw = web.safestr(data.get('confirmpw'))

    If this is simmilar in the latest dev. of iRedAdmin-Pro-LDAP then the issue can be closed and I'll wait for new release.

  4. Zhang Huangbin repo owner

    The latest iRedAdmin-Pro development edition uses web.safestr() too. :)

    So we close this issue, and you wait for next stable release. OK? Sorry about this trouble.

  5. Log in to comment