diff --git a/ChangeLog b/ChangeLog index 170f4a0..f5860d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -3,6 +3,9 @@ * EOAccess/EOGenericRecord.h/m ([-entity]): New category. * EOAccess/GNUmakefile (EOGenericRecord): Build and install new category. + + * EOControl/EOPrivate.h/m (GDL2_isLegalDBName): New function. + * EOQualifier.m (getKey): Validate qualifier bind variable key. 2009-02-18 David Ayers diff --git a/EOControl/EOPrivate.h b/EOControl/EOPrivate.h index c57635b..7032596 100644 --- a/EOControl/EOPrivate.h +++ b/EOControl/EOPrivate.h @@ -362,7 +362,7 @@ GDL2CONTROL_EXPORT unsigned int EOMKKDInitializer_indexForKeyWithImpPtr(EOMKKDIn // ==== EOEditingContext ==== GDL2CONTROL_EXPORT id EOEditingContext_objectForGlobalIDWithImpPtr(EOEditingContext* edContext,IMP* impPtr,EOGlobalID* gid); -EOGlobalID* EOEditingContext_globalIDForObjectWithImpPtr(EOEditingContext* edContext,IMP* impPtr,id object); +GDL2CONTROL_EXPORT EOGlobalID* EOEditingContext_globalIDForObjectWithImpPtr(EOEditingContext* edContext,IMP* impPtr,id object); GDL2CONTROL_EXPORT id EOEditingContext_recordObjectGlobalIDWithImpPtr(EOEditingContext* edContext,IMP* impPtr,id object,EOGlobalID* gid); @@ -371,6 +371,10 @@ GDL2CONTROL_EXPORT id EOEditingContext_recordObjectGlobalIDWithImpPtr(EOEditingC GDL2CONTROL_EXPORT void EOHashAddTable(NSHashTable *to, NSHashTable *from); +// ==== hash convienience functions ==== + +GDL2CONTROL_EXPORT BOOL GDL2_isLegalDBName(NSString *name); + // ==== Memory Management Utilities ==== @interface NSObject (DeallocHack) diff --git a/EOControl/EOPrivate.m b/EOControl/EOPrivate.m index ea617b4..f0f9497 100644 --- a/EOControl/EOPrivate.m +++ b/EOControl/EOPrivate.m @@ -642,3 +642,27 @@ static SEL eqSel; } @end + + +BOOL +GDL2_isLegalDBName(NSString* name) +{ + static NSCharacterSet *illegalSet = nil; + NSRange range; + + if (illegalSet == nil) + { + NSMutableCharacterSet *mutableSet; + illegalSet = [NSCharacterSet alphanumericCharacterSet]; + mutableSet = AUTORELEASE([illegalSet mutableCopy]); + [mutableSet addCharactersInString:@"_-"]; + illegalSet = RETAIN([mutableSet invertedSet]); + } + + if (![name length]) + { + return NO; + } + range = [name rangeOfCharacterFromSet: illegalSet]; + return (range.location == NSNotFound) ? YES : NO; +} diff --git a/EOControl/EOQualifier.m b/EOControl/EOQualifier.m index ced6da8..dd74afb 100644 --- a/EOControl/EOQualifier.m +++ b/EOControl/EOQualifier.m @@ -502,12 +502,19 @@ getKey(const unichar **cFormat, if (classString && (!(quoted || literalNumber))) { [NSException raise:NSInvalidArgumentException - format:@"expected string literal after cast to class"]; + format:@"expected string literal after cast to class"]; } /* not sure about this !isQualVar */ if (isQualVar) { + if (!GDL2_isLegalDBName(key)) + { + NSString *format + = [NSString stringWithFormat: @"illegal qualifier variable $%@",key]; + [NSException raise:NSInvalidArgumentException + format:format]; + } key = (id)[[EOQualifierVariable alloc] initWithKey:key]; } else if (isKeyValue)