From: Simon Ruderich Date: Tue, 27 Aug 2013 17:03:34 +0000 (+0200) Subject: mutt/crypto-autoencrypt.pl: Minor cleanup. X-Git-Url: https://ruderich.org/simon/gitweb/?a=commitdiff_plain;h=73c125f258cd3f4523e9f522c7e58feb72a7ac96;p=config%2Fdotfiles.git mutt/crypto-autoencrypt.pl: Minor cleanup. Also add a comment describing why invalid UIDs aren't skipped. Thanks to Simon Schuster for inspiring me to think about this issue. --- diff --git a/mutt/crypto-autoencrypt.pl b/mutt/crypto-autoencrypt.pl index 6895dcc..c0a49ea 100755 --- a/mutt/crypto-autoencrypt.pl +++ b/mutt/crypto-autoencrypt.pl @@ -3,7 +3,7 @@ # Helper script for mutt to create a list of send-hooks which enable # crypt_autoencrypt for known GnuPG keys. -# Copyright (C) 2009-2012 Simon Ruderich +# Copyright (C) 2009-2013 Simon Ruderich # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -24,7 +24,14 @@ use warnings; open my $gpg, '-|', 'gpg --list-keys --with-colons --fixed-list-mode' or die $!; while (<$gpg>) { - next unless /<(.+?@.+?)>/; + next if not /^uid:/; + + # We don't skip invalid, deleted, revoked, expired and not-trusted UIDs to + # prevent sending an unencrypted mail when e.g. a key is revoked or + # expired. If you want to skip those UIDs, uncomment the next line. + #next if /^uid:[idren]:/; + + next if not /<(.+?@.+?)>:/; print "send-hook '~t .*$1.*' 'set crypt_autoencrypt=yes'\n"; } close $gpg or die $!;