diff --git a/SAX2.c b/SAX2.c index 86d3ccc0..74fca18a 100644 --- a/SAX2.c +++ b/SAX2.c @@ -39,6 +39,7 @@ xmlSAX2ErrMemory(xmlParserCtxtPtr ctxt) { xmlCtxtErrMemory(ctxt); } +#ifdef LIBXML_VALID_ENABLED /** * Handle a validation error * @@ -57,6 +58,7 @@ xmlErrValid(xmlParserCtxtPtr ctxt, xmlParserErrors error, if (ctxt != NULL) ctxt->valid = 0; } +#endif /* LIBXML_VALID_ENABLED */ /** * Handle a fatal parser error, i.e. violating Well-Formedness constraints @@ -1255,10 +1257,15 @@ process_external_subset: if (elemDecl != NULL) { xmlAttributePtr attr = elemDecl->attributes; - /* - * Check against defaulted attributes from the external subset - * if the document is stamped as standalone - */ + +#ifdef LIBXML_VALID_ENABLED + /* + * Check against defaulted attributes from the external subset + * if the document is stamped as standalone. + * + * This should be moved to valid.c, but we don't keep track + * whether an attribute was defaulted. + */ if ((ctxt->myDoc->standalone == 1) && (ctxt->myDoc->extSubset != NULL) && (ctxt->validate)) { @@ -1312,6 +1319,7 @@ process_external_subset: attr = attr->nexth; } } +#endif /* * Actually insert defaulted values when needed @@ -1411,6 +1419,7 @@ xmlSAX1StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) if ((ctx == NULL) || (fullname == NULL) || (ctxt->myDoc == NULL)) return; +#ifdef LIBXML_VALID_ENABLED /* * First check on validity: */ @@ -1424,6 +1433,7 @@ xmlSAX1StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts) "Validation failed: no DTD found !", NULL, NULL); ctxt->validate = 0; } +#endif /* * Split the full name into a namespace prefix and the tag name @@ -2127,6 +2137,8 @@ xmlSAX2StartElementNs(void *ctx, int i, j; if (ctx == NULL) return; + +#ifdef LIBXML_VALID_ENABLED /* * First check on validity: */ @@ -2142,6 +2154,7 @@ xmlSAX2StartElementNs(void *ctx, "Validation failed: no DTD found !", NULL, NULL); ctxt->validate = 0; } +#endif /* LIBXML_VALID_ENABLED */ /* * Take care of the rare case of an undefined namespace prefix diff --git a/parser.c b/parser.c index e544dcc0..b2432811 100644 --- a/parser.c +++ b/parser.c @@ -268,6 +268,7 @@ xmlWarningMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error, str1, str2, NULL, 0, msg, str1, str2); } +#ifdef LIBXML_VALID_ENABLED /** * Handle a validity error. * @@ -286,6 +287,7 @@ xmlValidityError(xmlParserCtxtPtr ctxt, xmlParserErrors error, xmlCtxtErr(ctxt, NULL, XML_FROM_DTD, error, XML_ERR_ERROR, str1, str2, NULL, 0, msg, str1, str2); } +#endif /** * Handle a fatal parser error, i.e. violating Well-Formedness constraints @@ -7234,6 +7236,7 @@ xmlHandleUndeclaredEntity(xmlParserCtxtPtr ctxt, const xmlChar *name) { (ctxt->hasPErefs == 0))) { xmlFatalErrMsgStr(ctxt, XML_ERR_UNDECLARED_ENTITY, "Entity '%s' not defined\n", name); +#ifdef LIBXML_VALID_ENABLED } else if (ctxt->validate) { /* * [ VC: Entity Declared ] @@ -7244,6 +7247,7 @@ xmlHandleUndeclaredEntity(xmlParserCtxtPtr ctxt, const xmlChar *name) { */ xmlValidityError(ctxt, XML_ERR_UNDECLARED_ENTITY, "Entity '%s' not defined\n", name, NULL); +#endif } else if ((ctxt->loadsubset & ~XML_SKIP_IDS) || ((ctxt->replaceEntities) && ((ctxt->options & XML_PARSE_NO_XXE) == 0))) { @@ -9092,12 +9096,21 @@ next_attr: atts[nbatts++] = XML_INT_TO_PTR(nsIndex); atts[nbatts++] = attr->value.name; atts[nbatts++] = attr->valueEnd; - if ((ctxt->standalone == 1) && (attr->external != 0)) { + +#ifdef LIBXML_VALID_ENABLED + /* + * This should be moved to valid.c, but we don't keep track + * whether an attribute was defaulted. + */ + if ((ctxt->validate) && + (ctxt->standalone == 1) && + (attr->external != 0)) { xmlValidityError(ctxt, XML_DTD_STANDALONE_DEFAULTED, "standalone: attribute %s on %s defaulted " "from external subset\n", attname, localname); } +#endif nbdef++; } }