krxsh007 opened a new pull request, #30685: URL: https://github.com/apache/camel/pull/30685
# Description Fixes [CAMEL-27201](https://issues.apache.org/jira/browse/CAMEL-27201). When parsing documents to `xml` or `html` output formats with `camel-tika`, documents containing metadata with NUL (`\u0000`) or other characters invalid in XML 1.0 (such as control characters) caused the SAX `TransformerHandler` serializer to throw a fatal `SAXException`. ### Changes: - Wrapped `TransformerHandler` in `org.apache.tika.sax.SafeContentHandler` for both `xml` and `html` format paths in `TikaProducer.getContentHandler()`. `SafeContentHandler` safely replaces invalid XML characters in element attributes and character content with the Unicode replacement character (`\uFFFD`). - Added unit tests in `TikaParseTest` verifying that: - Parsing HTML and XML with invalid characters in metadata attributes succeeds without throwing `SAXException` and filters invalid characters into `\uFFFD`. - Custom parsers emitting SAX events containing invalid characters in attributes or character data are safely handled for both XML and HTML outputs. _Gemini on behalf of krxsh007_ -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
