From 6f9daea91be0a41bf42ce1da065fa7e2d5782235 Mon Sep 17 00:00:00 2001 From: Brian Dolbec Date: Sat, 22 Jun 2013 18:26:52 -0700 Subject: [PATCH] Strip line feeds from seeds when loading --- gkeyldap/cli.py | 14 ++++++++++---- gkeys/seed.py | 1 + 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/gkeyldap/cli.py b/gkeyldap/cli.py index cd813d4..bf4e00e 100644 --- a/gkeyldap/cli.py +++ b/gkeyldap/cli.py @@ -223,11 +223,18 @@ class Main(object): if not field: continue try: - values = info[field] + # strip errant line feeds + values = [y.strip('\n') for y in info[field]] if values and values in ['uid', 'cn' ]: value = values[0] + # separate out short/long key id's + elif values and x in ['keyid', 'longkeyid']: + value = get_key_ids(x, values) else: value = values + if 'undefined' in values: + logger.error('%s = "undefined" for %s, %s' + %(field, info['uid'][0], info['cn'][0])) if value: keyinfo[x] = value except KeyError: @@ -245,11 +252,10 @@ class Main(object): keyinfo.append(None) continue try: - values = info[field] # strip errant line feeds - values = [x.strip('\n') for x in values] + values = [y.strip('\n') for y in info[field]] if values and field in ['uid', 'cn' ]: - value = values[0].strip('\n') + value = values[0] # separate out short/long key id's elif values and x in ['keyid', 'longkeyid']: value = get_key_ids(x, values) diff --git a/gkeys/seed.py b/gkeys/seed.py index 544ab02..5cfa5fe 100644 --- a/gkeys/seed.py +++ b/gkeys/seed.py @@ -54,6 +54,7 @@ class Seeds(object): for seed in seedlines: try: + seed = seed.strip('\n') parts = self._split_seed(seed, self.separator) self.seeds.append(GKEY._make(parts)) except Exception as err: -- 2.26.2