[LIBXML2] Update to version 2.10.0. CORE-17766

This commit is contained in:
Thomas Faber 2022-11-20 10:17:45 -05:00
parent 608bbe1136
commit 911153da10
No known key found for this signature in database
GPG key ID: 076E7C3D44720826
80 changed files with 2351 additions and 20735 deletions

View file

@ -38,7 +38,7 @@
#define IN_LIBXML
#include "libxml.h"
#if defined(_WIN32) && !defined (__CYGWIN__)
#if defined(_WIN32)
#define XML_DIR_SEP '\\'
#else
#define XML_DIR_SEP '/'
@ -49,6 +49,8 @@
#include <string.h>
#include <stdarg.h>
#include <stddef.h>
#include <ctype.h>
#include <stdlib.h>
#include <libxml/xmlmemory.h>
#include <libxml/threads.h>
#include <libxml/globals.h>
@ -68,21 +70,6 @@
#include <libxml/xmlschemastypes.h>
#include <libxml/relaxng.h>
#endif
#ifdef HAVE_CTYPE_H
#include <ctype.h>
#endif
#ifdef HAVE_STDLIB_H
#include <stdlib.h>
#endif
#ifdef HAVE_SYS_STAT_H
#include <sys/stat.h>
#endif
#ifdef HAVE_FCNTL_H
#include <fcntl.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include "buf.h"
#include "enc.h"
@ -302,7 +289,7 @@ unsigned int xmlParserMaxDepth = 256;
* List of XML prefixed PI allowed by W3C specs
*/
static const char *xmlW3CPIs[] = {
static const char* const xmlW3CPIs[] = {
"xml-stylesheet",
"xml-model",
NULL
@ -1104,6 +1091,10 @@ xmlHasFeature(xmlFeature feature)
static void
xmlDetectSAX2(xmlParserCtxtPtr ctxt) {
xmlSAXHandlerPtr sax;
/* Avoid unused variable warning if features are disabled. */
(void) sax;
if (ctxt == NULL) return;
sax = ctxt->sax;
#ifdef LIBXML_SAX1_ENABLED
@ -1761,9 +1752,7 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
sizeof(ctxt->inputTab[0]));
if (ctxt->inputTab == NULL) {
xmlErrMemory(ctxt, NULL);
xmlFreeInputStream(value);
ctxt->inputMax /= 2;
value = NULL;
return (-1);
}
}
@ -2176,6 +2165,9 @@ static void xmlGROW (xmlParserCtxtPtr ctxt) {
if (l == 1) b[i++] = (xmlChar) v; \
else i += xmlCopyCharMultiByte(&b[i],v)
#define CUR_CONSUMED \
(ctxt->input->consumed + (ctxt->input->cur - ctxt->input->base))
/**
* xmlSkipBlankChars:
* @ctxt: the XML parser context
@ -6815,12 +6807,12 @@ xmlParseConditionalSections(xmlParserCtxtPtr ctxt) {
}
SKIP(3);
} else {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
xmlParseMarkupDecl(ctxt);
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
xmlHaltParser(ctxt);
goto error;
@ -7039,8 +7031,8 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
while (((RAW == '<') && (NXT(1) == '?')) ||
((RAW == '<') && (NXT(1) == '!')) ||
(RAW == '%')) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
GROW;
if ((RAW == '<') && (NXT(1) == '!') && (NXT(2) == '[')) {
@ -7049,7 +7041,7 @@ xmlParseExternalSubset(xmlParserCtxtPtr ctxt, const xmlChar *ExternalID,
xmlParseMarkupDecl(ctxt);
SKIP_BLANKS;
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_EXT_SUBSET_NOT_FINISHED, NULL);
break;
}
@ -7240,7 +7232,8 @@ xmlParseReference(xmlParserCtxtPtr ctxt) {
ent->owner = 1;
while (list != NULL) {
list->parent = (xmlNodePtr) ent;
xmlSetTreeDoc(list, ent->doc);
if (list->doc != ent->doc)
xmlSetTreeDoc(list, ent->doc);
if (list->next == NULL)
ent->last = list;
list = list->next;
@ -8079,6 +8072,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
"xmlLoadEntityContent parameter error");
return(-1);
}
xmlBufferSetAllocationScheme(buf, XML_BUFFER_ALLOC_DOUBLEIT);
input = xmlNewEntityInputStream(ctxt, entity);
if (input == NULL) {
@ -8094,6 +8088,7 @@ xmlLoadEntityContent(xmlParserCtxtPtr ctxt, xmlEntityPtr entity) {
*/
if (xmlPushInput(ctxt, input) < 0) {
xmlBufferFree(buf);
xmlFreeInputStream(input);
return(-1);
}
@ -8361,8 +8356,8 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
*/
while (((RAW != ']') || (ctxt->inputNr > baseInputNr)) &&
(ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *check = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
SKIP_BLANKS;
xmlParseMarkupDecl(ctxt);
@ -8377,7 +8372,7 @@ xmlParseInternalSubset(xmlParserCtxtPtr ctxt) {
xmlParseConditionalSections(ctxt);
}
if ((CUR_PTR == check) && (cons == ctxt->input->consumed)) {
if ((id == ctxt->input->id) && (cons == CUR_CONSUMED)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseInternalSubset: error detected in Markup declaration\n");
if (ctxt->inputNr > baseInputNr)
@ -8556,8 +8551,8 @@ xmlParseStartTag(xmlParserCtxtPtr ctxt) {
while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
attname = xmlParseAttribute(ctxt, &attvalue);
if ((attname != NULL) && (attvalue != NULL)) {
@ -8622,7 +8617,7 @@ failed:
xmlFatalErrMsg(ctxt, XML_ERR_SPACE_REQUIRED,
"attributes construct error\n");
}
if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
(attname == NULL) && (attvalue == NULL)) {
xmlFatalErrMsg(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseStartTag: problem parsing attributes\n");
@ -9306,8 +9301,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
while (((RAW != '>') &&
((RAW != '/') || (NXT(1) != '>')) &&
(IS_BYTE_CHAR(RAW))) && (ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *q = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
int len = -1, alloc = 0;
attname = xmlParseAttribute2(ctxt, prefix, localname,
@ -9488,7 +9483,7 @@ next_attr:
"attributes construct error\n");
break;
}
if ((cons == ctxt->input->consumed) && (q == CUR_PTR) &&
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id) &&
(attname == NULL) && (attvalue == NULL)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"xmlParseStartTag: problem parsing attributes\n");
@ -9872,8 +9867,8 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
GROW;
while ((RAW != 0) &&
(ctxt->instate != XML_PARSER_EOF)) {
const xmlChar *test = CUR_PTR;
unsigned int cons = ctxt->input->consumed;
int id = ctxt->input->id;
unsigned long cons = CUR_CONSUMED;
const xmlChar *cur = ctxt->input->cur;
/*
@ -9932,7 +9927,7 @@ xmlParseContentInternal(xmlParserCtxtPtr ctxt) {
GROW;
SHRINK;
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
xmlHaltParser(ctxt);
@ -10889,8 +10884,6 @@ xmlParseExtParsedEnt(xmlParserCtxtPtr ctxt) {
if ((ctxt == NULL) || (ctxt->input == NULL))
return(-1);
xmlDefaultSAXHandlerInit();
xmlDetectSAX2(ctxt);
GROW;
@ -11527,15 +11520,15 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
break;
}
case XML_PARSER_CONTENT: {
const xmlChar *test;
unsigned int cons;
int id;
unsigned long cons;
if ((avail < 2) && (ctxt->inputNr == 1))
goto done;
cur = ctxt->input->cur[0];
next = ctxt->input->cur[1];
test = CUR_PTR;
cons = ctxt->input->consumed;
id = ctxt->input->id;
cons = CUR_CONSUMED;
if ((cur == '<') && (next == '/')) {
ctxt->instate = XML_PARSER_END_TAG;
break;
@ -11616,7 +11609,7 @@ xmlParseTryOrFinish(xmlParserCtxtPtr ctxt, int terminate) {
ctxt->checkIndex = 0;
xmlParseCharData(ctxt, 0);
}
if ((cons == ctxt->input->consumed) && (test == CUR_PTR)) {
if ((cons == CUR_CONSUMED) && (id == ctxt->input->id)) {
xmlFatalErr(ctxt, XML_ERR_INTERNAL_ERROR,
"detected an error in element content\n");
xmlHaltParser(ctxt);
@ -13590,7 +13583,7 @@ xmlParseInNodeContext(xmlNodePtr node, const char *data, int datalen,
ctxt->input_id = 2;
ctxt->instate = XML_PARSER_CONTENT;
fake = xmlNewComment(NULL);
fake = xmlNewDocComment(node->doc, NULL);
if (fake == NULL) {
xmlFreeParserCtxt(ctxt);
return(XML_ERR_NO_MEMORY);
@ -14827,6 +14820,8 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
ctxt->nameNr = 0;
ctxt->name = NULL;
ctxt->nsNr = 0;
DICT_FREE(ctxt->version);
ctxt->version = NULL;
DICT_FREE(ctxt->encoding);
@ -15552,5 +15547,3 @@ xmlCtxtReadIO(xmlParserCtxtPtr ctxt, xmlInputReadCallback ioread,
return (xmlDoRead(ctxt, URL, encoding, options, 1));
}
#define bottom_parser
#include "elfgcchack.h"