Permalink
Browse files

[FIX] Pre-select gpgtools keys when searching on keyservers.

Some keyservers do not send the fingerprints by default.
[#475]
  • Loading branch information...
Mento committed Jan 28, 2019
1 parent fc10ab1 commit c0e37c2a7946d1479eb49a258b55608c661b428b
Showing with 20 additions and 1 deletion.
  1. +20 −1 Source/SheetController.m
@@ -1020,7 +1020,26 @@ - (BOOL)generateFoundKeyDicts {
for (GPGRemoteKey *key in _keys) {
NSDictionary *stringAttributes = nil;

BOOL isGpgtoolsKey = [key respondsToSelector:@selector(fingerprint)] && [gpgtoolsKeys containsObject:key.fingerprint];
BOOL isGpgtoolsKey = NO;
if ([key respondsToSelector:@selector(fingerprint)]) {
NSString *fingerprint = key.fingerprint;
if (fingerprint.length == 40) {
isGpgtoolsKey = [gpgtoolsKeys containsObject:fingerprint];
} else {
// Some keyservers do not return the fingerprint, but rather a key id.
for (NSString *gpgtoolsKey in gpgtoolsKeys) {
NSUInteger fingerprintLength = fingerprint.length;
NSUInteger gpgtoolsKeyLength = gpgtoolsKey.length;
if (gpgtoolsKeyLength >= fingerprintLength) {
if ([[gpgtoolsKey substringFromIndex:gpgtoolsKeyLength - fingerprintLength] isEqualToString:fingerprint]) {
isGpgtoolsKey = YES;
break;
}
}
}
}
}

NSNumber *selected = @NO;

if (key.expired || key.revoked || [key.expirationDate compare:now] == NSOrderedAscending) {

0 comments on commit c0e37c2

Please sign in to comment.