don't crash when given an invalid public key block
authorAndrew Engelbrecht <sudoman@ninthfloor.org>
Sun, 19 Jul 2015 23:44:08 +0000 (19:44 -0400)
committerAndrew Engelbrecht <sudoman@ninthfloor.org>
Mon, 7 Dec 2015 18:16:28 +0000 (13:16 -0500)
edward

diff --git a/edward b/edward
index cd585367bb5ef3199e4a32d5a9d4fd87f7b7b0e4..ca6ef082affc034fe44be65fb9bb19df0b9b5122 100755 (executable)
--- a/edward
+++ b/edward
@@ -163,11 +163,13 @@ def add_gpg_keys (text, gpgme_ctx):
         fp = io.BytesIO(key_block.encode('ascii'))
 
         result = gpgme_ctx.import_(fp)
+        imports = result.imports
 
-        fingerprint = result.imports[0][0]
-        debug("added gpg key: " + fingerprint)
+        if imports != []:
+            fingerprint = imports[0][0]
+            keys += [gpgme_ctx.get_key(fingerprint)]
 
-        keys += [gpgme_ctx.get_key(fingerprint)]
+            debug("added gpg key: " + fingerprint)
 
     return keys