aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Interfaces/English.lproj/ConnectionView.xib4
-rw-r--r--Source/SPConnectionController.m37
-rw-r--r--Source/TableDocument.m4
3 files changed, 22 insertions, 23 deletions
diff --git a/Interfaces/English.lproj/ConnectionView.xib b/Interfaces/English.lproj/ConnectionView.xib
index 916cfd05..2eb2d7a1 100644
--- a/Interfaces/English.lproj/ConnectionView.xib
+++ b/Interfaces/English.lproj/ConnectionView.xib
@@ -8,7 +8,7 @@
<string key="IBDocument.HIToolboxVersion">353.00</string>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
- <integer value="4826"/>
+ <integer value="4888"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
<bool key="EncodedWithXMLCoder">YES</bool>
@@ -1122,7 +1122,7 @@
<reference key="NSSuperview" ref="735564334"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="220047154">
- <int key="NSCellFlags">604110336</int>
+ <int key="NSCellFlags">67239424</int>
<int key="NSCellFlags2">134217728</int>
<string key="NSContents">Add to Favorites</string>
<reference key="NSSupport" ref="807120225"/>
diff --git a/Source/SPConnectionController.m b/Source/SPConnectionController.m
index baef9691..6670c732 100644
--- a/Source/SPConnectionController.m
+++ b/Source/SPConnectionController.m
@@ -657,8 +657,8 @@
{
NSString *thePassword, *theSSHPassword;
NSNumber *favoriteid = [NSNumber numberWithInt:[[NSString stringWithFormat:@"%f", [[NSDate date] timeIntervalSince1970]] hash]];
- NSString *favoriteName = [[self name] length]?[self name]:[NSString stringWithFormat:@"%@@%@", [self user], [self host]];
- if (![[self name] length] && ![[self database] isEqualToString:@""])
+ NSString *favoriteName = [[self name] length]?[self name]:[NSString stringWithFormat:@"%@@%@", ([self user] && [[self user] length])?[self user]:@"anonymous", [self host]];
+ if (![[self name] length] && [self database] && ![[self database] isEqualToString:@""])
favoriteName = [NSString stringWithFormat:@"%@ %@", [self database], favoriteName];
// Ensure that host is not empty if this is a TCP/IP or SSH connection
@@ -676,21 +676,20 @@
// Ensure that a socket connection is not inadvertently used
if (![self checkHost]) return;
- // Construct the favorite details
- NSDictionary *newFavorite = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:[self type]], @"type",
- favoriteName, @"name",
- [self host], @"host",
- [self socket], @"socket",
- [self user], @"user",
- [self port], @"port",
- [self database], @"database",
- [self sshHost], @"sshHost",
- [self sshUser], @"sshUser",
- [self sshPort], @"sshPort",
- favoriteid, @"id",
- nil];
-
+ // Construct the favorite details - cannot use only dictionaryWithObjectsAndKeys for possible nil values.
+ NSMutableDictionary *newFavorite = [NSMutableDictionary dictionaryWithObjectsAndKeys:
+ [NSNumber numberWithInt:[self type]], @"type",
+ favoriteName, @"name",
+ [self host], @"host",
+ favoriteid, @"id",
+ nil];
+ if ([self socket]) [newFavorite setObject:[self socket] forKey:@"socket"];
+ if ([self user]) [newFavorite setObject:[self user] forKey:@"user"];
+ if ([self port]) [newFavorite setObject:[self port] forKey:@"port"];
+ if ([self database]) [newFavorite setObject:[self database] forKey:@"database"];
+ if ([self sshHost]) [newFavorite setObject:[self sshHost] forKey:@"sshHost"];
+ if ([self sshUser]) [newFavorite setObject:[self sshUser] forKey:@"sshUser"];
+ if ([self sshPort]) [newFavorite setObject:[self sshPort] forKey:@"sshPort"];
// Add the new favorite to the user defaults array
NSMutableArray *currentFavorites;
@@ -708,7 +707,7 @@
if (mySQLConnection && connectionKeychainItemName) {
thePassword = [keychain getPasswordForName:connectionKeychainItemName account:connectionKeychainItemAccount];
}
- if (![thePassword isEqualToString:@""]) {
+ if (thePassword && ![thePassword isEqualToString:@""]) {
[keychain addPassword:thePassword
forName:[keychain nameForFavoriteName:favoriteName id:[NSString stringWithFormat:@"%i", [favoriteid intValue]]]
account:[keychain accountForUser:[self user] host:[self host] database:[self database]]];
@@ -719,7 +718,7 @@
if (mySQLConnection && connectionSSHKeychainItemName) {
theSSHPassword = [keychain getPasswordForName:connectionSSHKeychainItemName account:connectionSSHKeychainItemAccount];
}
- if (![theSSHPassword isEqualToString:@""]) {
+ if (theSSHPassword && ![theSSHPassword isEqualToString:@""]) {
[keychain addPassword:theSSHPassword
forName:[keychain nameForSSHForFavoriteName:favoriteName id:[NSString stringWithFormat:@"%i", [favoriteid intValue]]]
account:[keychain accountForSSHUser:[self sshUser] sshHost:[self sshHost]]];
diff --git a/Source/TableDocument.m b/Source/TableDocument.m
index 1063070b..1057be90 100644
--- a/Source/TableDocument.m
+++ b/Source/TableDocument.m
@@ -1445,9 +1445,9 @@
return [connectionController name];
}
if ([connectionController type] == SP_CONNECTION_SOCKET) {
- return [NSString stringWithFormat:@"%@@localhost", [connectionController user]?[connectionController user]:@""];
+ return [NSString stringWithFormat:@"%@@localhost", ([connectionController user] && [[connectionController user] length])?[connectionController user]:@"anonymous"];
}
- return [NSString stringWithFormat:@"%@@%@", [connectionController user]?[connectionController user]:@"", [connectionController host]?[connectionController host]:@""];
+ return [NSString stringWithFormat:@"%@@%@", ([connectionController user] && [[connectionController user] length])?[connectionController user]:@"anonymous", [connectionController host]?[connectionController host]:@""];
}
/**