Skip to content

Commit 5e54af5

Browse files
committed
Update to libxml2-2.13.2
1 parent 413b26c commit 5e54af5

22 files changed

+483
-138
lines changed

HTMLparser.c

+6
Original file line numberDiff line numberDiff line change
@@ -6185,6 +6185,12 @@ htmlCtxtReset(htmlParserCtxtPtr ctxt)
61856185
ctxt->extSubURI = NULL;
61866186
DICT_FREE(ctxt->extSubSystem);
61876187
ctxt->extSubSystem = NULL;
6188+
6189+
if (ctxt->directory != NULL) {
6190+
xmlFree(ctxt->directory);
6191+
ctxt->directory = NULL;
6192+
}
6193+
61886194
if (ctxt->myDoc != NULL)
61896195
xmlFreeDoc(ctxt->myDoc);
61906196
ctxt->myDoc = NULL;

HTMLtree.c

+7-12
Original file line numberDiff line numberDiff line change
@@ -385,22 +385,17 @@ htmlFindOutputEncoder(const char *encoding) {
385385
xmlCharEncodingHandler *handler = NULL;
386386

387387
if (encoding != NULL) {
388-
xmlCharEncoding enc;
388+
int res;
389389

390-
enc = xmlParseCharEncoding(encoding);
391-
if (enc != XML_CHAR_ENCODING_UTF8) {
392-
xmlOpenCharEncodingHandler(encoding, /* output */ 1, &handler);
393-
if (handler == NULL)
394-
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
395-
}
390+
res = xmlOpenCharEncodingHandler(encoding, /* output */ 1,
391+
&handler);
392+
if (res != XML_ERR_OK)
393+
htmlSaveErr(XML_SAVE_UNKNOWN_ENCODING, NULL, encoding);
396394
} else {
397395
/*
398-
* Fallback to HTML or ASCII when the encoding is unspecified
396+
* Fallback to HTML when the encoding is unspecified
399397
*/
400-
if (handler == NULL)
401-
xmlOpenCharEncodingHandler("HTML", /* output */ 1, &handler);
402-
if (handler == NULL)
403-
xmlOpenCharEncodingHandler("ascii", /* output */ 1, &handler);
398+
xmlOpenCharEncodingHandler("HTML", /* output */ 1, &handler);
404399
}
405400

406401
return(handler);

NEWS

+25-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,24 @@
11
NEWS file for libxml2
22

3+
v2.13.2: Jul 4 2024
4+
5+
### Regressions
6+
7+
- tree: Fix handling of empty strings in xmlNodeParseContent
8+
- valid: Restore ID lookup
9+
- parser: Reenable ctxt->directory
10+
- uri: Handle filesystem paths in xmlBuildRelativeURISafe
11+
- encoding: Make xmlFindCharEncodingHandler return UTF-8 handler
12+
- encoding: Fix encoding lookup with xmlOpenCharEncodingHandler
13+
- include: Define ATTRIBUTE_UNUSED for clang
14+
- uri: Fix xmlBuildURI with NULL base
15+
16+
### Improvements
17+
18+
- uri: Enable Windows paths on Cygwin
19+
- tests: Clarify licence of test/intsubset2.xml
20+
21+
322
v2.13.1: Jun 19 2024
423

524
### Regressions
@@ -57,8 +76,12 @@ to be enabled by passing --with-zlib, --with-lzma or --with-http to
5776
configure. In legacy mode (--with-legacy) these options are enabled
5877
by default as before.
5978

60-
Support for FTP and xpointer() XPath extensions will be removed in
61-
the next release.
79+
Support for FTP will be removed in the next release.
80+
81+
Support for the range and point extensions of the xpointer() scheme
82+
will be removed in the next release. The rest of the XPointer
83+
implementation won't be affected. The xpointer() scheme will behave
84+
like the xpath1() scheme.
6285

6386
Several more legacy symbols were deprecated. Users of the old "SAX1"
6487
API functions are encouraged to upgrade to the new "SAX2" API,

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
libxml2 Windows build with Visual Studio.
44

5-
This version is libxml2-2.13.1.
5+
This version is libxml2-2.13.2.
66

77
Note that LZMA support is only available for VS2013 or later.
88

SAX2.c

+16
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,13 @@ xmlSAX2ResolveEntity(void *ctx, const xmlChar *publicId, const xmlChar *systemId
412412
if (ctxt->input != NULL)
413413
base = BAD_CAST ctxt->input->filename;
414414

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;
421+
415422
if ((xmlStrlen(systemId) > XML_MAX_URI_LENGTH) ||
416423
(xmlStrlen(base) > XML_MAX_URI_LENGTH)) {
417424
xmlFatalErr(ctxt, XML_ERR_RESOURCE_LIMIT, "URI too long");
@@ -574,6 +581,13 @@ xmlSAX2EntityDecl(void *ctx, const xmlChar *name, int type,
574581
}
575582
}
576583

584+
/*
585+
* We don't really need the 'directory' struct member, but some
586+
* users set it manually to a base URI for memory streams.
587+
*/
588+
if (base == NULL)
589+
base = ctxt->directory;
590+
577591
res = xmlBuildURISafe(systemId, (const xmlChar *) base, &URI);
578592

579593
if (URI == NULL) {
@@ -1255,6 +1269,7 @@ xmlSAX2AttributeInternal(void *ctx, const xmlChar *fullname,
12551269
} else
12561270
#endif /* LIBXML_VALID_ENABLED */
12571271
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
1272+
(ctxt->input->entity == NULL) &&
12581273
/* Don't create IDs containing entity references */
12591274
(ret->children != NULL) &&
12601275
(ret->children->type == XML_TEXT_NODE) &&
@@ -1987,6 +2002,7 @@ xmlSAX2AttributeNs(xmlParserCtxtPtr ctxt,
19872002
} else
19882003
#endif /* LIBXML_VALID_ENABLED */
19892004
if (((ctxt->loadsubset & XML_SKIP_IDS) == 0) &&
2005+
(ctxt->input->entity == NULL) &&
19902006
/* Don't create IDs containing entity references */
19912007
(ret->children != NULL) &&
19922008
(ret->children->type == XML_TEXT_NODE) &&
File renamed without changes.

distfiles/download.url

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.1.tar.xz
1+
https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.2.tar.xz

distfiles/libxml2-2.13.1.tar.xz

-2.46 MB
Binary file not shown.
File renamed without changes.

distfiles/libxml2-2.13.1-import.md5 distfiles/libxml2-2.13.2-import.md5

+13-13
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
f437ed9058e8e5135e47c01e973376ba Copyright
2-
81f2881accbc601275df1d0f2885c135 HTMLparser.c
3-
d04a2b2879cb84c5c3a195c2d444b335 HTMLtree.c
2+
799d00dfaca59a88a1ddcb7e564e6476 HTMLparser.c
3+
24211653eb3b5d6752f5eb91d6ecc3ef HTMLtree.c
44
dd63184811cb2ff705c3e466364d3773 INSTALL
5-
f3e85e6ed1d3dee747ccefcb42be5718 NEWS
5+
fe33b193822d5fb2d92b436f2547d765 NEWS
66
5f32c16a4eccf442197b65fa65f3c7b8 README.libxml2.md
77
7283878f36a935a3c00df077cf45af54 SAX.c
8-
4bb688a8949366334e6803484a0db05b SAX2.c
8+
f2edb7da1ddb9093de9841519b68f576 SAX2.c
99
67a65054d57590e61fdb1e70d2ea5a96 buf.c
1010
4b44ee7f5a69c1058b5e78cecd37a15c c14n.c
1111
b86dee5a15a23fcae795b2fb2544b8dc catalog.c
1212
691708e81dee605336b6ef6e431c5c21 chvalid.c
1313
697a63537714f6d73508f642b8caf24b debugXML.c
1414
08d37f8cc00ce8576a00dd2c2725ffe3 dict.c
15-
c9a558a311456f1df0ce4da7fec493ca encoding.c
15+
0beb3fd21633ebd2718add8a219d65c3 encoding.c
1616
74aea6c1f67db19f14a4ea658caabb50 entities.c
1717
1614814772ec00261f6c68dbb3fb2e87 error.c
1818
4a0ab9ada11a64828012376799576cfa globals.c
@@ -48,7 +48,7 @@ f56a2156246c1eabc080d8c2f27d48b6 include/libxml/xinclude.h
4848
59b6841396e332b38f075694ac2db47d include/libxml/xmlIO.h
4949
78602d66c5db00b0deece2c56ab86d43 include/libxml/xmlautomata.h
5050
04fa9aa45df384fe962db1a14fb59553 include/libxml/xmlerror.h
51-
dfd4234e18f823082d3d301f25cce375 include/libxml/xmlexports.h
51+
0ea11c4b60a6584f081053fcad323f4a include/libxml/xmlexports.h
5252
13b117b714ad87f0fb17d302d9580cf3 include/libxml/xmlmemory.h
5353
1dda0f8301c72cab8c0015a4f36d008f include/libxml/xmlmodule.h
5454
288e26a1a1b1e495a463ff90b7d243d7 include/libxml/xmlreader.h
@@ -86,8 +86,8 @@ cdbcf52ea11b6ee99454e3b9a3adeaac legacy.c
8686
62f33a8621e3442770fd15a540a7eba0 list.c
8787
040942573dbd47e7188991ab3c9c9a99 nanoftp.c
8888
4c676ca8672af9c242eab69fb9e2056f nanohttp.c
89-
776c4676d1903df60d19cd9c11e08ac4 parser.c
90-
f32e0c097c781ddc57b268169f83a320 parserInternals.c
89+
53c1f20bdbb724031dadb506e6683ff2 parser.c
90+
7a70d4383a870b265ca14cd498b37c85 parserInternals.c
9191
fc88d174a7b70de62c609c32ce3f55f8 pattern.c
9292
06b7f056c759cff032979e0075c5b318 relaxng.c
9393
371edae07b81c37668065294e77dedcd runsuite.c
@@ -101,13 +101,13 @@ c48cacc169fbe69e961ceafbfb92ee71 testModule.c
101101
8efef0b6535d6c069678e9f6750d3742 testdict.c
102102
6a3e7cbf9864c04639a1a8ac0c388ea2 testdso.c
103103
e7f8098f4a9e147624c3cf7d652a70c0 testlimits.c
104-
ac0599e08f02704f5d7db1e36134248f testparser.c
104+
6010c3c335e3369385618d022aade84a testparser.c
105105
71ea68a83739869caba574c1725fba96 testrecurse.c
106106
d746403de87ca28dbb43a4a76e63a3d6 threads.c
107107
1bcb15667ab695cdd2cc8d5b1bc05169 timsort.h
108-
d94e4d3aee44c5a9c504f4b06e073e4e tree.c
109-
7be25cd62649ec06302c67a0dbdcccc7 uri.c
110-
e1828d328a36cd0eea27256123122946 valid.c
108+
37417e0db954291ae7078a946456aa53 tree.c
109+
f8bea8ace4ec3a2d89543da6b91ab630 uri.c
110+
46d56681c3541150ee29b33f77e76bb8 valid.c
111111
8ab2045fb3bb5553449a93c85ebbb58a win32/config.h
112112
9ca0965eeabe09b4f8d9a1c6c5d8c3b0 win32/libxml2.rc
113113
a9b815153157403c75b2c9abf687e97e xinclude.c
@@ -119,7 +119,7 @@ a9b815153157403c75b2c9abf687e97e xinclude.c
119119
9d8d0df11b80a714e97da726359977dc xmlmodule.c
120120
adb85e00bf69885fdddf7fd16f5baf0e xmlreader.c
121121
fda6796d6766ba055664f2993eca5ed7 xmlregexp.c
122-
35a26cd93568987405da54e9279d1359 xmlsave.c
122+
d877f026dd7130ed114ef4715be479bf xmlsave.c
123123
7ad15c4a469cee12b90af8115dd76b5e xmlschemas.c
124124
991c4949ca7a25c99a7beff8e7516915 xmlschemastypes.c
125125
82c2b7394f560d8af467b779026d3972 xmlstring.c

distfiles/libxml2-2.13.2.tar.xz

2.46 MB
Binary file not shown.

encoding.c

+27-7
Original file line numberDiff line numberDiff line change
@@ -1279,9 +1279,8 @@ DECLARE_ISO_FUNCS(16)
12791279
{ (char *) name, in, out EMPTY_ICONV EMPTY_UCONV }
12801280

12811281
static const xmlCharEncodingHandler defaultHandlers[] = {
1282-
MAKE_HANDLER("UTF-8", UTF8ToUTF8, UTF8ToUTF8)
12831282
#ifdef LIBXML_OUTPUT_ENABLED
1284-
,MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE)
1283+
MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, UTF8ToUTF16LE)
12851284
,MAKE_HANDLER("UTF-16BE", UTF16BEToUTF8, UTF8ToUTF16BE)
12861285
,MAKE_HANDLER("UTF-16", UTF16LEToUTF8, UTF8ToUTF16)
12871286
,MAKE_HANDLER("ISO-8859-1", isolat1ToUTF8, UTF8Toisolat1)
@@ -1291,7 +1290,7 @@ static const xmlCharEncodingHandler defaultHandlers[] = {
12911290
,MAKE_HANDLER("HTML", NULL, UTF8ToHtml)
12921291
#endif
12931292
#else
1294-
,MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, NULL)
1293+
MAKE_HANDLER("UTF-16LE", UTF16LEToUTF8, NULL)
12951294
,MAKE_HANDLER("UTF-16BE", UTF16BEToUTF8, NULL)
12961295
,MAKE_HANDLER("UTF-16", UTF16LEToUTF8, NULL)
12971296
,MAKE_HANDLER("ISO-8859-1", isolat1ToUTF8, NULL)
@@ -1321,10 +1320,13 @@ static const xmlCharEncodingHandler defaultHandlers[] = {
13211320
#define NUM_DEFAULT_HANDLERS \
13221321
(sizeof(defaultHandlers) / sizeof(defaultHandlers[0]))
13231322

1324-
static const xmlCharEncodingHandler *xmlUTF16LEHandler = &defaultHandlers[1];
1325-
static const xmlCharEncodingHandler *xmlUTF16BEHandler = &defaultHandlers[2];
1326-
static const xmlCharEncodingHandler *xmlLatin1Handler = &defaultHandlers[4];
1327-
static const xmlCharEncodingHandler *xmlAsciiHandler = &defaultHandlers[5];
1323+
static const xmlCharEncodingHandler xmlUTF8Handler =
1324+
MAKE_HANDLER("UTF-8", UTF8ToUTF8, UTF8ToUTF8);
1325+
1326+
static const xmlCharEncodingHandler *xmlUTF16LEHandler = &defaultHandlers[0];
1327+
static const xmlCharEncodingHandler *xmlUTF16BEHandler = &defaultHandlers[1];
1328+
static const xmlCharEncodingHandler *xmlLatin1Handler = &defaultHandlers[3];
1329+
static const xmlCharEncodingHandler *xmlAsciiHandler = &defaultHandlers[4];
13281330

13291331
/* the size should be growable, but it's not a big deal ... */
13301332
#define MAX_ENCODING_HANDLERS 50
@@ -1922,6 +1924,9 @@ xmlGetCharEncodingHandler(xmlCharEncoding enc) {
19221924
*
19231925
* The handler must be closed with xmlCharEncCloseFunc.
19241926
*
1927+
* If the encoding is UTF-8, a NULL handler and no error code will
1928+
* be returned.
1929+
*
19251930
* Available since 2.13.0.
19261931
*
19271932
* Returns an xmlParserErrors error code.
@@ -1941,6 +1946,10 @@ xmlOpenCharEncodingHandler(const char *name, int output,
19411946
if (name == NULL)
19421947
return(XML_ERR_ARGUMENT);
19431948

1949+
if ((xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF-8") == 0) ||
1950+
(xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF8") == 0))
1951+
return(XML_ERR_OK);
1952+
19441953
/*
19451954
* Do the alias resolution
19461955
*/
@@ -1957,6 +1966,9 @@ xmlOpenCharEncodingHandler(const char *name, int output,
19571966

19581967
/*
19591968
* Fallback using the canonical names
1969+
*
1970+
* TODO: We should make sure that the name of the returned
1971+
* handler equals norig.
19601972
*/
19611973
enc = xmlParseCharEncoding(norig);
19621974
return(xmlLookupCharEncodingHandler(enc, out));
@@ -1976,6 +1988,14 @@ xmlCharEncodingHandlerPtr
19761988
xmlFindCharEncodingHandler(const char *name) {
19771989
xmlCharEncodingHandler *ret;
19781990

1991+
/*
1992+
* This handler shouldn't be used, but we must return a non-NULL
1993+
* handler.
1994+
*/
1995+
if ((xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF-8") == 0) ||
1996+
(xmlStrcasecmp(BAD_CAST name, BAD_CAST "UTF8") == 0))
1997+
return((xmlCharEncodingHandlerPtr) &xmlUTF8Handler);
1998+
19791999
xmlOpenCharEncodingHandler(name, 0, &ret);
19802000
return(ret);
19812001
}

include/libxml/xmlexports.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
*/
4343

4444
#ifndef ATTRIBUTE_UNUSED
45-
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 207
45+
#if __GNUC__ * 100 + __GNUC_MINOR__ >= 207 || defined(__clang__)
4646
#define ATTRIBUTE_UNUSED __attribute__((unused))
4747
#else
4848
#define ATTRIBUTE_UNUSED

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.1"
18+
#define LIBXML_DOTTED_VERSION "2.13.2"
1919

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

2727
/**
2828
* LIBXML_VERSION_STRING:
2929
*
3030
* the version number string, 1.2.3 value is "10203"
3131
*/
32-
#define LIBXML_VERSION_STRING "21301"
32+
#define LIBXML_VERSION_STRING "21302"
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(21301);
47+
#define LIBXML_TEST_VERSION xmlCheckVersion(21302);
4848

4949
/**
5050
* LIBXML_THREAD_ENABLED:

parser.c

+25-1
Original file line numberDiff line numberDiff line change
@@ -1940,8 +1940,11 @@ xmlCtxtGrowAttrs(xmlParserCtxtPtr ctxt, int nr) {
19401940
int
19411941
inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
19421942
{
1943+
char *directory = NULL;
1944+
19431945
if ((ctxt == NULL) || (value == NULL))
19441946
return(-1);
1947+
19451948
if (ctxt->inputNr >= ctxt->inputMax) {
19461949
size_t newSize = ctxt->inputMax * 2;
19471950
xmlParserInputPtr *tmp;
@@ -1955,9 +1958,24 @@ inputPush(xmlParserCtxtPtr ctxt, xmlParserInputPtr value)
19551958
ctxt->inputTab = tmp;
19561959
ctxt->inputMax = newSize;
19571960
}
1961+
1962+
if ((ctxt->inputNr == 0) && (value->filename != NULL)) {
1963+
directory = xmlParserGetDirectory(value->filename);
1964+
if (directory == NULL) {
1965+
xmlErrMemory(ctxt);
1966+
return(-1);
1967+
}
1968+
}
1969+
19581970
ctxt->inputTab[ctxt->inputNr] = value;
19591971
ctxt->input = value;
1960-
return (ctxt->inputNr++);
1972+
1973+
if (ctxt->inputNr == 0) {
1974+
xmlFree(ctxt->directory);
1975+
ctxt->directory = directory;
1976+
}
1977+
1978+
return(ctxt->inputNr++);
19611979
}
19621980
/**
19631981
* inputPop:
@@ -13269,6 +13287,12 @@ xmlCtxtReset(xmlParserCtxtPtr ctxt)
1326913287
ctxt->extSubURI = NULL;
1327013288
DICT_FREE(ctxt->extSubSystem);
1327113289
ctxt->extSubSystem = NULL;
13290+
13291+
if (ctxt->directory != NULL) {
13292+
xmlFree(ctxt->directory);
13293+
ctxt->directory = NULL;
13294+
}
13295+
1327213296
if (ctxt->myDoc != NULL)
1327313297
xmlFreeDoc(ctxt->myDoc);
1327413298
ctxt->myDoc = NULL;

parserInternals.c

+1
Original file line numberDiff line numberDiff line change
@@ -2469,6 +2469,7 @@ xmlFreeParserCtxt(xmlParserCtxtPtr ctxt)
24692469
if (ctxt->sax != NULL)
24702470
#endif /* LIBXML_SAX1_ENABLED */
24712471
xmlFree(ctxt->sax);
2472+
if (ctxt->directory != NULL) xmlFree(ctxt->directory);
24722473
if (ctxt->vctxt.nodeTab != NULL) xmlFree(ctxt->vctxt.nodeTab);
24732474
if (ctxt->atts != NULL) xmlFree((xmlChar * *)ctxt->atts);
24742475
if (ctxt->dict != NULL) xmlDictFree(ctxt->dict);

0 commit comments

Comments
 (0)