diff --git a/ChangeLog b/ChangeLog index 04bbc9428..9aab7ba43 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,8 +1,9 @@ 2010-05-25 Richard Frith-Macdonald - * Source/NSPropertyList.m: ([-parser;foundChartacters:]) don't trim + * Source/NSPropertyList.m: ([-parser:foundCharacters:]) don't trim the supplied string ... we need to retain whitespace around entities - in value test. + in value test. If inside a element, treat ignorable + whitespace as normal whitespace. * Source/NSXMLParser.m: Add support for ignorable whitespace so that it doesn't get handed to the delegate as normal characters. diff --git a/Source/NSPropertyList.m b/Source/NSPropertyList.m index 9270a4699..420d192ef 100644 --- a/Source/NSPropertyList.m +++ b/Source/NSPropertyList.m @@ -87,6 +87,7 @@ extern BOOL GSScanDouble(unichar*, unsigned, double*); NSString *key; BOOL inArray; BOOL inDictionary; + BOOL inString; BOOL parsed; BOOL success; id plist; @@ -144,6 +145,15 @@ foundCharacters: (NSString *)string [value appendString: string]; } +- (void) parser: (NSXMLParser *)parser +foundIgnorableWhitespace: (NSString *)string +{ + if (YES == inString) + { + [value appendString: string]; + } +} + - (void) parser: (NSXMLParser *)parser didStartElement: (NSString *)elementName namespaceURI: (NSString *)namespaceURI @@ -182,6 +192,10 @@ foundCharacters: (NSString *)string inArray = YES; inDictionary = NO; } + else if ([elementName isEqualToString: @"string"] == YES) + { + inString = YES; + } } - (void) parser: (NSXMLParser *)parser @@ -191,11 +205,12 @@ foundCharacters: (NSString *)string { BOOL inContainer = NO; + inString = NO; if ([elementName isEqualToString: @"dict"] == YES) { inContainer = YES; } - if ([elementName isEqualToString: @"array"] == YES) + else if ([elementName isEqualToString: @"array"] == YES) { inContainer = YES; } diff --git a/Source/NSXMLParser.m b/Source/NSXMLParser.m index 242f1b526..b48171090 100644 --- a/Source/NSXMLParser.m +++ b/Source/NSXMLParser.m @@ -1314,25 +1314,25 @@ NSLog(@"_processTag <%@%@ %@>", flag?@"/": @"", tag, attributes); p--; } } - if (p < this->cp - 1 && this->foundIgnorable != 0) - { - /* Process data as ignorable whitespace - */ - s = NewUTF8STR(p, this->cp - p - 1); - (*this->foundIgnorable)(_del, - foundIgnorableSel, self, s); - [s release]; - } } if (p - vp > 0 && this->foundCharacters != 0) { - /* Process remaining data as characters + /* Process initial data as characters */ s = NewUTF8STR(vp, p - vp); (*this->foundCharacters)(_del, foundCharactersSel, self, s); [s release]; } + if (p < this->cp - 1 && this->foundIgnorable != 0) + { + /* Process data as ignorable whitespace + */ + s = NewUTF8STR(p, this->cp - p - 1); + (*this->foundIgnorable)(_del, + foundIgnorableSel, self, s); + [s release]; + } vp = this->cp; } }