mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-01-26 10:03:34 +03:00
fixing bug #108976 get the ID/REFs to reference the ID in the document
* 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 Daniel
This commit is contained in:
parent
2cfd9dff28
commit
ef8dd7be29
14
ChangeLog
14
ChangeLog
@ -1,3 +1,17 @@
|
||||
Sun Mar 23 12:57:00 CET 2003 Daniel Veillard <daniel@veillard.com>
|
||||
|
||||
* 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 <daniel@veillard.com>
|
||||
|
||||
* xmlreader.c: fixed #107043 removing 2 warnings with Sun One
|
||||
|
10
SAX.c
10
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.
|
||||
|
@ -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:
|
||||
*
|
||||
|
55
parser.c
55
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) == '/')) {
|
||||
|
@ -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><a/><c> doc is non-deterministic </c></doc>
|
||||
^
|
||||
|
13
result/valid/id1.xml
Normal file
13
result/valid/id1.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
<dest id="foo"/>
|
||||
<src ref="foo"/>
|
||||
</doc>
|
0
result/valid/id1.xml.err
Normal file
0
result/valid/id1.xml.err
Normal file
14
result/valid/id2.xml
Normal file
14
result/valid/id2.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
<!ENTITY dest "<dest id='foo'/>">
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
&dest;
|
||||
<src ref="foo"/>
|
||||
</doc>
|
0
result/valid/id2.xml.err
Normal file
0
result/valid/id2.xml.err
Normal file
14
result/valid/id3.xml
Normal file
14
result/valid/id3.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
<!ENTITY dest SYSTEM "dtds/destfoo.ent">
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
&dest;
|
||||
<src ref="foo"/>
|
||||
</doc>
|
0
result/valid/id3.xml.err
Normal file
0
result/valid/id3.xml.err
Normal file
@ -6,7 +6,7 @@
|
||||
<title>XHTML 1.0: The Extensible HyperText Markup
|
||||
Language</title>
|
||||
<link rel="stylesheet" href="W3C-PR.css" type="text/css" />
|
||||
<style type="text/css"><![CDATA[
|
||||
<style type="text/css">
|
||||
span.term { font-style: italic; color: rgb(0, 0, 192) }
|
||||
code {
|
||||
color: green;
|
||||
@ -49,7 +49,7 @@ div.contents {
|
||||
}
|
||||
.tocline { list-style: none; }
|
||||
table.exceptions { background-color: rgb(255,255,153); }
|
||||
]]></style>
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div class="navbar">
|
||||
|
@ -1,10 +1,10 @@
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc ((a | b)*, a, b) >
|
||||
<!ELEMENT doc ((a | b)*, c, b) >
|
||||
<!ELEMENT a EMPTY>
|
||||
<!ELEMENT b EMPTY>
|
||||
<!ELEMENT c EMPTY>
|
||||
]>
|
||||
<doc>
|
||||
<a/>
|
||||
<c/>
|
||||
<b/>
|
||||
</doc>
|
||||
|
1
test/valid/dtds/destfoo.ent
Normal file
1
test/valid/dtds/destfoo.ent
Normal file
@ -0,0 +1 @@
|
||||
<dest id='foo'/>
|
13
test/valid/id1.xml
Normal file
13
test/valid/id1.xml
Normal file
@ -0,0 +1,13 @@
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
<dest id="foo"/>
|
||||
<src ref="foo"/>
|
||||
</doc>
|
||||
|
14
test/valid/id2.xml
Normal file
14
test/valid/id2.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
<!ENTITY dest "<dest id='foo'/>">
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
&dest;
|
||||
<src ref="foo"/>
|
||||
</doc>
|
||||
|
14
test/valid/id3.xml
Normal file
14
test/valid/id3.xml
Normal file
@ -0,0 +1,14 @@
|
||||
<!DOCTYPE doc [
|
||||
<!ELEMENT doc (src | dest)*>
|
||||
<!ELEMENT src EMPTY>
|
||||
<!ELEMENT dest EMPTY>
|
||||
<!ATTLIST src ref IDREF #IMPLIED>
|
||||
<!ATTLIST dest id ID #IMPLIED>
|
||||
<!ENTITY dest SYSTEM "dtds/destfoo.ent">
|
||||
]>
|
||||
<doc>
|
||||
<src ref="foo"/>
|
||||
&dest;
|
||||
<src ref="foo"/>
|
||||
</doc>
|
||||
|
3
valid.c
3
valid.c
@ -5170,6 +5170,7 @@ xmlValidatePushElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
|
||||
xmlElementPtr eDecl;
|
||||
int extsubset = 0;
|
||||
|
||||
/* printf("PushElem %s\n", qname); */
|
||||
if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
|
||||
xmlValidStatePtr state = ctxt->vstate;
|
||||
xmlElementPtr elemDecl;
|
||||
@ -5257,6 +5258,7 @@ int
|
||||
xmlValidatePushCData(xmlValidCtxtPtr ctxt, const xmlChar *data, int len) {
|
||||
int ret = 1;
|
||||
|
||||
/* printf("CDATA %s %d\n", data, len); */
|
||||
if (len <= 0)
|
||||
return(ret);
|
||||
if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
|
||||
@ -5330,6 +5332,7 @@ xmlValidatePopElement(xmlValidCtxtPtr ctxt, xmlDocPtr doc ATTRIBUTE_UNUSED,
|
||||
const xmlChar *qname ATTRIBUTE_UNUSED) {
|
||||
int ret = 1;
|
||||
|
||||
/* printf("PopElem %s\n", qname); */
|
||||
if ((ctxt->vstateNr > 0) && (ctxt->vstate != NULL)) {
|
||||
xmlValidStatePtr state = ctxt->vstate;
|
||||
xmlElementPtr elemDecl;
|
||||
|
@ -524,6 +524,8 @@ xmlTextReaderValidateEntity(xmlTextReaderPtr reader) {
|
||||
if (node->children != NULL) {
|
||||
node = node->children;
|
||||
continue;
|
||||
} else if (node->type == XML_ELEMENT_NODE) {
|
||||
xmlTextReaderValidatePop(reader);
|
||||
}
|
||||
if (node->next != NULL) {
|
||||
node = node->next;
|
||||
|
@ -455,7 +455,6 @@ xmlRegEpxFromParse(xmlRegParserCtxtPtr ctxt) {
|
||||
prev = transitions[stateno * (nbatoms + 1) + atomno + 1];
|
||||
if (prev != 0) {
|
||||
if (prev != targetno + 1) {
|
||||
printf("not determinist\n");
|
||||
ret->determinist = 0;
|
||||
#ifdef DEBUG_COMPACTION
|
||||
printf("Indet: state %d trans %d, atom %d to %d : %d to %d\n",
|
||||
|
Loading…
x
Reference in New Issue
Block a user