diff --git a/ChangeLog b/ChangeLog index 4f70eec5..082735b9 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +Sun Mar 23 12:57:00 CET 2003 Daniel Veillard + + * parser.c: fixing bug #108976 get the ID/REFs to reference + the ID in the document content and not in the entity copy + * SAX.c include/libxml/parser.h: more checking of the ID/REF + stuff, better solution for #107208 + * xmlregexp.c: removed a direct printf, dohhh + * xmlreader.c: fixed a bug on streaming validation of empty + elements in entities + * result/VC/ElementValid8 test/VCM/v20.xml result/valid/xhtml1.xhtml: + cleanup of the validation tests + * test/valid/id* test/valid/dtds/destfoo.ent result/valid/id*: + added more ID/IDREF tests to the suite + Sat Mar 22 23:38:08 CET 2003 Daniel Veillard * xmlreader.c: fixed #107043 removing 2 warnings with Sun One diff --git a/SAX.c b/SAX.c index 3ee76e71..6e3cba1f 100644 --- a/SAX.c +++ b/SAX.c @@ -880,7 +880,7 @@ my_attribute(void *ctx, const xmlChar *fullname, const xmlChar *value, 0,0,0); ctxt->depth--; } else { - val = value; + val = (xmlChar *) value; } if (val[0] != 0) { @@ -932,7 +932,7 @@ my_attribute(void *ctx, const xmlChar *fullname, const xmlChar *value, 0,0,0); ctxt->depth--; } else { - val = value; + val = (xmlChar *) value; } if (val[0] == 0) { @@ -1068,9 +1068,9 @@ my_attribute(void *ctx, const xmlChar *fullname, const xmlChar *value, ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt, ctxt->myDoc, ctxt->node, ret, value); } - } else if ((((ctxt->replaceEntities == 0) && (ctxt->external != 2)) || - ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) && - (ctxt->depth == 0)) { + } else if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) && + (((ctxt->replaceEntities == 0) && (ctxt->external != 2)) || + ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) { /* * when validating, the ID registration is done at the attribute * validation level. Otherwise we have to do specific handling here. diff --git a/include/libxml/parser.h b/include/libxml/parser.h index e6725a36..d221825f 100644 --- a/include/libxml/parser.h +++ b/include/libxml/parser.h @@ -133,6 +133,14 @@ typedef enum { */ #define XML_COMPLETE_ATTRS 4 +/** + * XML_SKIP_IDS: + * + * Bit in the loadsubset context field to tell to not do ID/REFs registration. + * Used to initialize xmlLoadExtDtdDefaultValue in some special cases. + */ +#define XML_SKIP_IDS 8 + /** * xmlParserCtxt: * diff --git a/parser.c b/parser.c index f29d87d8..1a53b7ff 100644 --- a/parser.c +++ b/parser.c @@ -5620,24 +5620,57 @@ xmlParseReference(xmlParserCtxtPtr ctxt) { * a simple tree copy for all references except the first * In the first occurrence list contains the replacement */ - if (list == NULL) { - xmlNodePtr new = NULL, cur, firstChild = NULL; + if ((list == NULL) && (ent->owner == 0)) { + xmlNodePtr nw = NULL, cur, firstChild = NULL; cur = ent->children; while (cur != NULL) { - new = xmlCopyNode(cur, 1); - if (new != NULL) { - new->_private = cur->_private; + nw = xmlCopyNode(cur, 1); + if (nw != NULL) { + nw->_private = cur->_private; if (firstChild == NULL){ - firstChild = new; + firstChild = nw; } - xmlAddChild(ctxt->node, new); + xmlAddChild(ctxt->node, nw); } if (cur == ent->last) break; cur = cur->next; } if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) - xmlAddEntityReference(ent, firstChild, new); + xmlAddEntityReference(ent, firstChild, nw); + } else if (list == NULL) { + xmlNodePtr nw = NULL, cur, next, last, + firstChild = NULL; + /* + * Copy the entity child list and make it the new + * entity child list. The goal is to make sure any + * ID or REF referenced will be the one from the + * document content and not the entity copy. + */ + cur = ent->children; + ent->children = NULL; + last = ent->last; + ent->last = NULL; + while (cur != NULL) { + next = cur->next; + cur->next = NULL; + cur->parent = NULL; + nw = xmlCopyNode(cur, 1); + if (nw != NULL) { + nw->_private = cur->_private; + if (firstChild == NULL){ + firstChild = cur; + } + xmlAddChild((xmlNodePtr) ent, nw); + xmlAddChild(ctxt->node, cur); + } + if (cur == last) + break; + cur = next; + } + ent->owner = 1; + if (ent->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY) + xmlAddEntityReference(ent, firstChild, nw); } else { /* * the name change is to avoid coalescing of the @@ -9976,6 +10009,12 @@ xmlParseBalancedChunkMemoryInternal(xmlParserCtxtPtr oldctxt, ctxt->validate = 0; ctxt->loadsubset = oldctxt->loadsubset; + if ((oldctxt->validate) || (oldctxt->replaceEntities != 0)) { + /* + * ID/IDREF registration will be done in xmlValidateElement below + */ + ctxt->loadsubset |= XML_SKIP_IDS; + } xmlParseContent(ctxt); if ((RAW == '<') && (NXT(1) == '/')) { diff --git a/result/VC/ElementValid8 b/result/VC/ElementValid8 index 02072abf..73840df2 100644 --- a/result/VC/ElementValid8 +++ b/result/VC/ElementValid8 @@ -1,3 +1,3 @@ -./test/VC/ElementValid8:7: validity warning: Content model for Element doc is ambiguous +./test/VC/ElementValid8:7: validity error: Content model of doc is not determinist: ((a , b) | (a , c)) doc is non-deterministic ^ diff --git a/result/valid/id1.xml b/result/valid/id1.xml new file mode 100644 index 00000000..4f0b9f78 --- /dev/null +++ b/result/valid/id1.xml @@ -0,0 +1,13 @@ + + + + + + +]> + + + + + diff --git a/result/valid/id1.xml.err b/result/valid/id1.xml.err new file mode 100644 index 00000000..e69de29b diff --git a/result/valid/id2.xml b/result/valid/id2.xml new file mode 100644 index 00000000..0cef4a62 --- /dev/null +++ b/result/valid/id2.xml @@ -0,0 +1,14 @@ + + + + + + +"> +]> + + + &dest; + + diff --git a/result/valid/id2.xml.err b/result/valid/id2.xml.err new file mode 100644 index 00000000..e69de29b diff --git a/result/valid/id3.xml b/result/valid/id3.xml new file mode 100644 index 00000000..623603c0 --- /dev/null +++ b/result/valid/id3.xml @@ -0,0 +1,14 @@ + + + + + + + +]> + + + &dest; + + diff --git a/result/valid/id3.xml.err b/result/valid/id3.xml.err new file mode 100644 index 00000000..e69de29b diff --git a/result/valid/xhtml1.xhtml b/result/valid/xhtml1.xhtml index 1e9ac6f7..58d20da5 100644 --- a/result/valid/xhtml1.xhtml +++ b/result/valid/xhtml1.xhtml @@ -6,7 +6,7 @@ XHTML 1.0: The Extensible HyperText Markup Language - +