Permalink
Browse files

Fixes a crash when changing key server.

[#474 state:fixed assigned:mento milestone:1.4.7]
  • Loading branch information...
Mento committed Jan 2, 2019
1 parent f7abcc9 commit fc10ab117d6dba4956c7cd99a8ada67bfc2a2e9e
Showing with 27 additions and 22 deletions.
  1. +18 −17 Source/PreferencesController.m
  2. +9 −5 Source/SheetController.m
@@ -264,24 +264,25 @@ - (void)gpgController:(GPGController *)gc operationDidFinishWithReturnValue:(id)

dispatch_async(dispatch_get_main_queue(), ^{
self.testingServer = NO;
self.keyserverToCheck = nil;

if (![value boolValue]) {
[self.options removeKeyserver:gc.keyserver];

[[SheetController sharedInstance] alertSheetForWindow:window
messageText:localized(@"BadKeyserver_Title")
infoText:localized(@"BadKeyserver_Msg")
defaultButton:nil
alternateButton:nil
otherButton:nil
suppressionButton:nil];
} else {
// The server passed the check.
// Set it as default keyserver.
self.options.keyserver = gc.keyserver;
}
});
self.keyserverToCheck = nil;

if (![value boolValue]) {
[self.options removeKeyserver:gc.keyserver];

[[SheetController sharedInstance] alertSheetForWindow:window
messageText:localized(@"BadKeyserver_Title")
infoText:localized(@"BadKeyserver_Msg")
defaultButton:nil
alternateButton:nil
otherButton:nil
suppressionButton:nil];
} else {
// The server passed the check.
// Set it as default keyserver.
self.options.keyserver = gc.keyserver;
}

}


@@ -869,7 +869,7 @@ - (void)setPassphrase:(NSString *)value {
if (_passphrase.length == 0 || _passphrase.UTF8Length > 255) {
self.passwordStrength = 0;
} else {
DBResult *result = [_zxcvbn passwordStrength:self.passphrase userInputs:self.badPasswordIngredients];
DBResult *result = [self.zxcvbn passwordStrength:self.passphrase userInputs:self.badPasswordIngredients];

double seconds = result.crackTime;
double score = log10(seconds * 1000000);
@@ -984,7 +984,13 @@ - (void)setExportSecretKey:(BOOL)value {
}
}


- (DBZxcvbn *)zxcvbn {
if (_zxcvbn == nil) {
// Lazy load DBZxcvbn.
_zxcvbn = [DBZxcvbn new];
}
return _zxcvbn;
}



@@ -1550,7 +1556,7 @@ - (BOOL)checkPassphrase {
return NO;
}
} else {
DBResult *result = [_zxcvbn passwordStrength:self.passphrase];
DBResult *result = [self.zxcvbn passwordStrength:self.passphrase];
if (result.crackTime < 3600) {
warned = YES;
if (NSRunAlertPanel(localized(@"CheckAlert_PassphraseSimple_Title"),
@@ -1701,8 +1707,6 @@ - (id)init {
NSArray *objects;
[[NSBundle mainBundle] loadNibNamed:@"ModalSheets" owner:self topLevelObjects:&objects];
_topLevelObjects = objects;

_zxcvbn = [DBZxcvbn new];
}
return self;
}

0 comments on commit fc10ab1

Please sign in to comment.