mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-11-09 23:20:27 +00:00
Fix issue with inserting into the database fields 'firstname' and 'lastname' containing non-ascii characters that can be retrieved from LDAP
This commit is contained in:
parent
6f4cc42805
commit
b0caf0ca48
@ -9,6 +9,7 @@ import traceback
|
|||||||
import pyotp
|
import pyotp
|
||||||
import re
|
import re
|
||||||
import dns.reversename
|
import dns.reversename
|
||||||
|
import sys
|
||||||
|
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from distutils.util import strtobool
|
from distutils.util import strtobool
|
||||||
@ -221,6 +222,12 @@ class User(db.Model):
|
|||||||
self.firstname = result[0][0][1]['givenName'][0]
|
self.firstname = result[0][0][1]['givenName'][0]
|
||||||
self.lastname = result[0][0][1]['sn'][0]
|
self.lastname = result[0][0][1]['sn'][0]
|
||||||
self.email = result[0][0][1]['mail'][0]
|
self.email = result[0][0][1]['mail'][0]
|
||||||
|
|
||||||
|
if sys.version_info < (3,):
|
||||||
|
if isinstance(self.firstname, str):
|
||||||
|
self.firstname = self.firstname.decode('utf-8')
|
||||||
|
if isinstance(self.lastname, str):
|
||||||
|
self.lastname = self.lastname.decode('utf-8')
|
||||||
except Exception:
|
except Exception:
|
||||||
self.firstname = self.username
|
self.firstname = self.username
|
||||||
self.lastname = ''
|
self.lastname = ''
|
||||||
|
Loading…
Reference in New Issue
Block a user