From a485d370c24cb6378a52c3452dc0cdbadfefd50f Mon Sep 17 00:00:00 2001 From: rowanbeentje Date: Wed, 20 Jan 2010 23:51:15 +0000 Subject: Address Issue #546 (format string bugs): - Fix incorrect uses of [NSString stringWithFormat:] with preconstructed strings and no arguments in SPUserManager - To fix display issues, replace NSBeginAlertSheet (which includes automatic sprintf expansion of the message) with a safely-escaped SPBeginAlertSheet in many files --- Source/CustomQuery.m | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'Source/CustomQuery.m') diff --git a/Source/CustomQuery.m b/Source/CustomQuery.m index e35a7b26..790db8f5 100644 --- a/Source/CustomQuery.m +++ b/Source/CustomQuery.m @@ -42,6 +42,7 @@ #import "SPConstants.h" #import "SPEncodingPopupAccessory.h" #import "SPDataStorage.h" +#import "SPAlertSheets.h" @implementation CustomQuery @@ -162,7 +163,7 @@ // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will // only be enabled if the query text view has at least one character present. if ([[textView string] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); return; } @@ -179,7 +180,7 @@ // This should never evaluate to true as we are now performing menu validation, meaning the 'Save Query to Favorites' menu item will // only be enabled if the query text view has at least one character present. if ([[textView string] isEqualToString:@""]) { - NSBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Empty query", @"empty query message"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"Cannot save an empty query.", @"empty query informative message")); return; } @@ -1545,7 +1546,7 @@ // Check for errors while UPDATE if ( ![[mySQLConnection getLastErrorMessage] isEqualToString:@""] ) { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), NSLocalizedString(@"Cancel", @"cancel button"), nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Couldn't write field.\nMySQL said: %@", @"message of panel when error while updating field to db"), [mySQLConnection getLastErrorMessage]]); return; @@ -1555,7 +1556,7 @@ // This shouldn't happen – for safety reasons if ( ![mySQLConnection affectedRows] ) { if ( [prefs boolForKey:SPShowNoAffectedRowsError] ) { - NSBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Warning", @"warning"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, NSLocalizedString(@"The row was not written to the MySQL database. You probably haven't changed anything.\nReload the table to be sure that the row exists and use a primary key for your table.\n(This error can be turned off in the preferences.)", @"message of panel when no rows have been affected after writing to the db")); } else { NSBeep(); @@ -1569,7 +1570,7 @@ [self performQueries:[NSArray arrayWithObject:lastExecutedQuery] withCallback:NULL]; } else { - NSBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, + SPBeginAlertSheet(NSLocalizedString(@"Error", @"error"), NSLocalizedString(@"OK", @"OK button"), nil, nil, tableWindow, self, nil, nil, nil, [NSString stringWithFormat:NSLocalizedString(@"Updating field content failed. Couldn't identify field origin unambiguously (%ld match%@). It's very likely that while editing this field the table `%@` was changed by an other user.", @"message of panel when error while updating field to db after enabling it"), (long)numberOfPossibleUpdateRows, (numberOfPossibleUpdateRows>1)?@"es":@"", tableForColumn]); -- cgit v1.2.3