1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-10 08:58:16 +03:00

fix some recursion problems introduced in the last release. more debugging

* SAX.c parser.c: fix some recursion problems introduced in the
  last release.
* relaxng.c: more debugging of the RNG validation engine, still
  problems though.
Daniel
This commit is contained in:
Daniel Veillard 2003-03-11 11:21:28 +00:00
parent 5add868b2e
commit 39eb88b4ca
4 changed files with 53 additions and 12 deletions

View File

@ -1,3 +1,10 @@
Tue Mar 11 12:08:23 CET 2003 Daniel Veillard <daniel@veillard.com>
* SAX.c parser.c: fix some recursion problems introduced in the
last release.
* relaxng.c: more debugging of the RNG validation engine, still
problems though.
Mon Mar 10 14:10:47 CET 2003 Daniel Veillard <daniel@veillard.com>
* Makefile.am: stop generating wrong result file with * in name

16
SAX.c
View File

@ -378,14 +378,26 @@ getEntity(void *ctx, const xmlChar *name)
((ctxt->validate) || (ctxt->replaceEntities)) &&
(ret->children == NULL) &&
(ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
int val;
/*
* for validation purposes we really need to fetch and
* parse the external entity
*/
xmlNodePtr children;
xmlParseCtxtExternalEntity(ctxt, ret->URI, ret->ExternalID, &children);
xmlAddChildList((xmlNodePtr) ret, children);
val = xmlParseCtxtExternalEntity(ctxt, ret->URI,
ret->ExternalID, &children);
if (val == 0) {
xmlAddChildList((xmlNodePtr) ret, children);
} else {
ctxt->sax->error(ctxt,
"Failure to process entity %s\n", name);
ctxt->wellFormed = 0;
ctxt->valid = 0;
ctxt->validate = 0;
return(NULL);
}
ret->owner = 1;
}
return(ret);

View File

@ -5753,9 +5753,10 @@ xmlParseEntityRef(xmlParserCtxtPtr ctxt) {
if (ctxt->sax != NULL) {
if (ctxt->sax->getEntity != NULL)
ent = ctxt->sax->getEntity(ctxt->userData, name);
if (ent == NULL)
if ((ctxt->wellFormed == 1 ) && (ent == NULL))
ent = xmlGetPredefinedEntity(name);
if ((ent == NULL) && (ctxt->userData==ctxt)) {
if ((ctxt->wellFormed == 1 ) && (ent == NULL) &&
(ctxt->userData==ctxt)) {
ent = getEntity(ctxt, name);
}
}

View File

@ -46,7 +46,7 @@ static const xmlChar *xmlRelaxNGNs = (const xmlChar *)
(xmlStrEqual(node->ns->href, xmlRelaxNGNs)))
/* #define DEBUG 1 */ /* very verbose output */
/* #define DEBUG 1 */
/* #define DEBUG_GRAMMAR 1 */
/* #define DEBUG_CONTENT 1 */
/* #define DEBUG_TYPE 1 */
@ -2191,7 +2191,9 @@ static int xmlRelaxNGElementMatch(xmlRelaxNGValidCtxtPtr ctxt,
#define IS_BLANK_NODE(n) \
(((n)->type == XML_TEXT_NODE) && (xmlRelaxNGIsBlank((n)->content)))
((((n)->type == XML_TEXT_NODE) || \
((n)->type == XML_CDATA_SECTION_NODE)) && \
(xmlRelaxNGIsBlank((n)->content)))
/**
* xmlRelaxNGIsBlank:
@ -2331,7 +2333,8 @@ xmlRelaxNGParseValue(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr node) {
}
if (node->children == NULL) {
def->value = xmlStrdup(BAD_CAST "");
} else if ((node->children->type != XML_TEXT_NODE) ||
} else if (((node->children->type != XML_TEXT_NODE) &&
(node->children->type != XML_CDATA_SECTION_NODE)) ||
(node->children->next != NULL)) {
if (ctxt->error != NULL)
ctxt->error(ctxt->userData,
@ -5738,7 +5741,8 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root) {
/*
* Simplification 4.2 whitespaces
*/
else if (cur->type == XML_TEXT_NODE) {
else if ((cur->type == XML_TEXT_NODE) ||
(cur->type == XML_CDATA_SECTION_NODE)) {
if (IS_BLANK_NODE(cur)) {
if (cur->parent->type == XML_ELEMENT_NODE) {
if ((!xmlStrEqual(cur->parent->name, BAD_CAST "value")) &&
@ -5749,7 +5753,7 @@ xmlRelaxNGCleanupTree(xmlRelaxNGParserCtxtPtr ctxt, xmlNodePtr root) {
goto skip_children;
}
}
} else if (cur->type != XML_CDATA_SECTION_NODE) {
} else {
delete = cur;
goto skip_children;
}
@ -6220,7 +6224,8 @@ xmlRelaxNGSkipIgnored(xmlRelaxNGValidCtxtPtr ctxt ATTRIBUTE_UNUSED,
while ((node != NULL) &&
((node->type == XML_COMMENT_NODE) ||
(node->type == XML_PI_NODE) ||
((node->type == XML_TEXT_NODE) &&
(((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) &&
(IS_BLANK_NODE(node))))) {
node = node->next;
}
@ -6874,7 +6879,8 @@ xmlRelaxNGNodeMatchesList(xmlNodePtr node, xmlRelaxNGDefinePtr *list) {
return(1);
}
}
} else if ((node->type == XML_TEXT_NODE) &&
} else if (((node->type == XML_TEXT_NODE) ||
(node->type == XML_CDATA_SECTION_NODE)) &&
(cur->type == XML_RELAXNG_TEXT)) {
return(1);
}
@ -7188,12 +7194,14 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
switch (define->type) {
case XML_RELAXNG_EMPTY:
node = xmlRelaxNGSkipIgnored(ctxt, node);
#if 0
if (node != NULL) {
VALID_ERR2(XML_RELAXNG_ERR_ELEMNOTEMPTY,
ctxt->state->node->name);
ret = -1;
break;
}
#endif
ret = 0;
break;
case XML_RELAXNG_NOT_ALLOWED:
@ -7378,9 +7386,11 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
case XML_RELAXNG_CHOICE: {
xmlRelaxNGDefinePtr list = define->content;
int success = 0;
xmlRelaxNGValidStatePtr sstate = NULL;
oldflags = ctxt->flags;
ctxt->flags |= FLAGS_IGNORABLE;
node = xmlRelaxNGSkipIgnored(ctxt, node);
while (list != NULL) {
oldstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state);
@ -7392,6 +7402,10 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
* to make more progresses
*/
success = 1;
if (sstate != NULL) {
xmlRelaxNGFreeValidState(sstate);
}
sstate = xmlRelaxNGCopyValidState(ctxt, ctxt->state);
} else {
xmlRelaxNGFreeValidState(oldstate);
break;
@ -7402,8 +7416,15 @@ xmlRelaxNGValidateDefinition(xmlRelaxNGValidCtxtPtr ctxt,
list = list->next;
}
ctxt->flags = oldflags;
if (success == 1)
if (success == 1) {
if (ret != 0) {
xmlRelaxNGFreeValidState(ctxt->state);
ctxt->state = sstate;
} else {
xmlRelaxNGFreeValidState(sstate);
}
ret = 0;
}
if (ret != 0) {
if ((ctxt->flags & FLAGS_IGNORABLE) == 0)
xmlRelaxNGDumpValidError(ctxt);