8000 Update libxml2 to v2.13.8 · modelica-3rdparty/ExternData@eace302 · GitHub
[go: up one dir, main page]

Skip to content

Commit eace302

Browse files
committed
Update libxml2 to v2.13.8
1 parent 308c0f2 commit eace302

File tree

17 files changed

+272
-169
lines changed

17 files changed

+272
-169
lines changed

ExternData/Resources/C-Sources/libxml2/SAX2.c

+36-30
Original file line numberDiff line numberDiff line change
@@ -404,42 +404,48 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
404404
{
405405
xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
406406
xmlParserInputPtr ret = NULL;
407-
xmlChar *URI;
408-
const xmlChar *base = NULL;
409-
int res;
407+
xmlChar *URI = NULL;
410408

411409
if (ctx == NULL) return(NULL);
412-
if (ctxt->input != NULL)
413-
base = BAD_CAST ctxt->input->filename;
414410

415-
/*
416-
* We don't really need the 'directory' struct member, but some
417-
* users set it manually to a base URI for memory streams.
418-
*/
419-
if (base == NULL)
420-
base = BAD_CAST ctxt->directory;
411+
if (systemId != NULL) {
412+
const xmlChar *base = NULL;
413+
int res;
421414

422-
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
423-
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
424-
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
425-
return(NULL);
426-
}
427-
res = xmlBuildURISafe(systemId, base, &URI);
428-
if (URI == NULL) {
429-
if (res < 0)
430-
xmlSAX2ErrMemory(ctxt);
431-
else
432-
xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
433-
"Can't resolve URI: %s\n", systemId);
434-
return(NULL);
435-
}
436-
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
437-
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
438-
} else {
439-
ret = xmlLoadExternalEntity((const char *) URI,
440-
(const char *) publicId, ctxt);
415+
if (ctxt->input != NULL)
416+
base = BAD_CAST ctxt->input->filename;
417+
418+
/*
419+
* We don't really need the 'directory' struct member, but some
420+
* users set it manually to a base URI for memory streams.
421+
*/
422+
if (base == NULL)
423+
base = BAD_CAST ctxt->directory;
424+
425+
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
426+
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
427+
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
428+
return(NULL);
429+
}
430+
res = xmlBuildURISafe(systemId, base, &URI);
431+
if (URI == NULL) {
432+
if (res < 0)
433+
xmlSAX2ErrMemory(ctxt);
434+
else
435+
xmlWarnMsg(ctxt, XML_ERR_INVALID_URI,
436+
"Can't resolve URI: %s\n", systemId);
437+
return(NULL);
438+
}
439+
if (xmlStrlen(URI) > XML_MAX_URI_LENGTH) {
440+
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
441+
xmlFree(URI);
442+
return(NULL);
443+
}
441444
}
442445

446+
ret = xmlLoadExternalEntity((const char *) URI,
447+
(const char *) publicId, ctxt);
448+
443449
xmlFree(URI);
444450
return(ret);
445451
}

ExternData/Resources/C-Sources/libxml2/dict.c

+22-10
Original file line numberDiff line numberDiff line change
@@ -928,14 +928,15 @@ xmlDictQLookup(xmlDictPtr dict, const xmlChar *prefix, const xmlChar *name) {
928928
#define WIN32_LEAN_AND_MEAN
929929
#include <windows.h>
930930
#include <bcrypt.h>
931-
#elif defined(HAVE_GETENTROPY)
932-
#ifdef HAVE_UNISTD_H
933-
#include <unistd.h>
934-
#endif
935-
#ifdef HAVE_SYS_RANDOM_H
936-
#include <sys/random.h>
937-
#endif
938931
#else
932+
#if defined(HAVE_GETENTROPY)
933+
#ifdef HAVE_UNISTD_H
934+
#include <unistd.h>
935+
#endif
936+
#ifdef HAVE_SYS_RANDOM_H
937+
#include <sys/random.h>
938+
#endif
939+
#endif
939940
#include <time.h>
940941
#endif
941942

@@ -965,9 +966,21 @@ xmlInitRandom(void) {
965966
"error code %lu\n", GetLastError());
966967
abort();
967968
}
968-
#elif defined(HAVE_GETENTROPY)
969+
#else
970+
int var;
971+
972+
#if defined(HAVE_GETENTROPY)
969973
while (1) {
970974
if (getentropy(globalRngState, sizeof(globalRngState)) == 0)
975+
return;
976+
977+
/*
978+
* This most likely means that libxml2 was compiled on
979+
* a system supporting certain system calls and is running
980+
* on a system that doesn't support these calls, as can
981+
* be the case on Linux.
982+
*/
983+
if (errno == ENOSYS)
971984
break;
972985

973986
if (errno != EINTR) {
@@ -976,8 +989,7 @@ xmlInitRandom(void) {
976989
abort();
977990
}
978991
}
979-
#else
980-
int var;
992+
#endif
981993

982994
globalRngState[0] =
983995
(unsigned) time(NULL) ^

ExternData/Resources/C-Sources/libxml2/encoding.c

+14-10
Original file line numberDiff line numberDiff line change
@@ -1264,7 +1264,7 @@ DECLARE_ISO_FUNCS(16)
12641264
#endif /* LIBXML_ISO8859X_ENABLED */
12651265

12661266
#ifdef LIBXML_ICONV_ENABLED
1267-
#define EMPTY_ICONV , (iconv_t) 0, (iconv_t) 0
1267+
#define EMPTY_ICONV , (iconv_t) -1, (iconv_t) -1
12681268
#else
12691269
#define EMPTY_ICONV
12701270
#endif
@@ -1389,8 +1389,8 @@ xmlNewCharEncodingHandler(const char *name,
13891389
handler->name = up;
13901390

13911391
#ifdef LIBXML_ICONV_ENABLED
1392-
handler->iconv_in = NULL;
1393-
handler->iconv_out = NULL;
1392+
handler->iconv_in = (iconv_t) -1;
1393+
handler->iconv_out = (iconv_t) -1;
13941394
#endif
13951395
#ifdef LIBXML_ICU_ENABLED
13961396
handler->uconv_in = NULL;
@@ -1641,6 +1641,10 @@ xmlCreateUconvHandler(const char *name, xmlCharEncodingHandler **out) {
16411641
}
16421642
enc->input = NULL;
16431643
enc->output = NULL;
1644+
#ifdef LIBXML_ICONV_ENABLED
1645+
enc->iconv_in = (iconv_t) -1;
1646+
enc->iconv_out = (iconv_t) -1;
1647+
#endif
16441648
enc->uconv_in = ucv_in;
16451649
enc->uconv_out = ucv_out;
16461650

@@ -2200,7 +2204,7 @@ xmlEncInputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
22002204
}
22012205
}
22022206
#ifdef LIBXML_ICONV_ENABLED
2203-
else if (handler->iconv_in != NULL) {
2207+
else if (handler->iconv_in != (iconv_t) -1) {
22042208
ret = xmlIconvWrapper(handler->iconv_in, out, outlen, in, inlen);
22052209
}
22062210
#endif /* LIBXML_ICONV_ENABLED */
@@ -2260,7 +2264,7 @@ xmlEncOutputChunk(xmlCharEncodingHandler *handler, unsigned char *out,
22602264
}
22612265
}
22622266
#ifdef LIBXML_ICONV_ENABLED
2263-
else if (handler->iconv_out != NULL) {
2267+
else if (handler->iconv_out != (iconv_t) -1) {
22642268
ret = xmlIconvWrapper(handler->iconv_out, out, outlen, in, inlen);
22652269
}
22662270
#endif /* LIBXML_ICONV_ENABLED */
@@ -2672,17 +2676,17 @@ xmlCharEncCloseFunc(xmlCharEncodingHandler *handler) {
26722676
* Iconv handlers can be used only once, free the whole block.
26732677
* and the associated icon resources.
26742678
*/
2675-
if ((handler->iconv_out != NULL) || (handler->iconv_in != NULL)) {
2679+
if ((handler->iconv_out != (iconv_t) -1) || (handler->iconv_in != (iconv_t) -1)) {
26762680
tofree = 1;
2677-
if (handler->iconv_out != NULL) {
2681+
if (handler->iconv_out != (iconv_t) -1) {
26782682
if (iconv_close(handler->iconv_out))
26792683
ret = -1;
2680-
handler->iconv_out = NULL;
2684+
handler->iconv_out = (iconv_t) -1;
26812685
}
2682-
if (handler->iconv_in != NULL) {
2686+
if (handler->iconv_in != (iconv_t) -1) {
26832687
if (iconv_close(handler->iconv_in))
26842688
ret = -1;
2685-
handler->iconv_in = NULL;
2689+
handler->iconv_in = (iconv_t) -1;
26862690
}
26872691
}
26882692
#endif /* LIBXML_ICONV_ENABLED */

ExternData/Resources/C-Sources/libxml2/include/libxml/xmlversion.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -15,21 +15,21 @@
1515
*
1616
* the version string like "1.2.3"
1717
*/
18-
#define LIBXML_DOTTED_VERSION "2.13.5"
18+
#define LIBXML_DOTTED_VERSION "2.13.8"
1919

2020
/**
2121
* LIBXML_VERSION:
2222
*
2323
* the version number: 1.2.3 value is 10203
2424
*/
25-
#define LIBXML_VERSION 21305
25+
#define LIBXML_VERSION 21308
2626

2727
/**
2828
* LIBXML_VERSION_STRING:
2929
*
3030
* the version number string, 1.2.3 value is "10203"
3131
*/
32-
#define LIBXML_VERSION_STRING "21305"
32+
#define LIBXML_VERSION_STRING "21308"
3333

3434
/**
3535
* LIBXML_VERSION_EXTRA:
@@ -44,7 +44,7 @@
4444
* Macro to check that the libxml version in use is compatible with
4545
* the version the software has been compiled against
4646
*/
47-
#define LIBXML_TEST_VERSION xmlCheckVersion(21305);
47+
#define LIBXML_TEST_VERSION xmlCheckVersion(21308);
4848

4949
/**
5050
* LIBXML_THREAD_ENABLED:

ExternData/Resources/C-Sources/libxml2/include/private/io.h

+3
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ XML_HIDDEN xmlParserInputBufferPtr
2424
xmlNewInputBufferMemory(const void *mem, size_t size, int flags,
2525
xmlCharEncoding enc);
2626

27+
XML_HIDDEN int
28+
xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int unzip);
29+
2730
#ifdef LIBXML_OUTPUT_ENABLED
2831
XML_HIDDEN xmlOutputBufferPtr
2932
xmlAllocOutputBufferInternal(xmlCharEncodingHandlerPtr encoder);

ExternData/Resources/C-Sources/libxml2/include/private/parser.h

+4
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ xmlParserNsLookupSax(xmlParserCtxtPtr ctxt, const xmlChar *prefix);
9090

9191
#define XML_INPUT_BUF_STATIC (1u << 1)
9292
#define XML_INPUT_BUF_ZERO_TERMINATED (1u << 2)
93+
#define XML_INPUT_UNZIP (1u << 3)
94+
95+
/* Internal parser option */
96+
#define XML_PARSE_UNZIP (1 << 24)
9397

9498
XML_HIDDEN xmlParserInputPtr
9599
xmlNewInputURL(xmlParserCtxtPtr ctxt, const char *url, const char *publicId,

ExternData/Resources/C-Sources/libxml2/libxml.h

+2-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@
5555
#endif
5656

5757
#ifdef __clang__
58-
#if __clang_major__ >= 12
58+
#if (!defined(__apple_build_version__) && __clang_major__ >= 12) || \
59+
(defined(__apple_build_version__) && __clang_major__ >= 13)
5960
#define ATTRIBUTE_NO_SANITIZE_INTEGER \
6061
ATTRIBUTE_NO_SANITIZE("unsigned-integer-overflow") \
6162
ATTRIBUTE_NO_SANITIZE("unsigned-shift-base")

ExternData/Resources/C-Sources/libxml2/parser.c

+12-3
Original file line numberDiff line numberDiff line change
@@ -7153,7 +7153,11 @@ xmlParseMarkupDecl(xmlParserCtxtPtr ctxt) {
71537153
xmlParseComment(ctxt);
71547154
break;
71557155
default:
7156-
/* there is an error but it will be detected later */
7156+
xmlFatalErr(ctxt,
7157+
ctxt->inSubset == 2 ?
7158+
XML_ERR_EXT_SUBSET_NOT_FINISHED :
7159+
XML_ERR_INT_SUBSET_NOT_FINISHED,
7160+
NULL);
71577161
SKIP(2);
71587162
break;
71597163
}
@@ -13890,7 +13894,8 @@ xmlReadFile(const char *filename, const char *encoding, int options)
1389013894
* should be removed at some point.
1389113895
*/
1389213896
if ((filename != NULL) && (filename[0] == '-') && (filename[1] == 0))
13893-
input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding, 0);
13897+
input = xmlNewInputFd(ctxt, filename, STDIN_FILENO, encoding,
13898+
XML_INPUT_UNZIP);
1389413899
else
1389513900
input = xmlNewInputURL(ctxt, filename, NULL, encoding, 0);
1389613901

@@ -14141,14 +14146,18 @@ xmlCtxtReadFd(xmlParserCtxtPtr ctxt, int fd,
1414114146
const char *URL, const char *encoding, int options)
1414214147
{
1414314148
xmlParserInputPtr input;
14149+
int inputFlags;
1414414150

1414514151
if (ctxt == NULL)
1414614152
return(NULL);
1414714153

1414814154
xmlCtxtReset(ctxt);
1414914155
xmlCtxtUseOptions(ctxt, options);
1415014156

14151-
input = xmlNewInputFd(ctxt, URL, fd, encoding, 0);
14157+
inputFlags = 0;
14158+
if (options & XML_PARSE_UNZIP)
14159+
inputFlags |= XML_INPUT_UNZIP;
14160+
input = xmlNewInputFd(ctxt, URL, fd, encoding, inputFlags);
1415214161

1415314162
return(xmlCtxtParseDocument(ctxt, input));
1415414163
}

ExternData/Resources/C-Sources/libxml2/parserInternals.c

+7-2
Original file line numberDiff line numberDiff line change
@@ -1715,18 +1715,23 @@ xmlNewInputString(xmlParserCtxtPtr ctxt, const char *url,
17151715
*/
17161716
xmlParserInputPtr
17171717
xmlNewInputFd(xmlParserCtxtPtr ctxt, const char *url,
1718-
int fd, const char *encoding, int flags ATTRIBUTE_UNUSED) {
1718+
int fd, const char *encoding, int flags) {
17191719
xmlParserInputBufferPtr buf;
17201720

17211721
if ((ctxt == NULL) || (fd < 0))
17221722
return(NULL);
17231723

1724-
buf = xmlParserInputBufferCreateFd(fd, XML_CHAR_ENCODING_NONE);
1724+
buf = xmlAllocParserInputBuffer(XML_CHAR_ENCODING_NONE);
17251725
if (buf == NULL) {
17261726
xmlCtxtErrMemory(ctxt);
17271727
return(NULL);
17281728
}
17291729

1730+
if (xmlInputFromFd(buf, fd, (flags & XML_INPUT_UNZIP) != 0) < 0) {
1731+
xmlFreeParserInputBuffer(buf);
1732+
return(NULL);
1733+
}
1734+
17301735
return(xmlNewInputInternal(ctxt, buf, url, encoding));
17311736
}
17321737

ExternData/Resources/C-Sources/libxml2/pattern.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1158,10 +1158,10 @@ xmlCompileStepPattern(xmlPatParserContextPtr ctxt) {
11581158
goto error;
11591159
}
11601160
} else {
1161-
PUSH(XML_OP_CHILD, token, URL);
1161+
PUSH(XML_OP_ELEM, token, URL);
11621162
}
11631163
} else
1164-
PUSH(XML_OP_CHILD, name, NULL);
1164+
PUSH(XML_OP_ELEM, name, NULL);
11651165
return;
11661166
} else if (xmlStrEqual(name, (const xmlChar *) "attribute")) {
11671167
XML_PAT_FREE_STRING(ctxt, name)

ExternData/Resources/C-Sources/libxml2/tree.c

+10-4
Original file line numberDiff line numberDiff line change
@@ -5858,15 +5858,21 @@ xmlNodeAddContent(xmlNodePtr cur, const xmlChar *content) {
58585858
* @first: the first text node
58595859
* @second: the second text node being merged
58605860
*
5861-
* Merge the second text node into the first. The second node is
5862-
* unlinked and freed.
5861+
* Merge the second text node into the first. If @first is NULL,
5862+
* @second is returned. Otherwise, the second node is unlinked and
5863+
* freed.
58635864
*
58645865
* Returns the first text node augmented or NULL in case of error.
58655866
*/
58665867
xmlNodePtr
58675868
xmlTextMerge(xmlNodePtr first, xmlNodePtr second) {
5868-
if ((first == NULL) || (first->type != XML_TEXT_NODE) ||
5869-
(second == NULL) || (second->type != XML_TEXT_NODE) ||
5869+
if (first == NULL)
5870+
return(second);
5871+
if (second == NULL)
5872+
return(first);
5873+
5874+
if ((first->type != XML_TEXT_NODE) ||
5875+
(second->type != XML_TEXT_NODE) ||
58705876
(first == second) ||
58715877
(first->name != second->name))
58725878
return(NULL);

0 commit comments

Comments
 (0)
0