@@ -298,13 +298,22 @@ def get_uids(self, key):
298298 # For the normal case (have email), we'll be storing each email
299299 # twice but that's OK since it means that email is *always* a valid
300300 # email or None and id is *always* a valid identifier
301- match = re .search (".* <(.*)>" , uid )
301+ match = re .search ("^ .* <(.*)>$ " , uid )
302302 if match :
303303 email = match .group (1 )
304304 PiusUtil .debug ("got email %s" % email )
305305 filename = re .sub ("@" , "_at_" , email )
306306 filename = "%s__%s" % (key , filename )
307307 uid = email
308+ # It is possible for the UID to be JUST a raw email address, so
309+ # if that appears to be the case, use that
310+ elif re .match (
311+ "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$" , uid
312+ ):
313+ email = uid
314+ PiusUtil .debug ("got email %s" % email )
315+ filename = re .sub ("@" , "_at_" , email )
316+ filename = "%s__%s" % (key , filename )
308317 else :
309318 # but if it doesn't have an email, do the right thing
310319 email = None
@@ -442,7 +451,7 @@ def encrypt_signed_uid(self, key, filename):
442451
443452 def _run_and_check_status (self , cmd , shell = False ):
444453 """Helper function for running a gpg call that requires no input
445- but that we want to make sure succeeded."""
454+ but that we want to make sure succeeded."""
446455 PiusUtil .logcmd (cmd )
447456 gpg = subprocess .Popen (
448457 cmd ,
@@ -495,7 +504,7 @@ def clean_clean_key(self, key):
495504
496505 def import_clean_key (self , key ):
497506 """Import the clean key we exported in export_clean_key() to our temp
498- keyring."""
507+ keyring."""
499508 # Import the export of our public key and the given public key
500509 for x in [self .signer , key ]:
501510 PiusUtil .debug ("importing %s" % x )
@@ -690,7 +699,7 @@ def sign_all_uids(self, key, level):
690699 uids = self .get_uids (key )
691700 print (
692701 " There %s %s UID%s on this key to sign"
693- % (["is" , "are" ][len (uids ) != 1 ], len (uids ), "s" [len (uids ) == 1 :])
702+ % (["is" , "are" ][len (uids ) != 1 ], len (uids ), "s" [len (uids ) == 1 :])
694703 )
695704
696705 # From the user key ring make a clean copy
@@ -812,7 +821,7 @@ def import_unsigned_keys(self):
812821 def encrypt_and_sign_file (self , infile , outfile , keyid ):
813822 """Encrypt and sign a file.
814823
815- Used for PGP/Mime email generation."""
824+ Used for PGP/Mime email generation."""
816825 cmd = (
817826 [self .gpg ]
818827 + GPG_BASE_OPTS
0 commit comments