mirror of
https://github.com/gnustep/libs-gdl2.git
synced 2025-05-31 09:21:02 +00:00
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m
(-formatValue:forAttribute:): Use unichars, and getCharacter:. in case insertString: modifies the string buffer. * EOAdaptors/SQLiteAdaptor/SQLiteExpression.m (escapeString): Ditto. Rename to escapeValue, since it works on values other than strings. git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/gdl2/trunk@26320 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
parent
0fa50e111d
commit
c691d6043d
3 changed files with 53 additions and 54 deletions
|
@ -1,3 +1,11 @@
|
||||||
|
2008-03-16 Matt Rice <ratmice@gmail.com>
|
||||||
|
|
||||||
|
* EOAdaptors/PostgreSQLAdaptor/PostgreSQLExpression.m
|
||||||
|
(-formatValue:forAttribute:): Use unichars, and getCharacter:.
|
||||||
|
in case insertString: modifies the string buffer.
|
||||||
|
* EOAdaptors/SQLiteAdaptor/SQLiteExpression.m (escapeString): Ditto.
|
||||||
|
Rename to escapeValue, since it works on values other than strings.
|
||||||
|
|
||||||
2008-03-16 Tim McIntosh <tmcintos@avalon.net>
|
2008-03-16 Tim McIntosh <tmcintos@avalon.net>
|
||||||
|
|
||||||
* EOControl/EOKeyValueCoding.m
|
* EOControl/EOKeyValueCoding.m
|
||||||
|
|
|
@ -97,9 +97,6 @@ RCS_ID("$Id$")
|
||||||
{
|
{
|
||||||
NSString *formatted = nil;
|
NSString *formatted = nil;
|
||||||
NSString *externalType;
|
NSString *externalType;
|
||||||
NSMutableString *string;
|
|
||||||
const char *tempString;
|
|
||||||
int i, dif;
|
|
||||||
|
|
||||||
EOFLOGObjectFnStart();
|
EOFLOGObjectFnStart();
|
||||||
|
|
||||||
|
@ -332,46 +329,36 @@ RCS_ID("$Id$")
|
||||||
}
|
}
|
||||||
else // String...
|
else // String...
|
||||||
{
|
{
|
||||||
int length = 0;
|
NSMutableString *string = [NSMutableString stringWithFormat:@"%@", value];
|
||||||
|
unsigned i, dif;
|
||||||
|
unsigned length = [string length];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression",
|
if (length > 0)
|
||||||
@"other case - value=%@ class=%@",
|
|
||||||
value, [value class]);
|
|
||||||
|
|
||||||
string = [NSMutableString stringWithFormat: @"%@", value];
|
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"string %p='%@'",
|
|
||||||
string, string);
|
|
||||||
|
|
||||||
length=[string cStringLength];
|
|
||||||
tempString = [string cString];
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"string '%@' tempString=%s",
|
|
||||||
string, tempString);
|
|
||||||
|
|
||||||
for (i = 0, dif = 0; i < length; i++)
|
|
||||||
{
|
{
|
||||||
switch (tempString[i])
|
unichar tempString[length];
|
||||||
|
|
||||||
|
[string getCharacters:tempString];
|
||||||
|
|
||||||
|
for (i = 0, dif = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
case '\\':
|
switch (tempString[i])
|
||||||
case '\'':
|
{
|
||||||
[string insertString: @"\\" atIndex: dif + i];
|
case '\\':
|
||||||
dif++;
|
case '\'':
|
||||||
break;
|
[string insertString: @"\\" atIndex: dif + i];
|
||||||
case '_':
|
dif++;
|
||||||
[string insertString: @"\\" atIndex: dif + i];
|
break;
|
||||||
dif++;
|
case '_':
|
||||||
break;
|
[string insertString: @"\\" atIndex: dif + i];
|
||||||
default:
|
dif++;
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"string '%@' tempString=%s",
|
|
||||||
string, tempString);
|
|
||||||
|
|
||||||
formatted = [NSString stringWithFormat: @"'%@'", string];
|
formatted = [NSString stringWithFormat: @"'%@'", string];
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"formatted %p=%@",
|
|
||||||
formatted, formatted);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"formatted=%@", formatted);
|
EOFLOGObjectLevelArgs(@"EOSQLExpression", @"formatted=%@", formatted);
|
||||||
|
|
|
@ -37,27 +37,31 @@
|
||||||
#include <Foundation/NSData.h>
|
#include <Foundation/NSData.h>
|
||||||
|
|
||||||
@implementation SQLite3Expression
|
@implementation SQLite3Expression
|
||||||
static NSString *escapeString(NSString *value)
|
static NSString *escapeValue(id value)
|
||||||
{
|
{
|
||||||
int length = 0, dif, i;
|
|
||||||
NSMutableString *string = [NSMutableString stringWithFormat: @"%@", value];
|
NSMutableString *string = [NSMutableString stringWithFormat: @"%@", value];
|
||||||
const char *tempString;
|
unsigned length = [string length];
|
||||||
|
unsigned dif, i;
|
||||||
length=[string cStringLength];
|
|
||||||
tempString = [string cString];
|
|
||||||
|
|
||||||
for (i = 0, dif = 0; i < length; i++)
|
if (length)
|
||||||
{
|
{
|
||||||
switch (tempString[i])
|
unichar tempString[length];
|
||||||
|
|
||||||
|
[string getCharacters:tempString];
|
||||||
|
|
||||||
|
for (i = 0, dif = 0; i < length; i++)
|
||||||
{
|
{
|
||||||
case '\'':
|
switch (tempString[i])
|
||||||
[string insertString: @"'" atIndex: dif + i];
|
{
|
||||||
dif++;
|
case '\'':
|
||||||
break;
|
[string insertString: @"'" atIndex: dif + i];
|
||||||
default:
|
dif++;
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return string;
|
return string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +80,7 @@ static NSString *escapeString(NSString *value)
|
||||||
}
|
}
|
||||||
else if ([externalType isEqual:@"TEXT"])
|
else if ([externalType isEqual:@"TEXT"])
|
||||||
{
|
{
|
||||||
return [NSString stringWithFormat:@"'%@'", escapeString(value)];
|
return [NSString stringWithFormat:@"'%@'", escapeValue(value)];
|
||||||
}
|
}
|
||||||
else if ([externalType isEqual:@"BLOB"])
|
else if ([externalType isEqual:@"BLOB"])
|
||||||
{
|
{
|
||||||
|
@ -84,7 +88,7 @@ static NSString *escapeString(NSString *value)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return [NSString stringWithFormat:@"'%@'", escapeString(value)];
|
return [NSString stringWithFormat:@"'%@'", escapeValue(value)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
- (NSString *)lockClause
|
- (NSString *)lockClause
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue