parser: Pass global object to sax->setDocumentLocator

Revert part of commit c011e760.

Fixes #732.
This commit is contained in:
Nick Wellnhofer 2024-06-14 16:41:43 +02:00
parent 3b4a84e4b7
commit 039ce1e821
2 changed files with 10 additions and 19 deletions

View File

@ -4753,12 +4753,9 @@ htmlParseDocument(htmlParserCtxtPtr ctxt) {
if ((ctxt == NULL) || (ctxt->input == NULL))
return(-1);
/*
* Document locator is unused. Only for backward compatibility.
*/
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
xmlSAXLocator copy = xmlDefaultSAXLocator;
ctxt->sax->setDocumentLocator(ctxt->userData, &copy);
ctxt->sax->setDocumentLocator(ctxt->userData,
(xmlSAXLocator *) &xmlDefaultSAXLocator);
}
xmlDetectEncoding(ctxt);
@ -5297,8 +5294,8 @@ htmlParseTryOrFinish(htmlParserCtxtPtr ctxt, int terminate) {
avail = in->end - in->cur;
}
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
xmlSAXLocator copy = xmlDefaultSAXLocator;
ctxt->sax->setDocumentLocator(ctxt->userData, &copy);
ctxt->sax->setDocumentLocator(ctxt->userData,
(xmlSAXLocator *) &xmlDefaultSAXLocator);
}
if ((ctxt->sax) && (ctxt->sax->startDocument) &&
(!ctxt->disableSAX))

View File

@ -10496,12 +10496,9 @@ xmlParseDocument(xmlParserCtxtPtr ctxt) {
*/
xmlCtxtInitializeLate(ctxt);
/*
* Document locator is unused. Only for backward compatibility.
*/
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
xmlSAXLocator copy = xmlDefaultSAXLocator;
ctxt->sax->setDocumentLocator(ctxt->userData, &copy);
ctxt->sax->setDocumentLocator(ctxt->userData,
(xmlSAXLocator *) &xmlDefaultSAXLocator);
}
xmlDetectEncoding(ctxt);
@ -10626,12 +10623,9 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
xmlCtxtInitializeLate(ctxt);
/*
* Document locator is unused. Only for backward compatibility.
*/
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
xmlSAXLocator copy = xmlDefaultSAXLocator;
ctxt->sax->setDocumentLocator(ctxt->userData, &copy);
ctxt->sax->setDocumentLocator(ctxt->userData,
(xmlSAXLocator *) &xmlDefaultSAXLocator);
}
xmlDetectEncoding(ctxt);
@ -11095,8 +11089,8 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
}
}
if ((ctxt->sax) && (ctxt->sax->setDocumentLocator)) {
xmlSAXLocator copy = xmlDefaultSAXLocator;
ctxt->sax->setDocumentLocator(ctxt->userData, &copy);
ctxt->sax->setDocumentLocator(ctxt->userData,
(xmlSAXLocator *) &xmlDefaultSAXLocator);
}
if ((ctxt->sax) && (ctxt->sax->startDocument) &&
(!ctxt->disableSAX))