From b099e53fad99fee802ee846156b1582c6d60c603 Mon Sep 17 00:00:00 2001 From: "stuart.morgan%alumni.case.edu" Date: Thu, 8 Mar 2007 18:33:22 +0000 Subject: [PATCH] Camino only - Bug 372942: Don't pick up Safar's pseudo-negative keychain entries as accounts. r=josh sr=pink --- camino/src/formfill/KeychainService.mm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/camino/src/formfill/KeychainService.mm b/camino/src/formfill/KeychainService.mm index 8b398ca959d..e8a68bdccd3 100644 --- a/camino/src/formfill/KeychainService.mm +++ b/camino/src/formfill/KeychainService.mm @@ -249,15 +249,24 @@ int KeychainPrefChangedCallback(const char* inPref, void* unused) // Finally, check for a new style entry created by something other than Camino. // Since we don't yet have any UI for multiple accounts, we use Safari's default - // if we can find it, otherwise we just arbitrarily pick the first one. + // if we can find it, otherwise we just arbitrarily pick the first one that + // looks plausible. keychainEnumerator = [newKeychainItems objectEnumerator]; while ((item = [keychainEnumerator nextObject])) { NSString* comment = [item comment]; - if (comment && ([comment rangeOfString:@"default"].location != NSNotFound)) + if (comment && ([comment rangeOfString:@"default"].location != NSNotFound)) { + // Safari doesn't bother to set kSecNegativeItemAttr on "Passwords not saved" + // items; that's just the way they roll. This fragile method is the best we can do. + if ([[item password] isEqualToString:@" "]) + continue; return item; + } } - if ([newKeychainItems count] > 0) { - return [newKeychainItems objectAtIndex:0]; + keychainEnumerator = [newKeychainItems objectEnumerator]; + while ((item = [keychainEnumerator nextObject])) { + if ([[item password] isEqualToString:@" "]) + continue; + return item; } return nil;