Author: thebeing Date: Mon Oct 24 12:52:44 2016 New Revision: 40172 URL: http://svn.gna.org/viewcvs/gnustep?rev=40172&view=rev Log: Allow XML coders to use the 'sloppy' parser from gnustep-base instead of the libxml2 based one.
Modified: libs/webservices/trunk/ChangeLog libs/webservices/trunk/GWSCoder.h libs/webservices/trunk/GWSCoder.m Modified: libs/webservices/trunk/ChangeLog URL: http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/ChangeLog?rev=40172&r1=40171&r2=40172&view=diff ============================================================================== --- libs/webservices/trunk/ChangeLog (original) +++ libs/webservices/trunk/ChangeLog Mon Oct 24 12:52:44 2016 @@ -1,3 +1,7 @@ +2016-10-24 Niels Grewe <niels.gr...@halbordnung.de> + + * GWSCoder.[hm]: Allow XML coders to use the 'sloppy' XML parser. + 2016-07-19 Richard Frith-Macdonald <r...@gnu.org> * GWSCoder.m: Add ([-setCRLF:]) method to allow generation of XML Modified: libs/webservices/trunk/GWSCoder.h URL: http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GWSCoder.h?rev=40172&r1=40171&r2=40172&view=diff ============================================================================== --- libs/webservices/trunk/GWSCoder.h (original) +++ libs/webservices/trunk/GWSCoder.h Mon Oct 24 12:52:44 2016 @@ -89,6 +89,8 @@ unsigned _level; // Current indentation level. NSMutableString *_ms; // Not retained. id _delegate; // Not retained. + BOOL _preferSloppyParser; // Whether the old GNUstep + // parser should be preferred } /** Creates and returns an autoreleased instance.<br /> @@ -210,6 +212,17 @@ */ - (void) unindent; +/** + * Whether the old non-libxml2 parser in GNUstep should be preferred. + */ +- (BOOL)preferSloppyParser; + +/** + * Specifies whether the old non-libxml2 parser should be preferred if + * available. This supports a wider range of not-entirely valid XML, but + * omits features such as external entity support. + */ +- (void)setPreferSloppyParser: (BOOL)flag; @end /** The methods in this category are used to handle web services Modified: libs/webservices/trunk/GWSCoder.m URL: http://svn.gna.org/viewcvs/gnustep/libs/webservices/trunk/GWSCoder.m?rev=40172&r1=40171&r2=40172&view=diff ============================================================================== --- libs/webservices/trunk/GWSCoder.m (original) +++ libs/webservices/trunk/GWSCoder.m Mon Oct 24 12:52:44 2016 @@ -113,6 +113,8 @@ @class GWSXMLRPCCoder; +static Class _defaultParserClass; +static Class _sloppyParserClass; @implementation GWSCoder @@ -136,13 +138,39 @@ + (void) initialize { - boolN = [[NSNumber numberWithBool: NO] retain]; - boolY = [[NSNumber numberWithBool: YES] retain]; + if (self == [GWSCoder class]) + { + boolN = [[NSNumber numberWithBool: NO] retain]; + boolY = [[NSNumber numberWithBool: YES] retain]; + _defaultParserClass = [NSXMLParser class]; + _sloppyParserClass = NSClassFromString(@"GSSloppyXMLParser"); + if (Nil == _sloppyParserClass) + { + _sloppyParserClass = _defaultParserClass; +#ifdef GNUSTEP + NSWarnMLog(@"No separate class for the sloppy parser. All parsers " + @"will be sloppy."); +#else + NSWarnMLog(@"No separate class for the sloppy parser. All parsers " + @"will be strict."); +#endif + } + } } - (BOOL) compact { return _compact; +} + +- (BOOL) preferSloppyParser +{ + return _preferSloppyParser; +} + +- (void) setPreferSloppyParser: (BOOL)flag +{ + _preferSloppyParser = flag; } - (void) dealloc @@ -727,12 +755,17 @@ - (GWSElement*) parseXML: (NSData*)xml { - NSAutoreleasePool *pool; - NSXMLParser *parser; + NSAutoreleasePool *pool = nil; + NSXMLParser *parser = nil; + Class parserClass = _defaultParserClass; pool = [NSAutoreleasePool new]; [self reset]; - parser = [[[NSXMLParser alloc] initWithData: xml] autorelease]; + if (_preferSloppyParser) + { + parserClass = _sloppyParserClass; + } + parser = [[[parserClass alloc] initWithData: xml] autorelease]; [parser setShouldProcessNamespaces: YES]; [parser setShouldReportNamespacePrefixes: YES]; _oldparser = NO; _______________________________________________ Gnustep-cvs mailing list Gnustep-cvs@gna.org https://mail.gna.org/listinfo/gnustep-cvs