Show all uids when disambiguating a key.

Previously, only a contiguous block of uids would be presented to the
user when trying to disambiguate a key.  This happened because a key may
have other fields interspersed among the uids, like UAT.

Signed-off-by: James McCoy <vega.james@gmail.com>
This commit is contained in:
James McCoy 2013-01-27 20:59:18 -05:00
parent 2f1d2c8244
commit dcb9d3764a

View File

@ -841,7 +841,7 @@ function s:GPGFinishRecipientsBuffer()
endfor
" write back the new recipient list to the corresponding buffer and mark it
" as modified. Buffer is now for sure a encrypted buffer.
" as modified. Buffer is now for sure an encrypted buffer.
call setbufvar(b:GPGCorrespondingTo, "GPGRecipients", recipients)
call setbufvar(b:GPGCorrespondingTo, "&mod", 1)
call setbufvar(b:GPGCorrespondingTo, "GPGEncrypted", 1)
@ -1091,26 +1091,24 @@ function s:GPGNameToID(name)
let pubseen = 0
let counter = 0
let gpgids = []
let duplicates = {}
let seen_keys = {}
let skip_key = 0
let has_strftime = exists('*strftime')
let choices = "The name \"" . a:name . "\" is ambiguous. Please select the correct key:\n"
for line in lines
" check if this line has already been processed
if !has_key(duplicates, line)
let duplicates[line] = 1
let fields = split(line, ":")
" search for the next uid
if pubseen
if (fields[0] == "uid")
let choices = choices . " " . fields[9] . "\n"
else
let pubseen = 0
endif
" search for the next pub
else
if (fields[0] == "pub")
" check if this key has already been processed
if has_key(seen_keys, fields[4])
let skip_key = 1
continue
endif
let skip_key = 0
let seen_keys[fields[4]] = 1
" Ignore keys which are not usable for encryption
if fields[11] !~? 'e'
continue
@ -1118,15 +1116,16 @@ function s:GPGNameToID(name)
let identity = fields[4]
let gpgids += [identity]
if exists("*strftime")
if has_strftime
let choices = choices . counter . ": ID: 0x" . identity . " created at " . strftime("%c", fields[5]) . "\n"
else
let choices = choices . counter . ": ID: 0x" . identity . "\n"
endif
let counter = counter+1
let pubseen = 1
endif
endif
" search for the next uid
elseif (!skip_key && fields[0] == "uid")
let choices = choices . " " . fields[9] . "\n"
endif
endfor