From 8d1185c3884f8125cedf9c4c8060cb5d360e9ef4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 14 Sep 2016 13:25:12 -0400 Subject: Another fix to gpg secret key list parser. gpg2 2.1.15 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 continueing to look for the uid line until the next "sec" line. --- CHANGELOG | 1 + Gpg.hs | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 7f64e2d..b3c7f06 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -7,6 +7,7 @@ keysafe (0.20160832) UNRELEASED; urgency=medium * Server-side rate limiting and DOS protection. * server: Added --months-to-fill-half-disk option, defaulting to 12. * Several new dependencies. + * Another fix to gpg secret key list parser. -- Joey Hess Thu, 01 Sep 2016 11:42:27 -0400 diff --git a/Gpg.hs b/Gpg.hs index 9a743f0..4522cfb 100644 --- a/Gpg.hs +++ b/Gpg.hs @@ -42,8 +42,10 @@ listSecretKeys = map mk . parse . lines <$> readProcess "gpg" parse = extract [] Nothing . map (splitOn ":") extract c (Just keyid) (("uid":_:_:_:_:_:_:_:_:userid:_):rest) = extract ((userid, keyid):c) Nothing rest - extract c (Just keyid) rest = + extract c (Just keyid) rest@(("sec":_):_) = extract (("", keyid):c) Nothing rest + extract c (Just keyid) (_:rest) = + extract c (Just keyid) rest extract c _ [] = c extract c _ (("sec":_:_:_:keyid:_):rest) = extract c (Just keyid) rest -- cgit v1.2.3