Subject: | _rebuild_key_cache has started failing hard. Patch included. |
In "sub _rebuild_key_cache", $key->user_ids is expected to return a list of user ids, and it did. Until I just did a dist-upgrade on my Debian system. Then all of a sudden "has_public_key" started to fail, because "$key->user_ids" started returning a list of array refs instead. If fixed this, in what should be a backwards compatible manner with the following patch:
********************************************************************************
--- GnuPG.pm.ORIG 2014-03-12 17:07:52.209701232 +0000
+++ GnuPG.pm 2014-03-12 17:11:22.161473944 +0000
@@ -478,10 +478,12 @@
$self->_set_options($gnupg);
my @keys = $gnupg->get_public_keys();
foreach my $key (@keys) {
- foreach my $uid ($key->user_ids) {
- # M::A may not parse the gpg stuff properly. Cross fingers
- my ($a) = Mail::Address->parse($uid->as_string); # list context, please
- $key_cache{$a->address}=1 if ref $a;
+ foreach ($key->user_ids) {
+ foreach my $uid (ref($_) eq 'ARRAY' ? @$_ : ($_)) {
+ # M::A may not parse the gpg stuff properly. Cross fingers
+ my ($a) = Mail::Address->parse($uid->as_string); # list context, please
+ $key_cache{$a->address}=1 if ref $a;
+ }
}
}
}
********************************************************************************
I'm not sure what exactly changed during the upgrade to trigger this problem, although I'm guessing it's GnuPG::Interface. I'm running:
Mail::GnuPG v0.19
GnuPG v2.0.22
GnuPG::Interface v0.48