mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-10-26 00:37:43 +03:00
rework the patch to avoid some ABI issue with people allocating entities
* include/libxml/entities.h entities.c SAX2.c parser.c: rework the patch to avoid some ABI issue with people allocating entities structure directly Daniel svn path=/trunk/; revision=3773
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
Mon Aug 25 10:56:30 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* include/libxml/entities.h entities.c SAX2.c parser.c: rework
|
||||||
|
the patch to avoid some ABI issue with people allocating
|
||||||
|
entities structure directly
|
||||||
|
|
||||||
Wed Aug 20 19:02:01 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
Wed Aug 20 19:02:01 CEST 2008 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* include/libxml/parser.h include/libxml/entities.h entities.c
|
* include/libxml/parser.h include/libxml/entities.h entities.c
|
||||||
|
|||||||
1
SAX2.c
1
SAX2.c
@@ -580,6 +580,7 @@ xmlSAX2GetEntity(void *ctx, const xmlChar *name)
|
|||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
ret->owner = 1;
|
ret->owner = 1;
|
||||||
|
if (ret->checked == 0)
|
||||||
ret->checked = 1;
|
ret->checked = 1;
|
||||||
}
|
}
|
||||||
return(ret);
|
return(ret);
|
||||||
|
|||||||
10
entities.c
10
entities.c
@@ -31,35 +31,35 @@ static xmlEntity xmlEntityLt = {
|
|||||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
BAD_CAST "<", BAD_CAST "<", 1,
|
BAD_CAST "<", BAD_CAST "<", 1,
|
||||||
XML_INTERNAL_PREDEFINED_ENTITY,
|
XML_INTERNAL_PREDEFINED_ENTITY,
|
||||||
NULL, NULL, NULL, NULL, 0, 1, 0
|
NULL, NULL, NULL, NULL, 0, 1
|
||||||
};
|
};
|
||||||
static xmlEntity xmlEntityGt = {
|
static xmlEntity xmlEntityGt = {
|
||||||
NULL, XML_ENTITY_DECL, BAD_CAST "gt",
|
NULL, XML_ENTITY_DECL, BAD_CAST "gt",
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
BAD_CAST ">", BAD_CAST ">", 1,
|
BAD_CAST ">", BAD_CAST ">", 1,
|
||||||
XML_INTERNAL_PREDEFINED_ENTITY,
|
XML_INTERNAL_PREDEFINED_ENTITY,
|
||||||
NULL, NULL, NULL, NULL, 0, 1, 0
|
NULL, NULL, NULL, NULL, 0, 1
|
||||||
};
|
};
|
||||||
static xmlEntity xmlEntityAmp = {
|
static xmlEntity xmlEntityAmp = {
|
||||||
NULL, XML_ENTITY_DECL, BAD_CAST "amp",
|
NULL, XML_ENTITY_DECL, BAD_CAST "amp",
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
BAD_CAST "&", BAD_CAST "&", 1,
|
BAD_CAST "&", BAD_CAST "&", 1,
|
||||||
XML_INTERNAL_PREDEFINED_ENTITY,
|
XML_INTERNAL_PREDEFINED_ENTITY,
|
||||||
NULL, NULL, NULL, NULL, 0, 1, 0
|
NULL, NULL, NULL, NULL, 0, 1
|
||||||
};
|
};
|
||||||
static xmlEntity xmlEntityQuot = {
|
static xmlEntity xmlEntityQuot = {
|
||||||
NULL, XML_ENTITY_DECL, BAD_CAST "quot",
|
NULL, XML_ENTITY_DECL, BAD_CAST "quot",
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
BAD_CAST "\"", BAD_CAST "\"", 1,
|
BAD_CAST "\"", BAD_CAST "\"", 1,
|
||||||
XML_INTERNAL_PREDEFINED_ENTITY,
|
XML_INTERNAL_PREDEFINED_ENTITY,
|
||||||
NULL, NULL, NULL, NULL, 0, 1, 0
|
NULL, NULL, NULL, NULL, 0, 1
|
||||||
};
|
};
|
||||||
static xmlEntity xmlEntityApos = {
|
static xmlEntity xmlEntityApos = {
|
||||||
NULL, XML_ENTITY_DECL, BAD_CAST "apos",
|
NULL, XML_ENTITY_DECL, BAD_CAST "apos",
|
||||||
NULL, NULL, NULL, NULL, NULL, NULL,
|
NULL, NULL, NULL, NULL, NULL, NULL,
|
||||||
BAD_CAST "'", BAD_CAST "'", 1,
|
BAD_CAST "'", BAD_CAST "'", 1,
|
||||||
XML_INTERNAL_PREDEFINED_ENTITY,
|
XML_INTERNAL_PREDEFINED_ENTITY,
|
||||||
NULL, NULL, NULL, NULL, 0, 1, 0
|
NULL, NULL, NULL, NULL, 0, 1
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -57,7 +57,6 @@ struct _xmlEntity {
|
|||||||
const xmlChar *URI; /* the full URI as computed */
|
const xmlChar *URI; /* the full URI as computed */
|
||||||
int owner; /* does the entity own the childrens */
|
int owner; /* does the entity own the childrens */
|
||||||
int checked; /* was the entity content checked */
|
int checked; /* was the entity content checked */
|
||||||
unsigned long nbentities; /* the number of entities references */
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
15
parser.c
15
parser.c
@@ -2421,7 +2421,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
|||||||
goto int_error;
|
goto int_error;
|
||||||
ctxt->nbentities++;
|
ctxt->nbentities++;
|
||||||
if (ent != NULL)
|
if (ent != NULL)
|
||||||
ctxt->nbentities += ent->nbentities;
|
ctxt->nbentities += ent->checked;
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
||||||
if (ent->content != NULL) {
|
if (ent->content != NULL) {
|
||||||
@@ -2471,7 +2471,7 @@ xmlStringLenDecodeEntities(xmlParserCtxtPtr ctxt, const xmlChar *str, int len,
|
|||||||
goto int_error;
|
goto int_error;
|
||||||
ctxt->nbentities++;
|
ctxt->nbentities++;
|
||||||
if (ent != NULL)
|
if (ent != NULL)
|
||||||
ctxt->nbentities += ent->nbentities;
|
ctxt->nbentities += ent->checked;
|
||||||
if (ent != NULL) {
|
if (ent != NULL) {
|
||||||
if (ent->content == NULL) {
|
if (ent->content == NULL) {
|
||||||
if (xmlLoadEntityContent(ctxt, ent) < 0) {
|
if (xmlLoadEntityContent(ctxt, ent) < 0) {
|
||||||
@@ -3555,7 +3555,7 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
|
|||||||
ent = xmlParseEntityRef(ctxt);
|
ent = xmlParseEntityRef(ctxt);
|
||||||
ctxt->nbentities++;
|
ctxt->nbentities++;
|
||||||
if (ent != NULL)
|
if (ent != NULL)
|
||||||
ctxt->nbentities += ent->nbentities;
|
ctxt->nbentities += ent->checked;
|
||||||
if ((ent != NULL) &&
|
if ((ent != NULL) &&
|
||||||
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
(ent->etype == XML_INTERNAL_PREDEFINED_ENTITY)) {
|
||||||
if (len > buf_size - 10) {
|
if (len > buf_size - 10) {
|
||||||
@@ -5083,7 +5083,7 @@ xmlParseEntityDecl(xmlParserCtxtPtr ctxt) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (cur != NULL) {
|
if (cur != NULL) {
|
||||||
cur->nbentities = ctxt->nbentities - oldnbent;
|
cur->checked = ctxt->nbentities - oldnbent;
|
||||||
if (cur->orig != NULL)
|
if (cur->orig != NULL)
|
||||||
xmlFree(orig);
|
xmlFree(orig);
|
||||||
else
|
else
|
||||||
@@ -6594,7 +6594,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
|||||||
xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
|
xmlErrMsgStr(ctxt, XML_ERR_INTERNAL_ERROR,
|
||||||
"invalid entity type found\n", NULL);
|
"invalid entity type found\n", NULL);
|
||||||
}
|
}
|
||||||
ent->nbentities = ctxt->nbentities - oldnbent;
|
ent->checked = ctxt->nbentities - oldnbent;
|
||||||
if (ret == XML_ERR_ENTITY_LOOP) {
|
if (ret == XML_ERR_ENTITY_LOOP) {
|
||||||
xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
|
xmlFatalErr(ctxt, XML_ERR_ENTITY_LOOP, NULL);
|
||||||
return;
|
return;
|
||||||
@@ -6651,9 +6651,10 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
|||||||
list = NULL;
|
list = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (ent->checked == 0)
|
||||||
ent->checked = 1;
|
ent->checked = 1;
|
||||||
}
|
}
|
||||||
ctxt->nbentities += ent->nbentities;
|
ctxt->nbentities += ent->checked;
|
||||||
|
|
||||||
if (ent->children == NULL) {
|
if (ent->children == NULL) {
|
||||||
/*
|
/*
|
||||||
@@ -6662,7 +6663,7 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
|
|||||||
* though parsing for first checking go though the entity
|
* though parsing for first checking go though the entity
|
||||||
* content to generate callbacks associated to the entity
|
* content to generate callbacks associated to the entity
|
||||||
*/
|
*/
|
||||||
if (was_checked == 1) {
|
if (was_checked != 0) {
|
||||||
void *user_data;
|
void *user_data;
|
||||||
/*
|
/*
|
||||||
* This is a bit hackish but this seems the best
|
* This is a bit hackish but this seems the best
|
||||||
|
|||||||
Reference in New Issue
Block a user