Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2)

Unified Diff: third_party/libxml/valid.c

Issue 2951008: Update libxml to 2.7.7. (Closed) Base URL: http://src.chromium.org/git/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/libxml/valid.c
diff --git a/third_party/libxml/valid.c b/third_party/libxml/valid.c
index 2510b8d6a49a00a9072c9093e30a7780ebfdc54d..2cb32f32c841f98e7ce425a308a3d18d4cafa959 100644
--- a/third_party/libxml/valid.c
+++ b/third_party/libxml/valid.c
@@ -36,6 +36,11 @@ static xmlElementPtr xmlGetDtdElementDesc2(xmlDtdPtr dtd, const xmlChar *name,
"Unimplemented block at %s:%d\n", \
__FILE__, __LINE__);
+#ifdef LIBXML_VALID_ENABLED
+static int
+xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
+ const xmlChar *value);
+#endif
/************************************************************************
* *
* Error handling routines *
@@ -117,7 +122,7 @@ xmlErrValid(xmlValidCtxtPtr ctxt, xmlParserErrors error,
__xmlRaiseError(NULL, channel, data,
pctxt, NULL, XML_FROM_VALID, error,
XML_ERR_ERROR, NULL, 0, NULL, NULL, NULL, 0, 0,
- msg);
+ "%s", msg);
}
#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)
@@ -632,8 +637,6 @@ xmlValidStateDebug(xmlValidCtxtPtr ctxt) {
else if ((doc->intSubset == NULL) && \
(doc->extSubset == NULL)) return(0)
-xmlAttributePtr xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem);
-
#ifdef LIBXML_REGEXP_ENABLED
/************************************************************************
@@ -1828,53 +1831,6 @@ xmlDumpEnumeration(xmlBufferPtr buf, xmlEnumerationPtr cur) {
#ifdef LIBXML_VALID_ENABLED
/**
- * xmlScanAttributeDeclCallback:
- * @attr: the attribute decl
- * @list: the list to update
- *
- * Callback called by xmlScanAttributeDecl when a new attribute
- * has to be entered in the list.
- */
-static void
-xmlScanAttributeDeclCallback(xmlAttributePtr attr, xmlAttributePtr *list,
- const xmlChar* name ATTRIBUTE_UNUSED) {
- attr->nexth = *list;
- *list = attr;
-}
-
-/**
- * xmlScanAttributeDecl:
- * @dtd: pointer to the DTD
- * @elem: the element name
- *
- * When inserting a new element scan the DtD for existing attributes
- * for that element and initialize the Attribute chain
- *
- * Returns the pointer to the first attribute decl in the chain,
- * possibly NULL.
- */
-xmlAttributePtr
-xmlScanAttributeDecl(xmlDtdPtr dtd, const xmlChar *elem) {
- xmlAttributePtr ret = NULL;
- xmlAttributeTablePtr table;
-
- if (dtd == NULL) {
- return(NULL);
- }
- if (elem == NULL) {
- return(NULL);
- }
- table = (xmlAttributeTablePtr) dtd->attributes;
- if (table == NULL)
- return(NULL);
-
- /* WRONG !!! */
- xmlHashScan3(table, NULL, NULL, elem,
- (xmlHashScanner) xmlScanAttributeDeclCallback, &ret);
- return(ret);
-}
-
-/**
* xmlScanIDAttributeDecl:
* @ctxt: the validation context
* @elem: the element name
@@ -2024,7 +1980,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
return(NULL);
}
if ((defaultValue != NULL) &&
- (!xmlValidateAttributeValue(type, defaultValue))) {
+ (!xmlValidateAttributeValueInternal(dtd->doc, type, defaultValue))) {
xmlErrValidNode(ctxt, (xmlNodePtr) dtd, XML_DTD_ATTRIBUTE_DEFAULT,
"Attribute %s of %s: invalid default value\n",
elem, name, defaultValue);
@@ -2042,8 +1998,10 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
(dtd->doc->intSubset != NULL) &&
(dtd->doc->intSubset->attributes != NULL)) {
ret = xmlHashLookup3(dtd->doc->intSubset->attributes, name, ns, elem);
- if (ret != NULL)
+ if (ret != NULL) {
+ xmlFreeEnumeration(tree);
return(NULL);
+ }
}
/*
@@ -2057,6 +2015,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
if (table == NULL) {
xmlVErrMemory(ctxt,
"xmlAddAttributeDecl: Table creation failed!\n");
+ xmlFreeEnumeration(tree);
return(NULL);
}
@@ -2064,6 +2023,7 @@ xmlAddAttributeDecl(xmlValidCtxtPtr ctxt,
ret = (xmlAttributePtr) xmlMalloc(sizeof(xmlAttribute));
if (ret == NULL) {
xmlVErrMemory(ctxt, "malloc failed");
+ xmlFreeEnumeration(tree);
return(NULL);
}
memset(ret, 0, sizeof(xmlAttribute));
@@ -2719,7 +2679,8 @@ xmlIsID(xmlDocPtr doc, xmlNodePtr elem, xmlAttrPtr attr) {
(!strcmp((char *) attr->ns->prefix, "xml")))
return(1);
if (doc == NULL) return(0);
- if ((doc->intSubset == NULL) && (doc->extSubset == NULL)) {
+ if ((doc->intSubset == NULL) && (doc->extSubset == NULL) &&
+ (doc->type != XML_HTML_DOCUMENT_NODE)) {
return(0);
} else if (doc->type == XML_HTML_DOCUMENT_NODE) {
if ((xmlStrEqual(BAD_CAST "id", attr->name)) ||
@@ -3390,7 +3351,8 @@ int
xmlValidateNotationUse(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
const xmlChar *notationName) {
xmlNotationPtr notaDecl;
- if ((doc == NULL) || (doc->intSubset == NULL)) return(-1);
+ if ((doc == NULL) || (doc->intSubset == NULL) ||
+ (notationName == NULL)) return(-1);
notaDecl = xmlGetDtdNotationDesc(doc->intSubset, notationName);
if ((notaDecl == NULL) && (doc->extSubset != NULL))
@@ -3445,8 +3407,78 @@ xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
}
#ifdef LIBXML_VALID_ENABLED
+
+static int
+xmlIsDocNameStartChar(xmlDocPtr doc, int c) {
+ if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ (c == '_') || (c == ':') ||
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF)))
+ return(1);
+ } else {
+ if (IS_LETTER(c) || (c == '_') || (c == ':'))
+ return(1);
+ }
+ return(0);
+}
+
+static int
+xmlIsDocNameChar(xmlDocPtr doc, int c) {
+ if ((doc == NULL) || (doc->properties & XML_DOC_OLD10) == 0) {
+ /*
+ * Use the new checks of production [4] [4a] amd [5] of the
+ * Update 5 of XML-1.0
+ */
+ if (((c >= 'a') && (c <= 'z')) ||
+ ((c >= 'A') && (c <= 'Z')) ||
+ ((c >= '0') && (c <= '9')) || /* !start */
+ (c == '_') || (c == ':') ||
+ (c == '-') || (c == '.') || (c == 0xB7) || /* !start */
+ ((c >= 0xC0) && (c <= 0xD6)) ||
+ ((c >= 0xD8) && (c <= 0xF6)) ||
+ ((c >= 0xF8) && (c <= 0x2FF)) ||
+ ((c >= 0x300) && (c <= 0x36F)) || /* !start */
+ ((c >= 0x370) && (c <= 0x37D)) ||
+ ((c >= 0x37F) && (c <= 0x1FFF)) ||
+ ((c >= 0x200C) && (c <= 0x200D)) ||
+ ((c >= 0x203F) && (c <= 0x2040)) || /* !start */
+ ((c >= 0x2070) && (c <= 0x218F)) ||
+ ((c >= 0x2C00) && (c <= 0x2FEF)) ||
+ ((c >= 0x3001) && (c <= 0xD7FF)) ||
+ ((c >= 0xF900) && (c <= 0xFDCF)) ||
+ ((c >= 0xFDF0) && (c <= 0xFFFD)) ||
+ ((c >= 0x10000) && (c <= 0xEFFFF)))
+ return(1);
+ } else {
+ if ((IS_LETTER(c)) || (IS_DIGIT(c)) ||
+ (c == '.') || (c == '-') ||
+ (c == '_') || (c == ':') ||
+ (IS_COMBINING(c)) ||
+ (IS_EXTENDER(c)))
+ return(1);
+ }
+ return(0);
+}
+
/**
* xmlValidateNameValue:
+ * @doc: pointer to the document or NULL
* @value: an Name value
*
* Validate that the given value match Name production
@@ -3454,8 +3486,8 @@ xmlIsMixedElement(xmlDocPtr doc, const xmlChar *name) {
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNameValue(const xmlChar *value) {
+static int
+xmlValidateNameValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3463,18 +3495,12 @@ xmlValidateNameValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3485,7 +3511,22 @@ xmlValidateNameValue(const xmlChar *value) {
}
/**
- * xmlValidateNamesValue:
+ * xmlValidateNameValue:
+ * @value: an Name value
+ *
+ * Validate that the given value match Name production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNameValue(const xmlChar *value) {
+ return(xmlValidateNameValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNamesValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Names value
*
* Validate that the given value match Names production
@@ -3493,8 +3534,8 @@ xmlValidateNameValue(const xmlChar *value) {
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNamesValue(const xmlChar *value) {
+static int
+xmlValidateNamesValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3502,19 +3543,13 @@ xmlValidateNamesValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3526,18 +3561,13 @@ xmlValidateNamesValue(const xmlChar *value) {
cur += len;
}
- if (!IS_LETTER(val) && (val != '_') &&
- (val != ':')) {
+ if (!xmlIsDocNameStartChar(doc, val))
return(0);
- }
+
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3549,18 +3579,33 @@ xmlValidateNamesValue(const xmlChar *value) {
}
/**
- * xmlValidateNmtokenValue:
+ * xmlValidateNamesValue:
+ * @value: an Names value
+ *
+ * Validate that the given value match Names production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNamesValue(const xmlChar *value) {
+ return(xmlValidateNamesValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNmtokenValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Nmtoken value
*
* Validate that the given value match Nmtoken production
*
* [ VC: Name Token ]
- *
+ *
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNmtokenValue(const xmlChar *value) {
+static int
+xmlValidateNmtokenValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3568,19 +3613,13 @@ xmlValidateNmtokenValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ val = xmlStringCurrentChar(NULL, cur, &len);
+ cur += len;
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3591,18 +3630,35 @@ xmlValidateNmtokenValue(const xmlChar *value) {
}
/**
- * xmlValidateNmtokensValue:
+ * xmlValidateNmtokenValue:
+ * @value: an Nmtoken value
+ *
+ * Validate that the given value match Nmtoken production
+ *
+ * [ VC: Name Token ]
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNmtokenValue(const xmlChar *value) {
+ return(xmlValidateNmtokenValueInternal(NULL, value));
+}
+
+/**
+ * xmlValidateNmtokensValueInternal:
+ * @doc: pointer to the document or NULL
* @value: an Nmtokens value
*
* Validate that the given value match Nmtokens production
*
* [ VC: Name Token ]
- *
+ *
* returns 1 if valid or 0 otherwise
*/
-int
-xmlValidateNmtokensValue(const xmlChar *value) {
+static int
+xmlValidateNmtokensValueInternal(xmlDocPtr doc, const xmlChar *value) {
const xmlChar *cur;
int val, len;
@@ -3610,24 +3666,16 @@ xmlValidateNmtokensValue(const xmlChar *value) {
cur = value;
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
-
+
while (IS_BLANK(val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3640,18 +3688,13 @@ xmlValidateNmtokensValue(const xmlChar *value) {
}
if (val == 0) return(1);
- if (!IS_LETTER(val) && !IS_DIGIT(val) &&
- (val != '.') && (val != '-') &&
- (val != '_') && (val != ':') &&
- (!IS_COMBINING(val)) &&
- (!IS_EXTENDER(val)))
+ if (!xmlIsDocNameChar(doc, val))
return(0);
- while ((IS_LETTER(val)) || (IS_DIGIT(val)) ||
- (val == '.') || (val == '-') ||
- (val == '_') || (val == ':') ||
- (IS_COMBINING(val)) ||
- (IS_EXTENDER(val))) {
+ val = xmlStringCurrentChar(NULL, cur, &len);
+ cur += len;
+
+ while (xmlIsDocNameChar(doc, val)) {
val = xmlStringCurrentChar(NULL, cur, &len);
cur += len;
}
@@ -3663,6 +3706,22 @@ xmlValidateNmtokensValue(const xmlChar *value) {
}
/**
+ * xmlValidateNmtokensValue:
+ * @value: an Nmtokens value
+ *
+ * Validate that the given value match Nmtokens production
+ *
+ * [ VC: Name Token ]
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+int
+xmlValidateNmtokensValue(const xmlChar *value) {
+ return(xmlValidateNmtokensValueInternal(NULL, value));
+}
+
+/**
* xmlValidateNotationDecl:
* @ctxt: the validation context
* @doc: a document instance
@@ -3686,6 +3745,40 @@ xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATT
}
/**
+ * xmlValidateAttributeValueInternal:
+ * @doc: the document
+ * @type: an attribute type
+ * @value: an attribute value
+ *
+ * Validate that the given attribute value match the proper production
+ *
+ * returns 1 if valid or 0 otherwise
+ */
+
+static int
+xmlValidateAttributeValueInternal(xmlDocPtr doc, xmlAttributeType type,
+ const xmlChar *value) {
+ switch (type) {
+ case XML_ATTRIBUTE_ENTITIES:
+ case XML_ATTRIBUTE_IDREFS:
+ return(xmlValidateNamesValueInternal(doc, value));
+ case XML_ATTRIBUTE_ENTITY:
+ case XML_ATTRIBUTE_IDREF:
+ case XML_ATTRIBUTE_ID:
+ case XML_ATTRIBUTE_NOTATION:
+ return(xmlValidateNameValueInternal(doc, value));
+ case XML_ATTRIBUTE_NMTOKENS:
+ case XML_ATTRIBUTE_ENUMERATION:
+ return(xmlValidateNmtokensValueInternal(doc, value));
+ case XML_ATTRIBUTE_NMTOKEN:
+ return(xmlValidateNmtokenValueInternal(doc, value));
+ case XML_ATTRIBUTE_CDATA:
+ break;
+ }
+ return(1);
+}
+
+/**
* xmlValidateAttributeValue:
* @type: an attribute type
* @value: an attribute value
@@ -3709,27 +3802,9 @@ xmlValidateNotationDecl(xmlValidCtxtPtr ctxt ATTRIBUTE_UNUSED, xmlDocPtr doc ATT
*
* returns 1 if valid or 0 otherwise
*/
-
int
xmlValidateAttributeValue(xmlAttributeType type, const xmlChar *value) {
- switch (type) {
- case XML_ATTRIBUTE_ENTITIES:
- case XML_ATTRIBUTE_IDREFS:
- return(xmlValidateNamesValue(value));
- case XML_ATTRIBUTE_ENTITY:
- case XML_ATTRIBUTE_IDREF:
- case XML_ATTRIBUTE_ID:
- case XML_ATTRIBUTE_NOTATION:
- return(xmlValidateNameValue(value));
- case XML_ATTRIBUTE_NMTOKENS:
- case XML_ATTRIBUTE_ENUMERATION:
- return(xmlValidateNmtokensValue(value));
- case XML_ATTRIBUTE_NMTOKEN:
- return(xmlValidateNmtokenValue(value));
- case XML_ATTRIBUTE_CDATA:
- break;
- }
- return(1);
+ return(xmlValidateAttributeValueInternal(NULL, type, value));
}
/**
@@ -3978,13 +4053,10 @@ xmlValidNormalizeAttributeValue(xmlDocPtr doc, xmlNodePtr elem,
if ((elem->ns != NULL) && (elem->ns->prefix != NULL)) {
xmlChar fn[50];
xmlChar *fullname;
-
+
fullname = xmlBuildQName(elem->name, elem->ns->prefix, fn, 50);
if (fullname == NULL)
return(NULL);
- attrDecl = xmlGetDtdAttrDesc(doc->intSubset, fullname, name);
- if ((attrDecl == NULL) && (doc->extSubset != NULL))
- attrDecl = xmlGetDtdAttrDesc(doc->extSubset, fullname, name);
if ((fullname != fn) && (fullname != elem->name))
xmlFree(fullname);
}
@@ -4047,11 +4119,12 @@ xmlValidateAttributeDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
int val;
CHECK_DTD;
if(attr == NULL) return(1);
-
+
/* Attribute Default Legal */
/* Enumeration */
if (attr->defaultValue != NULL) {
- val = xmlValidateAttributeValue(attr->atype, attr->defaultValue);
+ val = xmlValidateAttributeValueInternal(doc, attr->atype,
+ attr->defaultValue);
if (val == 0) {
xmlErrValidNode(ctxt, (xmlNodePtr) attr, XML_DTD_ATTRIBUTE_DEFAULT,
"Syntax of default value for attribute %s of %s is not valid\n",
@@ -4182,15 +4255,15 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
while (next != NULL) {
if (next->type == XML_ELEMENT_CONTENT_ELEMENT) {
if ((xmlStrEqual(next->name, name)) &&
- (xmlStrEqual(next->prefix, cur->prefix))) {
- if (cur->prefix == NULL) {
+ (xmlStrEqual(next->prefix, cur->c1->prefix))) {
+ if (cur->c1->prefix == NULL) {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references of %s\n",
elem->name, name, NULL);
} else {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references of %s:%s\n",
- elem->name, cur->prefix, name);
+ elem->name, cur->c1->prefix, name);
}
ret = 0;
}
@@ -4199,15 +4272,15 @@ xmlValidateElementDecl(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
if (next->c1 == NULL) break;
if (next->c1->type != XML_ELEMENT_CONTENT_ELEMENT) break;
if ((xmlStrEqual(next->c1->name, name)) &&
- (xmlStrEqual(next->c1->prefix, cur->prefix))) {
- if (cur->prefix == NULL) {
+ (xmlStrEqual(next->c1->prefix, cur->c1->prefix))) {
+ if (cur->c1->prefix == NULL) {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references to %s\n",
elem->name, name, NULL);
} else {
xmlErrValidNode(ctxt, (xmlNodePtr) elem, XML_DTD_CONTENT_ERROR,
"Definition of %s has duplicate references to %s:%s\n",
- elem->name, cur->prefix, name);
+ elem->name, cur->c1->prefix, name);
}
ret = 0;
}
@@ -4332,7 +4405,7 @@ xmlValidateOneAttribute(xmlValidCtxtPtr ctxt, xmlDocPtr doc,
}
attr->atype = attrDecl->atype;
- val = xmlValidateAttributeValue(attrDecl->atype, value);
+ val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value);
if (val == 0) {
xmlErrValidNode(ctxt, elem, XML_DTD_ATTRIBUTE_VALUE,
"Syntax of value for attribute %s of %s is not valid\n",
@@ -4517,7 +4590,7 @@ xmlNodePtr elem, const xmlChar *prefix, xmlNsPtr ns, const xmlChar *value) {
return(0);
}
- val = xmlValidateAttributeValue(attrDecl->atype, value);
+ val = xmlValidateAttributeValueInternal(doc, attrDecl->atype, value);
if (val == 0) {
if (ns->prefix != NULL) {
xmlErrValidNode(ctxt, elem, XML_DTD_INVALID_DEFAULT,
@@ -6673,7 +6746,7 @@ xmlValidateDtdFinal(xmlValidCtxtPtr ctxt, xmlDocPtr doc) {
xmlAttributeTablePtr table;
xmlEntitiesTablePtr entities;
- if (doc == NULL) return(0);
+ if ((doc == NULL) || (ctxt == NULL)) return(0);
if ((doc->intSubset == NULL) && (doc->extSubset == NULL))
return(0);
ctxt->doc = doc;

Powered by Google App Engine
This is Rietveld 408576698