[Expat-CVS] expat/lib xmlparse.c,1.64,1.65
Karl Waclawek
kwaclaw@users.sourceforge.net
Thu Aug 22 14:25:03 2002
Update of /cvsroot/expat/expat/lib
In directory usw-pr-cvs1:/tmp/cvs-serv25368
Modified Files:
xmlparse.c
Log Message:
Fix for WFC: Entity Declared handling:
Expat would return an "undefined entity" error for the document:
<!DOCTYPE doc SYSTEM "foo">
<doc>&entity;</doc>
if the DTD was not read.
Index: xmlparse.c
===================================================================
RCS file: /cvsroot/expat/expat/lib/xmlparse.c,v
retrieving revision 1.64
retrieving revision 1.65
diff -u -d -r1.64 -r1.65
--- xmlparse.c 22 Aug 2002 14:52:44 -0000 1.64
+++ xmlparse.c 22 Aug 2002 21:24:10 -0000 1.65
@@ -228,8 +228,8 @@
XML_Bool keepProcessing;
/* indicates if external PE has been read */
XML_Bool paramEntityRead;
- /* true once an internal or external PE has been read */
- XML_Bool hasParamEntities;
+ /* true once an internal or external PE reference has been encountered */
+ XML_Bool hasParamEntityRefs;
XML_Bool standalone;
#ifdef XML_DTD
HASH_TABLE paramEntities;
@@ -1770,7 +1770,7 @@
if yes, check that the entity exists, and that it is internal,
otherwise call the skipped entity or default handler.
*/
- if (!dtd.hasParamEntities || dtd.standalone) {
+ if (!dtd.hasParamEntityRefs || dtd.standalone) {
if (!entity)
return XML_ERROR_UNDEFINED_ENTITY;
else if (!entity->is_internal)
@@ -2834,8 +2834,7 @@
return result;
/* we know now that XML_Parse(Buffer) has been called,
- so we assume we actually have an external parameter entity */
- dtd.hasParamEntities = XML_TRUE;
+ so we consider the external parameter entity read */
dtd.paramEntityRead = XML_TRUE;
if (prologState.inEntityValue) {
@@ -3110,6 +3109,7 @@
break;
#endif /* XML_DTD */
case XML_ROLE_DOCTYPE_PUBLIC_ID:
+ dtd.hasParamEntityRefs = XML_TRUE;
if (startDoctypeDeclHandler) {
doctypePubid = poolStoreString(&tempPool, enc,
s + enc->minBytesPerChar,
@@ -3342,6 +3342,7 @@
}
break;
case XML_ROLE_DOCTYPE_SYSTEM_ID:
+ dtd.hasParamEntityRefs = XML_TRUE;
if (startDoctypeDeclHandler) {
doctypeSysid = poolStoreString(&tempPool, enc,
s + enc->minBytesPerChar,
@@ -3647,6 +3648,7 @@
if (prologState.documentEntity &&
role == XML_ROLE_INNER_PARAM_ENTITY_REF)
return XML_ERROR_PARAM_ENTITY_REF;
+ dtd.hasParamEntityRefs = XML_TRUE;
dtd.paramEntityRead = XML_FALSE;
if (!paramEntityParsing)
dtd.keepProcessing = dtd.standalone;
@@ -3665,7 +3667,7 @@
otherwise call the skipped entity handler
*/
if (prologState.documentEntity &&
- (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntities)) {
+ (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntityRefs)) {
if (!entity)
return XML_ERROR_UNDEFINED_ENTITY;
else if (!entity->is_internal)
@@ -3952,7 +3954,6 @@
openEntity.internalEventEndPtr = NULL;
s = (char *)entity->textPtr;
end = (char *)(entity->textPtr + entity->textLen);
- dtd.hasParamEntities = XML_TRUE;
tok = XmlPrologTok(internalEncoding, s, end, &next);
result = doProlog(parser, internalEncoding, s, end, tok, next, 0);
entity->open = XML_FALSE;
@@ -4075,9 +4076,9 @@
#ifdef XML_DTD
prologState.documentEntity &&
#endif /* XML_DTD */
- (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntities);
+ (dtd.standalone ? !openInternalEntities : !dtd.hasParamEntityRefs);
else /* if (pool == &tempPool): we are called from content */
- checkEntityDecl = !dtd.hasParamEntities || dtd.standalone;
+ checkEntityDecl = !dtd.hasParamEntityRefs || dtd.standalone;
if (checkEntityDecl) {
if (!entity)
return XML_ERROR_UNDEFINED_ENTITY;
@@ -4695,7 +4696,7 @@
hashTableInit(&(p->prefixes), ms);
p->keepProcessing = XML_TRUE;
p->paramEntityRead = XML_FALSE;
- p->hasParamEntities = XML_FALSE;
+ p->hasParamEntityRefs = XML_FALSE;
p->standalone = XML_FALSE;
#ifdef XML_DTD
hashTableInit(&(p->paramEntities), ms);
@@ -4908,7 +4909,7 @@
newDtd->keepProcessing = oldDtd->keepProcessing;
newDtd->paramEntityRead = oldDtd->paramEntityRead;
- newDtd->hasParamEntities = oldDtd->hasParamEntities;
+ newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs;
newDtd->standalone = oldDtd->standalone;
/* Don't want deep copying for scaffolding */