diff --git a/ChangeLog b/ChangeLog index 18bbb070..b1c20f64 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Mon Sep 15 14:54:42 CEST 2003 Daniel Veillard + + * 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 * parser.c: more parser error factoring diff --git a/SAX2.c b/SAX2.c index 4707d026..00fdcb53 100644 --- a/SAX2.c +++ b/SAX2.c @@ -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: diff --git a/parser.c b/parser.c index 1154204a..944a6564 100644 --- a/parser.c +++ b/parser.c @@ -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; diff --git a/result/ent7.sax b/result/ent7.sax index 0d5befa8..40395975 100644 --- a/result/ent7.sax +++ b/result/ent7.sax @@ -1,4 +1,3 @@ -xmlSAXUserParseFile returned error 27 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(item, , ) diff --git a/result/xml2.sax b/result/xml2.sax index e8484733..04d7089b 100644 --- a/result/xml2.sax +++ b/result/xml2.sax @@ -1,4 +1,3 @@ -xmlSAXUserParseFile returned error 27 SAX.setDocumentLocator() SAX.startDocument() SAX.internalSubset(test, , ) diff --git a/valid.c b/valid.c index 36d1a35b..470f912f 100644 --- a/valid.c +++ b/valid.c @@ -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,