Changeset - 1943c6f00cd8
[Not reviewed]
stable
0 1 0
Mads Kiilerich - 6 years ago 2019-07-31 21:31:23
mads@kiilerich.com
user: allow LDAP users with non-ASCII characters in the DN

The database and sqlalchemy use unicode, so any attempt at storing encoded data
is wrong and might fail.

Thus, use safe_unicode instead of encoding it using safe_str.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general)
kallithea/model/user.py
Show inline comments
 
@@ -34,13 +34,13 @@ import traceback
 

	
 
from tg import config
 
from tg.i18n import ugettext as _
 

	
 
from sqlalchemy.exc import DatabaseError
 

	
 
from kallithea.lib.utils2 import safe_str, generate_api_key, get_current_authuser
 
from kallithea.lib.utils2 import safe_unicode, generate_api_key, get_current_authuser
 
from kallithea.lib.caching_query import FromCache
 
from kallithea.model.db import Permission, User, UserToPerm, \
 
    UserEmailMap, UserIpMap
 
from kallithea.lib.exceptions import DefaultUserException, \
 
    UserOwnsReposException
 
from kallithea.model.meta import Session
 
@@ -142,15 +142,15 @@ class UserModel(object):
 

	
 
        try:
 
            new_user.username = username
 
            new_user.admin = admin
 
            new_user.email = email
 
            new_user.active = active
 
            new_user.extern_name = safe_str(extern_name) \
 
            new_user.extern_name = safe_unicode(extern_name) \
 
                if extern_name else None
 
            new_user.extern_type = safe_str(extern_type) \
 
            new_user.extern_type = safe_unicode(extern_type) \
 
                if extern_type else None
 
            new_user.name = firstname
 
            new_user.lastname = lastname
 

	
 
            if not edit:
 
                new_user.api_key = generate_api_key()
0 comments (0 inline, 0 general)