starting to cleanup some of the problems exposed by the W3C/NIST

* SAX2.c parser.c valid.c: starting to cleanup some of the
  problems exposed by the W3C/NIST regression suite.
* result/ent7.sax result/xml2.sax: small fixes.
Daniel
This commit is contained in:
Daniel Veillard 2003-09-15 12:56:36 +00:00
parent bc92ecad5c
commit 62998c0ec7
6 changed files with 50 additions and 40 deletions

View File

@ -1,3 +1,9 @@
Mon Sep 15 14:54:42 CEST 2003 Daniel Veillard <daniel@veillard.com>
* SAX2.c parser.c valid.c: starting to cleanup some of the
problems exposed by the W3C/NIST regression suite.
* result/ent7.sax result/xml2.sax: small fixes.
Mon Sep 15 11:46:47 CEST 2003 Daniel Veillard <daniel@veillard.com>
* parser.c: more parser error factoring

70
SAX2.c
View File

@ -1596,9 +1596,9 @@ decode:
/**
* xmlSAX2AttributeNs:
* @ctx: the user data (XML parser context)
* @localname: the local name of the element
* @prefix: the element namespace prefix if available
* @URI: the element namespace name if available
* @localname: the local name of the attribute
* @prefix: the attribute namespace prefix if available
* @URI: the attribute namespace name if available
* @value: Start of the attribute value
* @valueend: end of the attribute value
*
@ -1618,11 +1618,6 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
xmlNsPtr namespace = NULL;
xmlChar *dup = NULL;
#if 0
TODO, check taht CDATA normalization is done at the
parser level !!!!!
#endif
/*
* Note: if prefix == NULL, the attribute is not in the default namespace
*/
@ -1662,31 +1657,50 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
if (!ctxt->replaceEntities) {
dup = xmlSAX2DecodeAttrEntities(ctxt, value, valueend);
if (dup == NULL) {
/*
* cheaper to finally allocate here than duplicate
* entry points in the full validation code
*/
dup = xmlStrndup(value, valueend - value);
if (*valueend == 0) {
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, value);
} else {
/*
* That should already be normalized.
* cheaper to finally allocate here than duplicate
* entry points in the full validation code
*/
dup = xmlStrndup(value, valueend - value);
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, dup);
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, dup);
}
} else {
#if 0
TODO
xmlChar *nvalnorm;
/*
* Do the last stage of the attribute normalization
/*
* dup now contains a string of the flattened attribute
* content with entities substitued. Check if we need to
* apply an extra layer of normalization.
* It need to be done twice ... it's an extra burden related
* to the ability to keep references in attributes
*/
nvalnorm = xmlValidNormalizeAttributeValue(ctxt->myDoc,
ctxt->node, fullname, dup);
if (nvalnorm != NULL) {
xmlFree(dup);
dup = nvalnorm;
if (ctxt->attsSpecial != NULL) {
xmlChar *nvalnorm;
xmlChar fn[50];
xmlChar *fullname;
fullname = xmlBuildQName(localname, prefix, fn, 50);
if (fullname != NULL) {
ctxt->vctxt.valid = 1;
nvalnorm = xmlValidCtxtNormalizeAttributeValue(
&ctxt->vctxt, ctxt->myDoc,
ctxt->node, fullname, dup);
if (ctxt->vctxt.valid != 1)
ctxt->valid = 0;
if ((fullname != fn) && (fullname != localname))
xmlFree(fullname);
if (nvalnorm != NULL) {
xmlFree(dup);
dup = nvalnorm;
}
}
}
#endif
ctxt->valid &= xmlValidateOneAttribute(&ctxt->vctxt,
ctxt->myDoc, ctxt->node, ret, dup);
@ -2221,7 +2235,7 @@ xmlSAX2CDataBlock(void *ctx, const xmlChar *value, int len)
}
}
static xmlSAX2DefaultVersionValue = 2;
static int xmlSAX2DefaultVersionValue = 2;
/**
* xmlSAXDefaultVersion:

View File

@ -3024,10 +3024,10 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
(c != '<')) {
if (c == 0) break;
if (c == '&') {
in_space = 0;
if (NXT(1) == '#') {
int val = xmlParseCharRef(ctxt);
in_space = 0;
if (val == '&') {
if (ctxt->replaceEntities) {
if (len > buf_size - 10) {
@ -3071,7 +3071,6 @@ xmlParseAttValueComplex(xmlParserCtxtPtr ctxt, int *attlen, int normalize) {
} else {
buf[len++] = ent->content[0];
}
in_space = 0;
} else if ((ent != NULL) &&
(ctxt->replaceEntities != 0)) {
xmlChar *rep;

View File

@ -1,4 +1,3 @@
xmlSAXUserParseFile returned error 27
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(item, , )

View File

@ -1,4 +1,3 @@
xmlSAXUserParseFile returned error 27
SAX.setDocumentLocator()
SAX.startDocument()
SAX.internalSubset(test, , )

View File

@ -3319,17 +3319,10 @@ xmlValidateAttributeValue2(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
xmlEntityPtr ent;
ent = xmlGetDocEntity(doc, value);
/* yeah it's a bit messy... */
if ((ent == NULL) && (doc->standalone == 1)) {
doc->standalone = 0;
ent = xmlGetDocEntity(doc, value);
if (ent != NULL) {
VERROR(ctxt->userData,
"standalone problem: attribute %s reference entity \"%s\" in external subset\n",
name, value);
/* WAIT to get answer from the Core WG on this
ret = 0;
*/
}
}
if (ent == NULL) {
VERROR(ctxt->userData,