mirror of
https://github.com/inverse-inc/sogo.git
synced 2026-04-29 08:49:27 +00:00
(fix) make sure we safely escape all chars
This commit is contained in:
committed by
Francis Lachapelle
parent
3a96b3b315
commit
6649d7101e
@@ -709,7 +709,7 @@ static Class iCalEventK = nil;
|
||||
if ([title length])
|
||||
[baseWhere
|
||||
addObject: [NSString stringWithFormat: @"c_title isCaseInsensitiveLike: '%%%@%%'",
|
||||
[title stringByReplacingString: @"'" withString: @"\\'\\'"]]];
|
||||
[title asSafeSQLString]]];
|
||||
|
||||
if (component)
|
||||
{
|
||||
@@ -1450,14 +1450,14 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
if ([filters isEqualToString:@"title_Category_Location"] || [filters isEqualToString:@"entireContent"])
|
||||
{
|
||||
[baseWhere addObject: [NSString stringWithFormat: @"(c_title isCaseInsensitiveLike: '%%%@%%' OR c_category isCaseInsensitiveLike: '%%%@%%' OR c_location isCaseInsensitiveLike: '%%%@%%')",
|
||||
[title stringByReplacingString: @"'" withString: @"\\'\\'"],
|
||||
[title stringByReplacingString: @"'" withString: @"\\'\\'"],
|
||||
[title stringByReplacingString: @"'" withString: @"\\'\\'"]]];
|
||||
[title asSafeSQLString],
|
||||
[title asSafeSQLString],
|
||||
[title asSafeSQLString]]];
|
||||
}
|
||||
}
|
||||
else
|
||||
[baseWhere addObject: [NSString stringWithFormat: @"c_title isCaseInsensitiveLike: '%%%@%%'",
|
||||
[title stringByReplacingString: @"'" withString: @"\\'\\'"]]];
|
||||
[title asSafeSQLString]]];
|
||||
}
|
||||
|
||||
/* prepare mandatory fields */
|
||||
@@ -2610,7 +2610,7 @@ firstInstanceCalendarDateRange: (NGCalendarDateRange *) fir
|
||||
if (uid && folder)
|
||||
{
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat: @"c_uid = %@",
|
||||
uid];
|
||||
[uid asSafeSQLString]];
|
||||
records = [folder fetchFields: nameFields matchingQualifier: qualifier];
|
||||
count = [records count];
|
||||
if (count)
|
||||
|
||||
@@ -109,7 +109,7 @@ static NSArray *folderListingFields = nil;
|
||||
NSString *component;
|
||||
Class objectClass;
|
||||
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat:@"c_name = %@", name];
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat: @"c_name = %@", [name asSafeSQLString]];
|
||||
records = [[self ocsFolder] fetchFields: [NSArray arrayWithObject: @"c_component"]
|
||||
matchingQualifier: qualifier];
|
||||
|
||||
@@ -178,8 +178,7 @@ static NSArray *folderListingFields = nil;
|
||||
|
||||
if ([filter length] > 0)
|
||||
{
|
||||
filter = [[filter stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"'" withString: @"\\'\\'"];
|
||||
filter = [filter asSafeSQLString];
|
||||
if ([criteria isEqualToString: @"name_or_address"])
|
||||
qs = [NSString stringWithFormat:
|
||||
@"(c_sn isCaseInsensitiveLike: '%%%@%%') OR "
|
||||
@@ -281,8 +280,7 @@ static NSArray *folderListingFields = nil;
|
||||
|
||||
if (aName && [aName length] > 0)
|
||||
{
|
||||
aName = [[aName stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"'" withString: @"\\'\\'"];
|
||||
aName = [aName asSafeSQLString];
|
||||
qs = [NSString stringWithFormat: @"(c_name='%@')", aName];
|
||||
qualifier = [EOQualifier qualifierWithQualifierFormat: qs];
|
||||
dbRecords = [[self ocsFolder] fetchFields: folderListingFields
|
||||
|
||||
@@ -688,8 +688,9 @@ static int cssEscapingCount;
|
||||
|
||||
- (NSString *) asSafeSQLString
|
||||
{
|
||||
return [[self stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"'" withString: @"\\'"];
|
||||
return [[[self stringByReplacingString: @"\\" withString: @"\\\\"]
|
||||
stringByReplacingString: @"'" withString: @"\\'"]
|
||||
stringByReplacingString: @"\%" withString: @"\\%"];
|
||||
}
|
||||
|
||||
- (NSUInteger) countOccurrencesOfString: (NSString *) substring
|
||||
|
||||
Reference in New Issue
Block a user