Closed tatsel closed 5 months ago
I added the mentioned test and potential fix in this pull-request https://github.com/FasterXML/aalto-xml/pull/87, please check if this is the correct way to address the issue.
Thank you for both reporting the issue and providing both reproduction and fix! I decided to check couple of other cases as well and similar issue affected comments (#91) and processing instructions (#93) too, so fixed those as well.
I can release 1.3.3 soon, but wanted to give you a chance to see if I missed anything with fix, before publishing.
Thank you for the quick response! I'm glad I helped to find this. There are no more comments from my end, will wait for the release.
This issue seems to be similar to the one fixed here https://github.com/FasterXML/aalto-xml/pull/75/commits, though the cause is a bit different:
I get 'javax.xml.stream.XMLStreamException: Incomplete surrogate pair in content: first char 0xdfce, second 0x78' exception when I try to write CData with multi-byte char sitting right at the border of 512-sized internal buffer.
Example test to reproduce (copied from https://github.com/FasterXML/aalto-xml/blob/master/src/test/java/com/fasterxml/aalto/sax/TestSaxWriter.java#L10 and slightly adjusted for writeCData()):
I think the reason is that ByteXmlWriter#writeCDataContents() lacks this piece of code which exists in writeCharacters():