diff options
author | Martin Schaaf <mschaaf@datameer.com> | 2017-11-01 20:20:37 +0100 |
---|---|---|
committer | Martin Schaaf <mschaaf@datameer.com> | 2017-11-01 20:20:37 +0100 |
commit | 93cde985157dd636e8c3d1d0d937bf68cdf05f27 (patch) | |
tree | 7c361eebc6933a7144bf09af93a4aff9a1d563ad /alot/commands/utils.py | |
parent | 6243ceef045e888a158e0d97b6d4e48108603c64 (diff) |
Fix issue 1164 of not able to select a key for encryption on ambigious keyid error
* avoid endless loop if the selected key leads to an ambiguous key error again
* do not add the resulting key to the loop again instead add it directly
* use a list of keys as selection return values
* add fpr to visual key selection list to be able to select the expected key
* remove reversed call that should not be necessary
Diffstat (limited to 'alot/commands/utils.py')
-rw-r--r-- | alot/commands/utils.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/alot/commands/utils.py b/alot/commands/utils.py index 7e4e0307..cb696eea 100644 --- a/alot/commands/utils.py +++ b/alot/commands/utils.py @@ -90,15 +90,16 @@ def _get_keys(ui, encrypt_keyids, block_error=False, signed_only=False): signed_only=signed_only) except GPGProblem as e: if e.code == GPGCode.AMBIGUOUS_NAME: - tmp_choices = [k.uids[0].uid for k in + tmp_choices = [k.uids[0].uid + " (" + k.fpr + ")" for k in crypto.list_keys(hint=keyid)] - choices = {str(i): t for i, t in - enumerate(reversed(tmp_choices), 1)} - keyid = yield ui.choice("ambiguous keyid! Which " + - "key do you want to use?", - choices, cancel=None) - if keyid: - encrypt_keyids.append(keyid) + choices = {str(i): t for i, t in enumerate(tmp_choices, 1)} + keys_to_return = {str(i): t for i, t in enumerate([k for k in + crypto.list_keys(hint=keyid)], 1)} + choosen_key = yield ui.choice("ambiguous keyid! Which " + + "key do you want to use?", + choices, keys_to_return) + if choosen_key: + keys[choosen_key.fpr] = choosen_key continue else: ui.notify(str(e), priority='error', block=block_error) |