summaryrefslogtreecommitdiffstats
path: root/pykolab
diff options
context:
space:
mode:
authorAleksander Machniak <machniak@kolabsys.com>2016-05-13 10:45:50 +0200
committerJeroen van Meeuwen (Kolab Systems) <vanmeeuwen@kolabsys.com>2016-05-13 10:45:50 +0200
commit3e419b753a2844655362c824cff167583d604bfa (patch)
tree09347856040f92bcce81b3f31d1cc4746a789711 /pykolab
parent39e31385df84f1d46576ecc8461ab1d0177de1e7 (diff)
downloadpykolab-3e419b753a2844655362c824cff167583d604bfa.tar.gz
Trim spaces in surname/givenname/sn when generating mail/alias (#5360)
Reviewers: vanmeeuwen, #pykolab_developers Reviewed By: vanmeeuwen, #pykolab_developers Subscribers: vanmeeuwen Differential Revision: https://git.kolab.org/D136
Diffstat (limited to 'pykolab')
-rw-r--r--pykolab/utils.py23
1 files changed, 15 insertions, 8 deletions
diff --git a/pykolab/utils.py b/pykolab/utils.py
index 7fca3fe..29a0e95 100644
--- a/pykolab/utils.py
+++ b/pykolab/utils.py
@@ -353,22 +353,29 @@ def normalize(_object):
return result
elif type(_object) == dict:
- for key in _object.keys():
+ def _strip(value):
+ try:
+ return value.strip()
+ except:
+ return value
+
+ for key in _object:
if type(_object[key]) == list:
- if _object[key] == None:
+ if _object[key] is None:
continue
- if len(_object[key]) == 1:
- result[key.lower()] = ''.join(_object[key])
+ val = map(_strip, _object[key])
+
+ if len(val) == 1:
+ result[key.lower()] = ''.join(val)
else:
- result[key.lower()] = _object[key]
+ result[key.lower()] = val
else:
- if _object[key] == None:
+ if _object[key] is None:
continue
- # What the heck?
- result[key.lower()] = _object[key]
+ result[key.lower()] = _strip(_object[key])
if result.has_key('objectsid') and not result['objectsid'][0] == "S":
result['objectsid'] = sid_to_string(result['objectsid'])