mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-07 06:43:02 +03:00
more work on the conformance suite. Took the step to finally block
* SAX.c parserInternals.c valid.c: more work on the conformance suite. Took the step to finally block documents with encoding errors. It's a fatal error per the spec, people should have fixed their documents by now. Daniel
This commit is contained in:
@@ -1,3 +1,10 @@
|
|||||||
|
Mon Feb 18 19:27:32 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* SAX.c parserInternals.c valid.c: more work on the conformance
|
||||||
|
suite. Took the step to finally block documents with encoding
|
||||||
|
errors. It's a fatal error per the spec, people should have fixed
|
||||||
|
their documents by now.
|
||||||
|
|
||||||
Mon Feb 18 15:30:14 CET 2002 Daniel Veillard <daniel@veillard.com>
|
Mon Feb 18 15:30:14 CET 2002 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* check-xml-test-suite.py: fixed the test script after some discussion
|
* check-xml-test-suite.py: fixed the test script after some discussion
|
||||||
|
11
SAX.c
11
SAX.c
@@ -640,6 +640,8 @@ 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 0
|
||||||
|
Done in xmlValidateDtdFinal now.
|
||||||
if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc) {
|
if (ctxt->validate && ctxt->wellFormed && ctxt->myDoc) {
|
||||||
int ret;
|
int ret;
|
||||||
ret = xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc,
|
ret = xmlValidateNotationUse(&ctxt->vctxt, ctxt->myDoc,
|
||||||
@@ -649,6 +651,7 @@ unparsedEntityDecl(void *ctx, const xmlChar *name,
|
|||||||
ctxt->valid = 0;
|
ctxt->valid = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
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,
|
||||||
@@ -1220,7 +1223,13 @@ startElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
|
|||||||
* check the document root element for validity
|
* check the document root element for validity
|
||||||
*/
|
*/
|
||||||
if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
|
if ((ctxt->validate) && (ctxt->vctxt.finishDtd == 0)) {
|
||||||
ctxt->valid &= xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
|
int chk;
|
||||||
|
|
||||||
|
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
|
||||||
|
if (chk <= 0)
|
||||||
|
ctxt->valid = 0;
|
||||||
|
if (chk < 0)
|
||||||
|
ctxt->wellFormed = 0;
|
||||||
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
|
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
|
||||||
ctxt->vctxt.finishDtd = 1;
|
ctxt->vctxt.finishDtd = 1;
|
||||||
}
|
}
|
||||||
|
@@ -1228,6 +1228,7 @@ encoding_error:
|
|||||||
ctxt->input->cur[0], ctxt->input->cur[1],
|
ctxt->input->cur[0], ctxt->input->cur[1],
|
||||||
ctxt->input->cur[2], ctxt->input->cur[3]);
|
ctxt->input->cur[2], ctxt->input->cur[3]);
|
||||||
}
|
}
|
||||||
|
ctxt->wellFormed = 0;
|
||||||
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
||||||
|
|
||||||
ctxt->charset = XML_CHAR_ENCODING_8859_1;
|
ctxt->charset = XML_CHAR_ENCODING_8859_1;
|
||||||
@@ -1371,6 +1372,7 @@ encoding_error:
|
|||||||
ctxt->input->cur[0], ctxt->input->cur[1],
|
ctxt->input->cur[0], ctxt->input->cur[1],
|
||||||
ctxt->input->cur[2], ctxt->input->cur[3]);
|
ctxt->input->cur[2], ctxt->input->cur[3]);
|
||||||
}
|
}
|
||||||
|
ctxt->wellFormed = 0;
|
||||||
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
||||||
|
|
||||||
ctxt->charset = XML_CHAR_ENCODING_8859_1;
|
ctxt->charset = XML_CHAR_ENCODING_8859_1;
|
||||||
@@ -1481,6 +1483,7 @@ encoding_error:
|
|||||||
ctxt->input->cur[2], ctxt->input->cur[3]);
|
ctxt->input->cur[2], ctxt->input->cur[3]);
|
||||||
}
|
}
|
||||||
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
ctxt->errNo = XML_ERR_INVALID_ENCODING;
|
||||||
|
ctxt->wellFormed = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
*len = 1;
|
*len = 1;
|
||||||
|
44
valid.c
44
valid.c
@@ -4788,9 +4788,30 @@ xmlValidateDtd(xmlValidCtxtPtr ctxt, xmlDocPtr doc, xmlDtdPtr dtd) {
|
|||||||
return(ret);
|
return(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
xmlValidateNotationCallback(xmlEntityPtr cur, xmlValidCtxtPtr ctxt,
|
||||||
|
const xmlChar *name ATTRIBUTE_UNUSED) {
|
||||||
|
if (cur == NULL)
|
||||||
|
return;
|
||||||
|
if (cur->etype == XML_EXTERNAL_GENERAL_UNPARSED_ENTITY) {
|
||||||
|
xmlChar *notation = cur->content;
|
||||||
|
|
||||||
|
if (cur != NULL) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
ret = xmlValidateNotationUse(ctxt, cur->doc, notation);
|
||||||
|
if (ret != 1) {
|
||||||
|
ctxt->valid = -1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
|
xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
|
||||||
const xmlChar *name ATTRIBUTE_UNUSED) {
|
const xmlChar *name ATTRIBUTE_UNUSED) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
if (cur == NULL)
|
if (cur == NULL)
|
||||||
return;
|
return;
|
||||||
switch (cur->atype) {
|
switch (cur->atype) {
|
||||||
@@ -4806,14 +4827,19 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
|
|||||||
case XML_ATTRIBUTE_ENTITIES:
|
case XML_ATTRIBUTE_ENTITIES:
|
||||||
case XML_ATTRIBUTE_NOTATION:
|
case XML_ATTRIBUTE_NOTATION:
|
||||||
if (cur->defaultValue != NULL) {
|
if (cur->defaultValue != NULL) {
|
||||||
ctxt->valid &= xmlValidateAttributeValue2(ctxt, ctxt->doc,
|
|
||||||
cur->name, cur->atype, cur->defaultValue);
|
ret = xmlValidateAttributeValue2(ctxt, ctxt->doc, cur->name,
|
||||||
|
cur->atype, cur->defaultValue);
|
||||||
|
if ((ret == 0) && (ctxt->valid == 1))
|
||||||
|
ctxt->valid = 0;
|
||||||
}
|
}
|
||||||
if (cur->tree != NULL) {
|
if (cur->tree != NULL) {
|
||||||
xmlEnumerationPtr tree = cur->tree;
|
xmlEnumerationPtr tree = cur->tree;
|
||||||
while (tree != NULL) {
|
while (tree != NULL) {
|
||||||
ctxt->valid &= xmlValidateAttributeValue2(ctxt, ctxt->doc,
|
ret = xmlValidateAttributeValue2(ctxt, ctxt->doc,
|
||||||
cur->name, cur->atype, tree->name);
|
cur->name, cur->atype, tree->name);
|
||||||
|
if ((ret == 0) && (ctxt->valid == 1))
|
||||||
|
ctxt->valid = 0;
|
||||||
tree = tree->next;
|
tree = tree->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4834,29 +4860,35 @@ xmlValidateAttributeCallback(xmlAttributePtr cur, xmlValidCtxtPtr ctxt,
|
|||||||
* - check that NOTATION type attributes default or
|
* - check that NOTATION type attributes default or
|
||||||
* possible values matches one of the defined notations.
|
* possible values matches one of the defined notations.
|
||||||
*
|
*
|
||||||
* returns 1 if valid or 0 otherwise
|
* returns 1 if valid or 0 if invalid and -1 if not well-formed
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int
|
int
|
||||||
xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
|
||||||
int ret = 1;
|
|
||||||
xmlDtdPtr dtd;
|
xmlDtdPtr dtd;
|
||||||
xmlAttributeTablePtr table;
|
xmlAttributeTablePtr table;
|
||||||
|
xmlEntitiesTablePtr entities;
|
||||||
|
|
||||||
if (doc == NULL) return(0);
|
if (doc == NULL) return(0);
|
||||||
if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
|
if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
|
||||||
return(0);
|
return(0);
|
||||||
ctxt->doc = doc;
|
ctxt->doc = doc;
|
||||||
ctxt->valid = ret;
|
ctxt->valid = 1;
|
||||||
dtd = doc->intSubset;
|
dtd = doc->intSubset;
|
||||||
if ((dtd != NULL) && (dtd->attributes != NULL)) {
|
if ((dtd != NULL) && (dtd->attributes != NULL)) {
|
||||||
table = (xmlAttributeTablePtr) dtd->attributes;
|
table = (xmlAttributeTablePtr) dtd->attributes;
|
||||||
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
|
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
|
||||||
|
entities = (xmlEntitiesTablePtr) dtd->entities;
|
||||||
|
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
|
||||||
|
ctxt);
|
||||||
}
|
}
|
||||||
dtd = doc->extSubset;
|
dtd = doc->extSubset;
|
||||||
if ((dtd != NULL) && (dtd->attributes != NULL)) {
|
if ((dtd != NULL) && (dtd->attributes != NULL)) {
|
||||||
table = (xmlAttributeTablePtr) dtd->attributes;
|
table = (xmlAttributeTablePtr) dtd->attributes;
|
||||||
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
|
xmlHashScan(table, (xmlHashScanner) xmlValidateAttributeCallback, ctxt);
|
||||||
|
entities = (xmlEntitiesTablePtr) dtd->entities;
|
||||||
|
xmlHashScan(entities, (xmlHashScanner) xmlValidateNotationCallback,
|
||||||
|
ctxt);
|
||||||
}
|
}
|
||||||
return(ctxt->valid);
|
return(ctxt->valid);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user