summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Veillard <veillard@src.gnome.org>2003-03-11 11:21:28 +0000
committerDaniel Veillard <veillard@src.gnome.org>2003-03-11 11:21:28 +0000
commit39eb88b4ca9c13de82e631faaccd5300514bb8bd (patch)
tree8a671a6a472990776ce1a2b83ae06615c99aa82a
parent5add868b2e79a304c8d99be57bc446f94798af84 (diff)
downloadlibxml2-39eb88b4ca9c13de82e631faaccd5300514bb8bd.tar.gz
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
-rw-r--r--ChangeLog7
-rw-r--r--SAX.c16
-rw-r--r--parser.c5
-rw-r--r--relaxng.c37
4 files changed, 53 insertions, 12 deletions
diff --git a/ChangeLog b/ChangeLog
index 718a65be..23a87b44 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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
diff --git a/SAX.c b/SAX.c
index 24e679d4..0f2a0291 100644
--- a/SAX.c
+++ b/SAX.c
@@ -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);
diff --git a/parser.c b/parser.c
index ba9327ce..83db22bf 100644
--- a/parser.c
+++ b/parser.c
@@ -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);
}
}
diff --git a/relaxng.c b/relaxng.c
index b1d4d475..81df4305 100644
--- a/relaxng.c
+++ b/relaxng.c
@@ -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);