summaryrefslogtreecommitdiff
path: root/chromium/third_party/libxml/src/SAX2.c
diff options
context:
space:
mode:
authorAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-12 15:59:20 +0200
committerAllan Sandfeld Jensen <allan.jensen@qt.io>2022-05-25 06:57:22 +0000
commitf7eaed5286974984ba5f9e3189d8f49d03e99f81 (patch)
treecaed19b2af2024f35449fb0b781d0a25e09d4f8f /chromium/third_party/libxml/src/SAX2.c
parent9729c4479fe23554eae6e6dd1f30ff488f470c84 (diff)
downloadqtwebengine-chromium-f7eaed5286974984ba5f9e3189d8f49d03e99f81.tar.gz
BASELINE: Update Chromium to 100.0.4896.167
Change-Id: I98cbeb5d7543d966ffe04d8cefded0c493a11333 Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
Diffstat (limited to 'chromium/third_party/libxml/src/SAX2.c')
-rw-r--r--chromium/third_party/libxml/src/SAX2.c149
1 files changed, 84 insertions, 65 deletions
diff --git a/chromium/third_party/libxml/src/SAX2.c b/chromium/third_party/libxml/src/SAX2.c
index 99019a984cd..9a093bcd88c 100644
--- a/chromium/third_party/libxml/src/SAX2.c
+++ b/chromium/third_party/libxml/src/SAX2.c
@@ -181,31 +181,6 @@ xmlWarnMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
}
/**
- * xmlNsErrMsg:
- * @ctxt: an XML parser context
- * @error: the error number
- * @msg: the error message
- * @str1: an error string
- * @str2: an error string
- *
- * Handle a namespace error
- */
-static void LIBXML_ATTR_FORMAT(3,0)
-xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
- const char *msg, const xmlChar *str1, const xmlChar *str2)
-{
- if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
- (ctxt->instate == XML_PARSER_EOF))
- return;
- if (ctxt != NULL)
- ctxt->errNo = error;
- __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
- XML_ERR_ERROR, NULL, 0,
- (const char *) str1, (const char *) str2,
- NULL, 0, 0, msg, str1, str2);
-}
-
-/**
* xmlNsWarnMsg:
* @ctxt: an XML parser context
* @error: the error number
@@ -709,6 +684,9 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
xmlAttributePtr attr;
xmlChar *name = NULL, *prefix = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) attr;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -742,6 +720,7 @@ xmlSAX2AttributeDecl(void *ctx, const xmlChar *elem, const xmlChar *fullname,
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
"SAX.xmlSAX2AttributeDecl(%s) called while not in subset\n",
name, NULL);
+ xmlFree(name);
xmlFreeEnumeration(tree);
return;
}
@@ -775,6 +754,9 @@ xmlSAX2ElementDecl(void *ctx, const xmlChar * name, int type,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlElementPtr elem = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) elem;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -821,6 +803,9 @@ xmlSAX2NotationDecl(void *ctx, const xmlChar *name,
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
xmlNotationPtr nota = NULL;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nota;
+
if ((ctxt == NULL) || (ctxt->myDoc == NULL))
return;
@@ -1051,6 +1036,31 @@ xmlSAX2EndDocument(void *ctx)
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
/**
+ * xmlNsErrMsg:
+ * @ctxt: an XML parser context
+ * @error: the error number
+ * @msg: the error message
+ * @str1: an error string
+ * @str2: an error string
+ *
+ * Handle a namespace error
+ */
+static void LIBXML_ATTR_FORMAT(3,0)
+xmlNsErrMsg(xmlParserCtxtPtr ctxt, xmlParserErrors error,
+ const char *msg, const xmlChar *str1, const xmlChar *str2)
+{
+ if ((ctxt != NULL) && (ctxt->disableSAX != 0) &&
+ (ctxt->instate == XML_PARSER_EOF))
+ return;
+ if (ctxt != NULL)
+ ctxt->errNo = error;
+ __xmlRaiseError(NULL, NULL, NULL, ctxt, NULL, XML_FROM_NAMESPACE, error,
+ XML_ERR_ERROR, NULL, 0,
+ (const char *) str1, (const char *) str2,
+ NULL, 0, 0, msg, str1, str2);
+}
+
+/**
* xmlSAX2AttributeInternal:
* @ctx: the user data (XML parser context)
* @fullname: The attribute name, including namespace prefix
@@ -1143,6 +1153,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nsret;
+
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
@@ -1205,6 +1218,9 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
xmlNsPtr nsret;
xmlChar *val;
+ /* Avoid unused variable warning if features are disabled. */
+ (void) nsret;
+
if (!ctxt->replaceEntities) {
ctxt->depth++;
val = xmlStringDecodeEntities(ctxt, value, XML_SUBSTITUTE_REF,
@@ -1367,7 +1383,12 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
- ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
+ ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
+ /* Don't create IDs containing entity references */
+ (ret->children != NULL) &&
+ (ret->children->type == XML_TEXT_NODE) &&
+ (ret->children->next == NULL)) {
+ xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@@ -1378,16 +1399,16 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
*
* Open issue: normalization of the value.
*/
- if (xmlValidateNCName(value, 1) != 0) {
+ if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
- (const char *) value, NULL);
+ (const char *) content, NULL);
}
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret))
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret))
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, value, ret);
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
error:
@@ -1622,10 +1643,10 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
ctxt->nodemem = -1;
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
- if (ctxt->input->line < 65535)
- ret->line = (short) ctxt->input->line;
+ if (ctxt->input->line < USHRT_MAX)
+ ret->line = (unsigned short) ctxt->input->line;
else
- ret->line = 65535;
+ ret->line = USHRT_MAX;
}
}
@@ -1746,7 +1767,8 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
- if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
+ if ((ctxt->validate) &&
+ ((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@@ -1755,7 +1777,7 @@ xmlSAX2StartElement(void *ctx, const xmlChar *fullname, const xmlChar **atts)
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
- ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
+ ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
}
#endif /* LIBXML_VALID_ENABLED */
@@ -1886,10 +1908,10 @@ skip:
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
- if (ctxt->input->line < 65535)
- ret->line = (short) ctxt->input->line;
+ if (ctxt->input->line < USHRT_MAX)
+ ret->line = (unsigned short) ctxt->input->line;
else {
- ret->line = 65535;
+ ret->line = USHRT_MAX;
if (ctxt->options & XML_PARSE_BIG_LINES)
ret->psvi = (void *) (ptrdiff_t) ctxt->input->line;
}
@@ -2119,7 +2141,12 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
#endif /* LIBXML_VALID_ENABLED */
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
(((ctxt->replaceEntities == 0) && (ctxt->external != 2)) ||
- ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0)))) {
+ ((ctxt->replaceEntities != 0) && (ctxt->inSubset == 0))) &&
+ /* Don't create IDs containing entity references */
+ (ret->children != NULL) &&
+ (ret->children->type == XML_TEXT_NODE) &&
+ (ret->children->next == NULL)) {
+ xmlChar *content = ret->children->content;
/*
* when validating, the ID registration is done at the attribute
* validation level. Otherwise we have to do specific handling here.
@@ -2132,27 +2159,20 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
*
* Open issue: normalization of the value.
*/
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_DOCB_ENABLED) || defined(LIBXML_LEGACY_ENABLED)
#ifdef LIBXML_VALID_ENABLED
- if (xmlValidateNCName(dup, 1) != 0) {
+ if (xmlValidateNCName(content, 1) != 0) {
xmlErrValid(ctxt, XML_DTD_XMLID_VALUE,
"xml:id : attribute value %s is not an NCName\n",
- (const char *) dup, NULL);
+ (const char *) content, NULL);
}
#endif
#endif
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsID(ctxt->myDoc, ctxt->node, ret)) {
- /* might be worth duplicate entry points and not copy */
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddID(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddID(&ctxt->vctxt, ctxt->myDoc, content, ret);
} else if (xmlIsRef(ctxt->myDoc, ctxt->node, ret)) {
- if (dup == NULL)
- dup = xmlStrndup(value, valueend - value);
- xmlAddRef(&ctxt->vctxt, ctxt->myDoc, dup, ret);
+ xmlAddRef(&ctxt->vctxt, ctxt->myDoc, content, ret);
}
}
if (dup != NULL)
@@ -2266,10 +2286,10 @@ xmlSAX2StartElementNs(void *ctx,
}
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
- if (ctxt->input->line < 65535)
- ret->line = (short) ctxt->input->line;
+ if (ctxt->input->line < USHRT_MAX)
+ ret->line = (unsigned short) ctxt->input->line;
else
- ret->line = 65535;
+ ret->line = USHRT_MAX;
}
}
@@ -2404,7 +2424,8 @@ xmlSAX2StartElementNs(void *ctx,
* If it's the Document root, finish the DTD validation and
* check the document root element for validity
*/
- if ((ctxt->validate) && (ctxt->vctxt.finishDtd == XML_CTXT_FINISH_DTD_0)) {
+ if ((ctxt->validate) &&
+ ((ctxt->vctxt.flags & XML_VCTXT_DTD_VALIDATED) == 0)) {
int chk;
chk = xmlValidateDtdFinal(&ctxt->vctxt, ctxt->myDoc);
@@ -2413,7 +2434,7 @@ xmlSAX2StartElementNs(void *ctx,
if (chk < 0)
ctxt->wellFormed = 0;
ctxt->valid &= xmlValidateRoot(&ctxt->vctxt, ctxt->myDoc);
- ctxt->vctxt.finishDtd = XML_CTXT_FINISH_DTD_1;
+ ctxt->vctxt.flags |= XML_VCTXT_DTD_VALIDATED;
}
#endif /* LIBXML_VALID_ENABLED */
}
@@ -2688,10 +2709,10 @@ xmlSAX2ProcessingInstruction(void *ctx, const xmlChar *target,
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
- if (ctxt->input->line < 65535)
- ret->line = (short) ctxt->input->line;
+ if (ctxt->input->line < USHRT_MAX)
+ ret->line = (unsigned short) ctxt->input->line;
else
- ret->line = 65535;
+ ret->line = USHRT_MAX;
}
}
if (ctxt->inSubset == 1) {
@@ -2748,10 +2769,10 @@ xmlSAX2Comment(void *ctx, const xmlChar *value)
if (ret == NULL) return;
if (ctxt->linenumbers) {
if (ctxt->input != NULL) {
- if (ctxt->input->line < 65535)
- ret->line = (short) ctxt->input->line;
+ if (ctxt->input->line < USHRT_MAX)
+ ret->line = (unsigned short) ctxt->input->line;
else
- ret->line = 65535;
+ ret->line = USHRT_MAX;
}
}
@@ -3032,5 +3053,3 @@ docbDefaultSAXHandlerInit(void)
}
#endif /* LIBXML_DOCB_ENABLED */
-#define bottom_SAX2
-#include "elfgcchack.h"