1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-08-07 06:43:02 +03:00

fixed a couple of conformances issues deep into the validation code

* SAX.c entities.c: fixed a couple of conformances issues deep
  into the validation code (standalone and undeclared Notations)
Daniel
This commit is contained in:
Daniel Veillard
2002-02-18 11:19:30 +00:00
parent 82ac6b0299
commit 2875770e53
3 changed files with 45 additions and 9 deletions

View File

@@ -1,3 +1,8 @@
Mon Feb 18 12:17:41 CET 2002 Daniel Veillard <daniel@veillard.com>
* SAX.c entities.c: fixed a couple of conformances issues deep
into the validation code (standalone and undeclared Notations)
Mon Feb 18 00:17:24 CET 2002 Daniel Veillard <daniel@veillard.com> Mon Feb 18 00:17:24 CET 2002 Daniel Veillard <daniel@veillard.com>
* parser.c: fixed #71741 supid typo an a bug about encoding parsing * parser.c: fixed #71741 supid typo an a bug about encoding parsing

36
SAX.c
View File

@@ -344,7 +344,30 @@ getEntity(void *ctx, const xmlChar *name)
"SAX.getEntity(%s)\n", name); "SAX.getEntity(%s)\n", name);
#endif #endif
ret = xmlGetDocEntity(ctxt->myDoc, name); if ((ctxt->myDoc != NULL) && (ctxt->myDoc->standalone == 1)) {
if (ctxt->inSubset == 2) {
ctxt->myDoc->standalone = 0;
ret = xmlGetDocEntity(ctxt->myDoc, name);
ctxt->myDoc->standalone = 1;
} else {
ret = xmlGetDocEntity(ctxt->myDoc, name);
if (ret == NULL) {
ctxt->myDoc->standalone = 0;
ret = xmlGetDocEntity(ctxt->myDoc, name);
if (ret != NULL) {
if ((ctxt->sax != NULL) && (ctxt->sax->error != NULL))
ctxt->sax->error(ctxt,
"Entity(%s) document marked standalone but require external subset\n",
name);
ctxt->valid = 0;
ctxt->wellFormed = 0;
}
ctxt->myDoc->standalone = 1;
}
}
} else {
ret = xmlGetDocEntity(ctxt->myDoc, name);
}
if ((ret != NULL) && (ctxt->validate) && (ret->children == NULL) && if ((ret != NULL) && (ctxt->validate) && (ret->children == NULL) &&
(ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) { (ret->etype == XML_EXTERNAL_GENERAL_PARSED_ENTITY)) {
/* /*
@@ -617,10 +640,15 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
"SAX.unparsedEntityDecl(%s, %s, %s, %s)\n", "SAX.unparsedEntityDecl(%s, %s, %s, %s)\n",
name, publicId, systemId, notationName); name, publicId, systemId, notationName);
#endif #endif
if (ctxt->validate && ctxt->wellFormed && if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc) {
ctxt->myDoc && ctxt->myDoc->extSubset) int ret;
ctxt->valid &= xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc, ret = xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc,
notationName); notationName);
if (ret == 0) {
ctxt->wellFormed = 0;
ctxt->valid = 0;
}
}
if (ctxt->inSubset == 1) { if (ctxt->inSubset == 1) {
ent = xmlAddDocEntity(ctxt->myDoc, name, ent = xmlAddDocEntity(ctxt->myDoc, name,
XML_EXTERNAL_GENERAL_UNPARSED_ENTITY, XML_EXTERNAL_GENERAL_UNPARSED_ENTITY,

View File

@@ -385,11 +385,14 @@ xmlGetDocEntity(xmlDocPtr doc, const xmlChar *name) {
if (cur != NULL) if (cur != NULL)
return(cur); return(cur);
} }
if ((doc->extSubset != NULL) && (doc->extSubset->entities != NULL)) { if (doc->standalone != 1) {
table = (xmlEntitiesTablePtr) doc->extSubset->entities; if ((doc->extSubset != NULL) &&
cur = xmlGetEntityFromTable(table, name); (doc->extSubset->entities != NULL)) {
if (cur != NULL) table = (xmlEntitiesTablePtr) doc->extSubset->entities;
return(cur); cur = xmlGetEntityFromTable(table, name);
if (cur != NULL)
return(cur);
}
} }
} }
if (xmlPredefinedEntities == NULL) if (xmlPredefinedEntities == NULL)