mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
previous fix for #124044 was broken, correct fix provided. fix
* python/libxml.c: previous fix for #124044 was broken, correct fix provided. * HTMLparser.c parser.c parserInternals.c xmlIO.c: fix xmlStopParser() and the error handlers to address #125877 Daniel
This commit is contained in:
@ -1,3 +1,10 @@
|
|||||||
|
Fri Oct 31 11:33:18 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* python/libxml.c: previous fix for #124044 was broken, correct
|
||||||
|
fix provided.
|
||||||
|
* HTMLparser.c parser.c parserInternals.c xmlIO.c: fix xmlStopParser()
|
||||||
|
and the error handlers to address #125877
|
||||||
|
|
||||||
Thu Oct 30 23:10:46 CET 2003 Daniel Veillard <daniel@veillard.com>
|
Thu Oct 30 23:10:46 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* parser.c: side effect of #123105 patch, namespace resolution
|
* parser.c: side effect of #123105 patch, namespace resolution
|
||||||
|
@ -73,6 +73,9 @@ static void htmlParseComment(htmlParserCtxtPtr ctxt);
|
|||||||
static void
|
static void
|
||||||
htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
|
htmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
@ -103,6 +106,9 @@ static void
|
|||||||
htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
htmlParseErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, const xmlChar *str1, const xmlChar *str2)
|
const char *msg, const xmlChar *str1, const xmlChar *str2)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
|
||||||
XML_ERR_ERROR, NULL, 0,
|
XML_ERR_ERROR, NULL, 0,
|
||||||
@ -125,6 +131,9 @@ static void
|
|||||||
htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
htmlParseErrInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, int val)
|
const char *msg, int val)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_HTML, error,
|
||||||
XML_ERR_ERROR, NULL, 0, NULL, NULL,
|
XML_ERR_ERROR, NULL, 0, NULL, NULL,
|
||||||
|
34
parser.c
34
parser.c
@ -141,6 +141,9 @@ static void
|
|||||||
xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix,
|
xmlErrAttributeDup(xmlParserCtxtPtr ctxt, const xmlChar * prefix,
|
||||||
const xmlChar * localname)
|
const xmlChar * localname)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = XML_ERR_ATTRIBUTE_REDEFINED;
|
ctxt->errNo = XML_ERR_ATTRIBUTE_REDEFINED;
|
||||||
if (prefix == NULL)
|
if (prefix == NULL)
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER,
|
||||||
@ -171,6 +174,9 @@ xmlFatalErr(xmlParserCtxtPtr ctxt, xmlParserErrors error, const char *info)
|
|||||||
{
|
{
|
||||||
const char *errmsg;
|
const char *errmsg;
|
||||||
|
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
switch (error) {
|
switch (error) {
|
||||||
case XML_ERR_INVALID_HEX_CHARREF:
|
case XML_ERR_INVALID_HEX_CHARREF:
|
||||||
errmsg = "CharRef: invalid hexadecimal value\n";
|
errmsg = "CharRef: invalid hexadecimal value\n";
|
||||||
@ -371,6 +377,9 @@ static void
|
|||||||
xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
xmlFatalErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg)
|
const char *msg)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_PARSER, error,
|
||||||
XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, msg);
|
XML_ERR_FATAL, NULL, 0, NULL, NULL, NULL, 0, 0, msg);
|
||||||
@ -395,6 +404,9 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
{
|
{
|
||||||
xmlStructuredErrorFunc schannel = NULL;
|
xmlStructuredErrorFunc schannel = NULL;
|
||||||
|
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
|
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
|
||||||
schannel = ctxt->sax->serror;
|
schannel = ctxt->sax->serror;
|
||||||
@ -421,6 +433,10 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
const char *msg, const xmlChar *str1)
|
const char *msg, const xmlChar *str1)
|
||||||
{
|
{
|
||||||
xmlStructuredErrorFunc schannel = NULL;
|
xmlStructuredErrorFunc schannel = NULL;
|
||||||
|
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
|
if ((ctxt->sax != NULL) && (ctxt->sax->initialized == XML_SAX2_MAGIC))
|
||||||
schannel = ctxt->sax->serror;
|
schannel = ctxt->sax->serror;
|
||||||
@ -446,6 +462,9 @@ static void
|
|||||||
xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
xmlFatalErrMsgInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, int val)
|
const char *msg, int val)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL,
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
|
ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
|
||||||
@ -471,6 +490,9 @@ xmlFatalErrMsgStrIntStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
const char *msg, const xmlChar *str1, int val,
|
const char *msg, const xmlChar *str1, int val,
|
||||||
const xmlChar *str2)
|
const xmlChar *str2)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL,
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
|
ctxt, NULL, XML_FROM_PARSER, error, XML_ERR_FATAL,
|
||||||
@ -494,6 +516,9 @@ static void
|
|||||||
xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
xmlFatalErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, const xmlChar * val)
|
const char *msg, const xmlChar * val)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
|
||||||
XML_FROM_PARSER, error, XML_ERR_FATAL,
|
XML_FROM_PARSER, error, XML_ERR_FATAL,
|
||||||
@ -517,6 +542,9 @@ static void
|
|||||||
xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
xmlErrMsgStr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, const xmlChar * val)
|
const char *msg, const xmlChar * val)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL,
|
||||||
XML_FROM_PARSER, error, XML_ERR_ERROR,
|
XML_FROM_PARSER, error, XML_ERR_ERROR,
|
||||||
@ -540,6 +568,9 @@ xmlNsErr(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
const xmlChar * info1, const xmlChar * info2,
|
const xmlChar * info1, const xmlChar * info2,
|
||||||
const xmlChar * info3)
|
const xmlChar * info3)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
|
__xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
|
||||||
XML_ERR_ERROR, NULL, 0, (const char *) info1,
|
XML_ERR_ERROR, NULL, 0, (const char *) info1,
|
||||||
@ -10126,7 +10157,10 @@ xmlParseChunk(xmlParserCtxtPtr ctxt, const char *chunk, int size,
|
|||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlStopParser(xmlParserCtxtPtr ctxt) {
|
xmlStopParser(xmlParserCtxtPtr ctxt) {
|
||||||
|
if (ctxt == NULL)
|
||||||
|
return;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
|
ctxt->disableSAX = 1;
|
||||||
if (ctxt->input != NULL)
|
if (ctxt->input != NULL)
|
||||||
ctxt->input->cur = BAD_CAST"";
|
ctxt->input->cur = BAD_CAST"";
|
||||||
}
|
}
|
||||||
|
@ -105,6 +105,9 @@ xmlCheckVersion(int version) {
|
|||||||
void
|
void
|
||||||
xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
|
xmlErrMemory(xmlParserCtxtPtr ctxt, const char *extra)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if (ctxt != NULL) {
|
if (ctxt != NULL) {
|
||||||
ctxt->errNo = XML_ERR_NO_MEMORY;
|
ctxt->errNo = XML_ERR_NO_MEMORY;
|
||||||
ctxt->instate = XML_PARSER_EOF;
|
ctxt->instate = XML_PARSER_EOF;
|
||||||
@ -135,6 +138,9 @@ void
|
|||||||
__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
__xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, const xmlChar * str1, const xmlChar * str2)
|
const char *msg, const xmlChar * str1, const xmlChar * str2)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if (ctxt != NULL)
|
if (ctxt != NULL)
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL,
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
@ -159,6 +165,9 @@ __xmlErrEncoding(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
|||||||
static void
|
static void
|
||||||
xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
|
xmlErrInternal(xmlParserCtxtPtr ctxt, const char *msg, const xmlChar * str)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if (ctxt != NULL)
|
if (ctxt != NULL)
|
||||||
ctxt->errNo = XML_ERR_INTERNAL_ERROR;
|
ctxt->errNo = XML_ERR_INTERNAL_ERROR;
|
||||||
__xmlRaiseError(NULL, NULL, NULL,
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
@ -185,6 +194,9 @@ static void
|
|||||||
xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
xmlErrEncodingInt(xmlParserCtxtPtr ctxt, xmlParserErrors error,
|
||||||
const char *msg, int val)
|
const char *msg, int val)
|
||||||
{
|
{
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if (ctxt != NULL)
|
if (ctxt != NULL)
|
||||||
ctxt->errNo = error;
|
ctxt->errNo = error;
|
||||||
__xmlRaiseError(NULL, NULL, NULL,
|
__xmlRaiseError(NULL, NULL, NULL,
|
||||||
|
@ -1644,12 +1644,12 @@ libxml_xmlFreeTextReader(ATTRIBUTE_UNUSED PyObject *self, PyObject *args) {
|
|||||||
xmlTextReaderErrorFunc f;
|
xmlTextReaderErrorFunc f;
|
||||||
void *arg;
|
void *arg;
|
||||||
|
|
||||||
if (self == NULL) {
|
if (!PyArg_ParseTuple(args, (char *)"O:xmlFreeTextReader", &pyobj_reader))
|
||||||
|
return(NULL);
|
||||||
|
if (!PyCObject_Check(pyobj_reader)) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
return(Py_None);
|
return(Py_None);
|
||||||
}
|
}
|
||||||
if (!PyArg_ParseTuple(args, (char *)"O:xmlFreeTextReader", &pyobj_reader))
|
|
||||||
return(NULL);
|
|
||||||
reader = (xmlTextReaderPtr) PyxmlTextReader_Get(pyobj_reader);
|
reader = (xmlTextReaderPtr) PyxmlTextReader_Get(pyobj_reader);
|
||||||
if (reader == NULL) {
|
if (reader == NULL) {
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
|
3
xmlIO.c
3
xmlIO.c
@ -409,6 +409,9 @@ __xmlLoaderErr(void *ctx, const char *msg, const char *filename)
|
|||||||
void *data = NULL;
|
void *data = NULL;
|
||||||
xmlErrorLevel level = XML_ERR_ERROR;
|
xmlErrorLevel level = XML_ERR_ERROR;
|
||||||
|
|
||||||
|
if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
|
||||||
|
(ctxt->instate == XML_PARSER_EOF))
|
||||||
|
return;
|
||||||
if ((ctxt != NULL) && (ctxt->sax != NULL)) {
|
if ((ctxt != NULL) && (ctxt->sax != NULL)) {
|
||||||
if (ctxt->validate) {
|
if (ctxt->validate) {
|
||||||
channel = ctxt->sax->error;
|
channel = ctxt->sax->error;
|
||||||
|
Reference in New Issue
Block a user