From 1879d879b2abe4cb2dc49f6743a8f61c2a2bbeda Mon Sep 17 00:00:00 2001 From: "stuart.morgan%alumni.case.edu" Date: Thu, 8 Mar 2007 18:33:24 +0000 Subject: [PATCH] Camino only - Bug 372942: Don't pick up Safar's pseudo-negative keychain entries as accounts. r=josh sr=pink git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@221560 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/camino/src/formfill/KeychainService.mm | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mozilla/camino/src/formfill/KeychainService.mm b/mozilla/camino/src/formfill/KeychainService.mm index aa0989fe369..7514f7b4c28 100644 --- a/mozilla/camino/src/formfill/KeychainService.mm +++ b/mozilla/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;