Mercurial > kallithea
changeset 8079:88e0d0c0c208
validator: fix ASCII password check to verify if it can be *encoded* in ascii
In Python 2, unicode strings have a .decode method (which really doesn't make
sense). Python 3 has more strict typing by design, and unicode strings don't
have a .decode method.
A Unicode string "is ASCII" if it can be encoded as ASCII. The check should
thus *encode* to ASCII - not decode.
author | Mads Kiilerich <mads@kiilerich.com> |
---|---|
date | Fri, 27 Dec 2019 02:02:20 +0100 |
parents | 45bfab30d433 |
children | e7dbe089e10d |
files | kallithea/model/validators.py |
diffstat | 1 files changed, 1 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/kallithea/model/validators.py Sat Dec 28 20:25:59 2019 +0100 +++ b/kallithea/model/validators.py Fri Dec 27 02:02:20 2019 +0100 @@ -235,7 +235,7 @@ def _validate_python(self, value, state): try: - (value or '').decode('ascii') + (value or '').encode('ascii') except UnicodeError: msg = self.message('invalid_password', state) raise formencode.Invalid(msg, value, state,)