Improve gpg secret key list parser to deal with changes in gpg 2.1.15. Fixes key name display in webapp.

gpg 2.1.15 (or so) seems to have added some new fields to the --with-colons
--list-secret-keys output. These include "fpr" and "grp", and come before
the "uid" line. So, the parser was giving up before it saw the name. Fix by
continuing to look for the uid line until the next "sec" line.

This commit was sponsored by Ole-Morten,Duesund on Patreon.
This commit is contained in:
Joey Hess 2016-09-14 13:30:50 -04:00
parent ddc1b46fc2
commit ec3558fb79
No known key found for this signature in database
GPG key ID: C910D9222512E3C7
2 changed files with 5 additions and 1 deletions

View file

@ -10,6 +10,8 @@ git-annex (6.20160908) UNRELEASED; urgency=medium
objects to the json output. objects to the json output.
* Remove key:null from git-annex add --json output. * Remove key:null from git-annex add --json output.
* copy, move, mirror: Support --json and --json-progress. * copy, move, mirror: Support --json and --json-progress.
* Improve gpg secret key list parser to deal with changes in gpg 2.1.15.
Fixes key name display in webapp.
-- Joey Hess <id@joeyh.name> Thu, 08 Sep 2016 12:48:55 -0400 -- Joey Hess <id@joeyh.name> Thu, 08 Sep 2016 12:48:55 -0400

View file

@ -178,8 +178,10 @@ secretKeys cmd = catchDefaultIO M.empty makemap
parse = extract [] Nothing . map (split ":") parse = extract [] Nothing . map (split ":")
extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) = extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) =
extract ((keyid, decode_c userid):c) Nothing rest extract ((keyid, decode_c userid):c) Nothing rest
extract c (Just keyid) rest = extract c (Just keyid) rest@(("sec":_):_) =
extract ((keyid, ""):c) Nothing rest extract ((keyid, ""):c) Nothing rest
extract c (Just keyid) (_:rest) =
extract c (Just keyid) rest
extract c _ [] = c extract c _ [] = c
extract c _ (("sec":_:_:_:keyid:_):rest) = extract c _ (("sec":_:_:_:keyid:_):rest) =
extract c (Just keyid) rest extract c (Just keyid) rest