NSXMLParser silently drops internal entities
Originator: | iosdeveloperzone | ||
Number: | rdar://22358140 | Date Originated: | 20-Aug-2015 01:16 AM |
Status: | Open | Resolved: | |
Product: | iOS | Product Version: | 8.4 |
Classification: | Serious Bug | Reproducible: | Always |
Summary: Given an XML file with internal entity definitions, NSXMLParser ignores entity references, that is it never calls parser:foundCharacters: with the entity reference expansion. For example, given the file: <?xml version="1.0" standalone="yes" ?> <!DOCTYPE foo [ <!ENTITY bar "Johnnie Fox's"> ]> <foo> Entity expansion test begin &bar; end. </foo> The parser will make the following delegate calls (ellipses indicate places where parameters have been removed for clarity): -[… parserDidStartDocument:…] -[… foundInternalEntityDeclarationWithName:@"bar" value:@"Johnnie Fox's"] -[… didStartElement:@"foo" namespaceURI:nil qualifiedName:nil attributes:{ }] -[… foundCharacters:@" Entity expansion test begin "] -[… foundCharacters:@" end. "] -[… didEndElement:@"foo" namespaceURI:nil qualifiedName:nil] -[… parserDidEndDocument:…] The parser exits successfully and no error is reported. Steps to Reproduce: Run any XML that contains an internal entity reference (such as the example above) through NSXMLParser and observe the delegate calls. Alternatively, run the test testInternalEntityReference in the attached Xcode workspace and examine the NSLog and/or notice the test fails. Expected Results: Given that NSXMLParser has no delegate method that is called when an internal entity reference is encountered, it is reasonable to expect that the expanded entity would be passed to the delegate in a call to parser:foundCharacter. Using the example above and ignoring some irrelevant calls this would look like this: … -[… foundCharacters:@" Entity expansion test begin "] -[… foundCharacters:@"Johnnie Fox's"] -[… foundCharacters:@" end. "] … Actual Results: See summary above Regression: I could not find a version of NSXMLParser where this worked. Both libxml2 and expat handle this correctly. Notes: Provide additional information, such as references to related problems, workarounds and relevant attachments.
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!
Still open after all these years.
This is now FB22358140