FasterXML / jackson-dataformat-xml

Extension for Jackson JSON processor that adds support for serializing POJOs as XML (and deserializing from XML) as an alternative to JSON
Apache License 2.0
562 stars 221 forks source link

@JacksonXmlCData breaks for strings containing "]]>" #557

Closed anguptaqualys closed 1 year ago

anguptaqualys commented 1 year ago

@JacksonXmlCData is unable to parse string when it contains CDATA end token i.e. "]]>". It throws below error: Caused by: javax.xml.stream.XMLStreamException: Illegal input: CDATA block has embedded ]]> in it (index 146,104)

Please someone provide a workaround to serialize a data with @JacksonXmlCData containing "]]>". I used jackson-dataformat:2.11.3

cowtowncoder commented 1 year ago

Quick note: 2.11.3 is a very old version, 2.11 no longer supported. So please try with a newer version; 2.13.4 or 2.14.1.

But beyond that: we'd need a full reproduction here; description is not enough to see what exactly is happening. Description is confusing as it refers to both "serialization" and "parsing" -- is Jackson used to write something and read? Or is this some external XML?

cowtowncoder commented 1 year ago

Also note that "]]>" is invalid XML -- it should NOT be accepted by XML parser as per XML specification.

However conversely content with embedded "]]>" should not be written -- but CDATA sections have no escaping so caller needs to be aware of the problem.

Will close, however since the original request is not quite clear on full context. But there is really no way to legally allow such content.