LibXML: Add parser hooks for CDATASection and ProcessingInstructions

This allows listeners to be notified when a CDATASection or
ProcessingInstruction is encountered during parsing. The non-listener
path still has the incorrect behavior of silently treating CDATASection
as Text nodes, but this allows listeners to handle them correctly.
This commit is contained in:
Andrew Kaster 2025-07-18 12:32:50 -06:00 committed by Ali Mohammad Pur
commit d9976b98b9
Notes: github-actions[bot] 2025-07-19 12:57:43 +00:00
2 changed files with 28 additions and 2 deletions

View file

@ -40,6 +40,8 @@ struct Listener {
virtual void element_start(Name const&, HashMap<Name, ByteString> const&) { }
virtual void element_end(Name const&) { }
virtual void text(StringView) { }
virtual void cdata_section(StringView) { }
virtual void processing_instruction(StringView, StringView) { }
virtual void comment(StringView) { }
virtual void error(ParseError const&) { }
};
@ -82,6 +84,8 @@ private:
void append_node(NonnullOwnPtr<Node>);
void append_text(StringView, LineTrackingLexer::Position);
void append_comment(StringView, LineTrackingLexer::Position);
void append_cdata_section(StringView, LineTrackingLexer::Position);
void append_processing_instruction(StringView target, StringView data);
void enter_node(Node&);
void leave_node();