mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-01-26 08:06:30 -06:00
Move utf-8 conversion inside user.py (for updates).
This commit is contained in:
parent
66d3f1e730
commit
c113d932b1
@ -3,6 +3,17 @@ import ldif
|
||||
import re
|
||||
import cStringIO
|
||||
|
||||
def utf8_encode_value(value):
|
||||
if isinstance(value,unicode):
|
||||
return value.encode('utf-8')
|
||||
return value
|
||||
|
||||
def utf8_encode_values(values):
|
||||
if isinstance(values,list) or isinstance(values,tuple):
|
||||
return map(utf8_encode_value, values)
|
||||
else:
|
||||
return utf8_encode_value(values)
|
||||
|
||||
class User:
|
||||
"""This class represents an IPA user. An LDAP entry consists of a DN
|
||||
and a list of attributes. Each attribute consists of a name and a list of
|
||||
@ -86,9 +97,9 @@ class User:
|
||||
if (len(value) < 1):
|
||||
return
|
||||
if (len(value) == 1):
|
||||
self.data[name] = value[0]
|
||||
self.data[name] = utf8_encode_values(value[0])
|
||||
else:
|
||||
self.data[name] = value
|
||||
self.data[name] = utf8_encode_values(value)
|
||||
|
||||
setValues = setValue
|
||||
|
||||
|
@ -115,10 +115,10 @@ class Root(controllers.RootController):
|
||||
orig_user_dict = loads(b64decode(kw.get('user_orig')))
|
||||
|
||||
new_user = ipa.user.User(orig_user_dict)
|
||||
new_user.setValue('givenname', utf8_encode(kw.get('givenname')))
|
||||
new_user.setValue('sn', utf8_encode(kw.get('sn')))
|
||||
new_user.setValue('mail', utf8_encode(kw.get('mail')))
|
||||
new_user.setValue('telephonenumber', utf8_encode(kw.get('telephonenumber')))
|
||||
new_user.setValue('givenname', kw.get('givenname'))
|
||||
new_user.setValue('sn', kw.get('sn'))
|
||||
new_user.setValue('mail', kw.get('mail'))
|
||||
new_user.setValue('telephonenumber', kw.get('telephonenumber'))
|
||||
#
|
||||
# this is a hack until we decide on the policy for names/cn/sn/givenName
|
||||
#
|
||||
|
Loading…
Reference in New Issue
Block a user