mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-24 13:33:01 +03:00
parser: Don't modify SAX2 handler if XML_PARSE_SAX1 is set
It's a bad idea to modify members of the SAX handler struct for option state management. Ideally, ctxt->options should be the preferred source of truth.
This commit is contained in:
7
parser.c
7
parser.c
@@ -950,7 +950,9 @@ xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
|
||||
* Only enable SAX2 if there SAX2 element handlers, except when there
|
||||
* are no element handlers at all.
|
||||
*/
|
||||
if ((sax) && (sax->initialized == XML_SAX2_MAGIC) &&
|
||||
if (((ctxt->options & XML_PARSE_SAX1) == 0) &&
|
||||
(sax) &&
|
||||
(sax->initialized == XML_SAX2_MAGIC) &&
|
||||
((sax->startElementNs != NULL) ||
|
||||
(sax->endElementNs != NULL) ||
|
||||
((sax->startElement == NULL) && (sax->endElement == NULL))))
|
||||
@@ -13412,9 +13414,6 @@ xmlCtxtUseOptions(xmlParserCtxtPtr ctxt, int options)
|
||||
}
|
||||
#ifdef LIBXML_SAX1_ENABLED
|
||||
if (options & XML_PARSE_SAX1) {
|
||||
ctxt->sax->startElementNs = NULL;
|
||||
ctxt->sax->endElementNs = NULL;
|
||||
ctxt->sax->initialized = 1;
|
||||
options -= XML_PARSE_SAX1;
|
||||
ctxt->options |= XML_PARSE_SAX1;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user