mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-07-29 12:09:37 +00:00
monkeysphere: Make sure show keys output is robust
This commit is contained in:
parent
9b89fac9e1
commit
4f9b271824
@ -125,7 +125,8 @@ def get_monkeysphere_keys(key_id=None):
|
||||
return {}
|
||||
|
||||
# parse output
|
||||
keys = [dict()]
|
||||
default_dict = {'imported_domains': [], 'available_domains': []}
|
||||
keys = [default_dict.copy()]
|
||||
lines = output.decode().strip().split('\n')
|
||||
for line in lines:
|
||||
if line.startswith('pub'):
|
||||
@ -140,8 +141,7 @@ def get_monkeysphere_keys(key_id=None):
|
||||
keys[-1].setdefault('uids', []).append(uid)
|
||||
matches = re.match('([a-zA-Z]*)://(.*)(:\d*)?', uid)
|
||||
keys[-1]['service'] = matches.group(1)
|
||||
keys[-1].setdefault('imported_domains', []) \
|
||||
.append(matches.group(2))
|
||||
keys[-1]['imported_domains'].append(matches.group(2))
|
||||
elif line.startswith('OpenPGP fingerprint:'):
|
||||
keys[-1]['openpgp_fingerprint'] = \
|
||||
line.lstrip('OpenPGP fingerprint:')
|
||||
@ -151,7 +151,7 @@ def get_monkeysphere_keys(key_id=None):
|
||||
keys[-1]['ssh_fingerprint'] = data[1]
|
||||
keys[-1]['ssh_key_type'] = data[2].strip('()')
|
||||
elif line == '':
|
||||
keys.append(dict())
|
||||
keys.append(default_dict.copy())
|
||||
|
||||
return {key['ssh_fingerprint']: key for key in keys}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user