register xmlSchemaSetValidErrors, patch from Brent Hendricks in the
* python/libxml.c: register xmlSchemaSetValidErrors, patch from
Brent Hendricks in the mailing-list
* include/libxml/valid.h HTMLparser.c SAX2.c valid.c
parserInternals.c: fix #156626 and more generally how to find out
if a validation contect is part of a parsing context or not. This
can probably be improved to make 100% sure that vctxt->userData
is the parser context too. It's a bit hairy because we can't
change the xmlValidCtxt structure without breaking the ABI since
this change xmlParserCtxt information indexes.
Daniel
diff --git a/valid.c b/valid.c
index b853992..3884c90 100644
--- a/valid.c
+++ b/valid.c
@@ -59,7 +59,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
if (extra)
__xmlRaiseError(NULL, channel, data,
@@ -92,7 +97,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
if (extra)
__xmlRaiseError(NULL, channel, data,
@@ -132,7 +142,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
@@ -168,7 +183,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0,
@@ -202,7 +222,12 @@
if (ctxt != NULL) {
channel = ctxt->error;
data = ctxt->userData;
- pctxt = ctxt->userData;
+ /* Use the special values to detect if it is part of a parsing
+ context */
+ if ((ctxt->finishDtd == XML_CTXT_FINISH_DTD_0) ||
+ (ctxt->finishDtd == XML_CTXT_FINISH_DTD_1)) {
+ pctxt = ctxt->userData;
+ }
}
__xmlRaiseError(schannel, channel, data, pctxt, node, XML_FROM_VALID, error,
XML_ERR_WARNING, NULL, 0,