Skip to content

Commit

Permalink
Update to 2.13.5
Browse files Browse the repository at this point in the history
  • Loading branch information
kiyolee committed Nov 16, 2024
1 parent 62ae8ef commit 28090f6
Show file tree
Hide file tree
Showing 17 changed files with 188 additions and 28 deletions.
16 changes: 16 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
NEWS file for libxml2

v2.13.5: Nov 12 2024

### Regressions

- xmlIO: Fix reading from non-regular files like pipes (Nick Wellnhofer)
- xmlreader: Fix return value of xmlTextReaderReadString (Nick Wellnhofer)
- parser: Fix loading of parameter entities in external DTDs (Nick Wellnhofer)
- parser: Fix downstream code that swaps DTDs (Nick Wellnhofer)
- parser: Fix detection of duplicate attributes (Nick Wellnhofer)
- string: Fix va_copy fallback (Nick Wellnhofer)

### Bug fixes

- xpath: Fix parsing of non-ASCII names (Nick Wellnhofer)


v2.13.4: Sep 18 2024

### Regressions
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

libxml2 Windows build with Visual Studio.

This version is libxml2-2.13.4.
This version is libxml2-2.13.5.

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

Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion distfiles/download.url
Original file line number Diff line number Diff line change
@@ -1 +1 @@
https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.4.tar.xz
https://download.gnome.org/sources/libxml2/2.13/libxml2-2.13.5.tar.xz
Binary file removed distfiles/libxml2-2.13.4.tar.xz
Binary file not shown.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ f437ed9058e8e5135e47c01e973376ba Copyright
799d00dfaca59a88a1ddcb7e564e6476 HTMLparser.c
24211653eb3b5d6752f5eb91d6ecc3ef HTMLtree.c
dd63184811cb2ff705c3e466364d3773 INSTALL
3b128a9995eb5addcc86f1c5984b2e83 NEWS
7a926a25d2fe5ccd55e217e00ec1cb86 NEWS
5f32c16a4eccf442197b65fa65f3c7b8 README.libxml2.md
7283878f36a935a3c00df077cf45af54 SAX.c
f2edb7da1ddb9093de9841519b68f576 SAX2.c
Expand Down Expand Up @@ -86,7 +86,7 @@ cdbcf52ea11b6ee99454e3b9a3adeaac legacy.c
62f33a8621e3442770fd15a540a7eba0 list.c
040942573dbd47e7188991ab3c9c9a99 nanoftp.c
4c676ca8672af9c242eab69fb9e2056f nanohttp.c
6f4d03099f4c60600f6640aea424356c parser.c
1a9b6424fcc1dd7a5d1d3b8df25894f5 parser.c
47ca05f0faf204f7d1a308cd24a80111 parserInternals.c
fc88d174a7b70de62c609c32ce3f55f8 pattern.c
06b7f056c759cff032979e0075c5b318 relaxng.c
Expand All @@ -101,7 +101,7 @@ c48cacc169fbe69e961ceafbfb92ee71 testModule.c
8efef0b6535d6c069678e9f6750d3742 testdict.c
6a3e7cbf9864c04639a1a8ac0c388ea2 testdso.c
e7f8098f4a9e147624c3cf7d652a70c0 testlimits.c
b6224e455a78abefae0a5a1d128ed789 testparser.c
5c573ad30e2cf82094729769850c4366 testparser.c
71ea68a83739869caba574c1725fba96 testrecurse.c
d746403de87ca28dbb43a4a76e63a3d6 threads.c
1bcb15667ab695cdd2cc8d5b1bc05169 timsort.h
Expand All @@ -112,19 +112,19 @@ ff757d7c377b585c520e7ef78551ed87 valid.c
9ca0965eeabe09b4f8d9a1c6c5d8c3b0 win32/libxml2.rc
98e142c0d1c661f7604934d31f6cc0ec xinclude.c
0a034450d155e35ec8ba99ee2005b695 xlink.c
44b28c907e7824182b409165130cf971 xmlIO.c
38e6fc4ba7ac7f5cfb9ab7b3dbffc517 xmlIO.c
7a41f0136e0179fafba0d6e9a4514d73 xmlcatalog.c
7eeb0736114d53f08e4be4d611e579dd xmllint.c
9a191c58eb3f035c795898caea8e689b xmlmemory.c
9d8d0df11b80a714e97da726359977dc xmlmodule.c
e8fa4ddf7a04cf784396eccbe8381224 xmlreader.c
1f17f7c808f45a7d24233f21a4a087e5 xmlreader.c
fda6796d6766ba055664f2993eca5ed7 xmlregexp.c
d877f026dd7130ed114ef4715be479bf xmlsave.c
7ad15c4a469cee12b90af8115dd76b5e xmlschemas.c
991c4949ca7a25c99a7beff8e7516915 xmlschemastypes.c
82c2b7394f560d8af467b779026d3972 xmlstring.c
b7ff570f5e58afc8fc939282e6707108 xmlstring.c
c9097be7e143f99684f19d937a775144 xmlunicode.c
a8ab2ac1eb6a00dccdae814c1cfcea68 xmlwriter.c
be75156569c7a3cfcca092ed459db66c xpath.c
9bc7467b012af0f01626c8eb38e59eed xmlwriter.c
fa4329f88bf47c174874486f6093a0b5 xpath.c
dcf0c2434204059b5d6f03346dec1004 xpointer.c
8798ea780f20ac559991cf1710c29087 xzlib.c
Binary file added distfiles/libxml2-2.13.5.tar.xz
Binary file not shown.
8 changes: 4 additions & 4 deletions include/libxml/xmlversion.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,21 +15,21 @@
*
* the version string like "1.2.3"
*/
#define LIBXML_DOTTED_VERSION "2.13.4"
#define LIBXML_DOTTED_VERSION "2.13.5"

/**
* LIBXML_VERSION:
*
* the version number: 1.2.3 value is 10203
*/
#define LIBXML_VERSION 21304
#define LIBXML_VERSION 21305

/**
* LIBXML_VERSION_STRING:
*
* the version number string, 1.2.3 value is "10203"
*/
#define LIBXML_VERSION_STRING "21304"
#define LIBXML_VERSION_STRING "21305"

/**
* LIBXML_VERSION_EXTRA:
Expand All @@ -44,7 +44,7 @@
* Macro to check that the libxml version in use is compatible with
* the version the software has been compiled against
*/
#define LIBXML_TEST_VERSION xmlCheckVersion(21304);
#define LIBXML_TEST_VERSION xmlCheckVersion(21305);

/**
* LIBXML_THREAD_ENABLED:
Expand Down
81 changes: 81 additions & 0 deletions parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -8912,6 +8912,35 @@ xmlAttrHashInsert(xmlParserCtxtPtr ctxt, unsigned size, const xmlChar *name,
return(INT_MAX);
}

static int
xmlAttrHashInsertQName(xmlParserCtxtPtr ctxt, unsigned size,
const xmlChar *name, const xmlChar *prefix,
unsigned hashValue, int aindex) {
xmlAttrHashBucket *table = ctxt->attrHash;
xmlAttrHashBucket *bucket;
unsigned hindex;

hindex = hashValue & (size - 1);
bucket = &table[hindex];

while (bucket->index >= 0) {
const xmlChar **atts = &ctxt->atts[bucket->index];

if ((name == atts[0]) && (prefix == atts[1]))
return(bucket->index);

hindex++;
bucket++;
if (hindex >= size) {
hindex = 0;
bucket = table;
}
}

bucket->index = aindex;

return(INT_MAX);
}
/**
* xmlParseStartTag2:
* @ctxt: an XML parser context
Expand Down Expand Up @@ -8960,6 +8989,8 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
int nratts, nbatts, nbdef;
int i, j, nbNs, nbTotalDef, attval, nsIndex, maxAtts;
int alloc = 0;
int numNsErr = 0;
int numDupErr = 0;

if (RAW != '<') return(NULL);
NEXT1;
Expand Down Expand Up @@ -9338,10 +9369,12 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
if (res < INT_MAX) {
if (aprefix == atts[res+1]) {
xmlErrAttributeDup(ctxt, aprefix, attname);
numDupErr += 1;
} else {
xmlNsErr(ctxt, XML_NS_ERR_ATTRIBUTE_REDEFINED,
"Namespaced Attribute %s in '%s' redefined\n",
attname, nsuri, NULL);
numNsErr += 1;
}
}
}
Expand Down Expand Up @@ -9440,6 +9473,43 @@ xmlParseStartTag2(xmlParserCtxtPtr ctxt, const xmlChar **pref,
}
}

/*
* Using a single hash table for nsUri/localName pairs cannot
* detect duplicate QNames reliably. The following example will
* only result in two namespace errors.
*
* <doc xmlns:a="a" xmlns:b="a">
* <elem a:a="" b:a="" b:a=""/>
* </doc>
*
* If we saw more than one namespace error but no duplicate QNames
* were found, we have to scan for duplicate QNames.
*/
if ((numDupErr == 0) && (numNsErr > 1)) {
memset(ctxt->attrHash, -1,
attrHashSize * sizeof(ctxt->attrHash[0]));

for (i = 0, j = 0; j < nratts; i += 5, j++) {
unsigned hashValue, nameHashValue, prefixHashValue;
int res;

aprefix = atts[i+1];
if (aprefix == NULL)
continue;

attname = atts[i];
/* Hash values always have bit 31 set, see dict.c */
nameHashValue = ctxt->attallocs[j] | 0x80000000;
prefixHashValue = xmlDictComputeHash(ctxt->dict, aprefix);

hashValue = xmlDictCombineHash(nameHashValue, prefixHashValue);
res = xmlAttrHashInsertQName(ctxt, attrHashSize, attname,
aprefix, hashValue, i);
if (res < INT_MAX)
xmlErrAttributeDup(ctxt, aprefix, attname);
}
}

/*
* Reconstruct attribute pointers
*/
Expand Down Expand Up @@ -11763,6 +11833,7 @@ xmlIOParseDTD(xmlSAXHandlerPtr sax, xmlParserInputBufferPtr input,
xmlFreeParserInputBuffer(input);
return(NULL);
}
xmlCtxtSetOptions(ctxt, XML_PARSE_DTDLOAD);

/*
* generate a parser input from the I/O handler
Expand Down Expand Up @@ -11852,6 +11923,7 @@ xmlSAXParseDTD(xmlSAXHandlerPtr sax, const xmlChar *ExternalID,
if (ctxt == NULL) {
return(NULL);
}
xmlCtxtSetOptions(ctxt, XML_PARSE_DTDLOAD);

/*
* Canonicalise the system ID
Expand Down Expand Up @@ -12143,6 +12215,15 @@ xmlCtxtParseEntity(xmlParserCtxtPtr ctxt, xmlEntityPtr ent) {

while (list != NULL) {
list->parent = (xmlNodePtr) ent;

/*
* Downstream code like the nginx xslt module can set
* ctxt->myDoc->extSubset to a separate DTD, so the entity
* might have a different or a NULL document.
*/
if (list->doc != ent->doc)
xmlSetTreeDoc(list, ent->doc);

if (list->next == NULL)
ent->last = list;
list = list->next;
Expand Down
54 changes: 54 additions & 0 deletions testparser.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,57 @@ testCFileIO(void) {
return err;
}

#ifdef LIBXML_VALID_ENABLED
static void
testSwitchDtdExtSubset(void *vctxt, const xmlChar *name ATTRIBUTE_UNUSED,
const xmlChar *externalId ATTRIBUTE_UNUSED,
const xmlChar *systemId ATTRIBUTE_UNUSED) {
xmlParserCtxtPtr ctxt = vctxt;

ctxt->myDoc->extSubset = ctxt->_private;
}

static int
testSwitchDtd(void) {
const char dtdContent[] =
"<!ENTITY test '<elem1/><elem2/>'>\n";
const char docContent[] =
"<!DOCTYPE doc SYSTEM 'entities.dtd'>\n"
"<doc>&test;</doc>\n";
xmlParserInputBufferPtr input;
xmlParserCtxtPtr ctxt;
xmlDtdPtr dtd;
xmlDocPtr doc;
xmlEntityPtr ent;
int err = 0;

input = xmlParserInputBufferCreateStatic(dtdContent,
sizeof(dtdContent) - 1,
XML_CHAR_ENCODING_NONE);
dtd = xmlIOParseDTD(NULL, input, XML_CHAR_ENCODING_NONE);

ctxt = xmlNewParserCtxt();
ctxt->_private = dtd;
ctxt->sax->externalSubset = testSwitchDtdExtSubset;
doc = xmlCtxtReadMemory(ctxt, docContent, sizeof(docContent) - 1, NULL,
NULL, XML_PARSE_NOENT | XML_PARSE_DTDLOAD);
xmlFreeParserCtxt(ctxt);

ent = xmlGetDocEntity(doc, BAD_CAST "test");
if (ent->children->doc != NULL) {
fprintf(stderr, "Entity content should have NULL doc\n");
err = 1;
}

/* Free doc before DTD */
doc->extSubset = NULL;
xmlFreeDoc(doc);
xmlFreeDtd(dtd);

return err;
}
#endif /* LIBXML_VALID_ENABLED */

#ifdef LIBXML_SAX1_ENABLED
static int
testBalancedChunk(void) {
Expand Down Expand Up @@ -571,6 +622,9 @@ main(void) {
err |= testUnsupportedEncoding();
err |= testNodeGetContent();
err |= testCFileIO();
#ifdef LIBXML_VALID_ENABLED
err |= testSwitchDtd();
#endif
#ifdef LIBXML_SAX1_ENABLED
err |= testBalancedChunk();
#endif
Expand Down
4 changes: 2 additions & 2 deletions win32/rcVersion.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define LIBXML_MAJOR_VERSION 2
#define LIBXML_MINOR_VERSION 13
#define LIBXML_MICRO_VERSION 4
#define LIBXML_DOTTED_VERSION "2.13.4"
#define LIBXML_MICRO_VERSION 5
#define LIBXML_DOTTED_VERSION "2.13.5"
19 changes: 13 additions & 6 deletions xmlIO.c
Original file line number Diff line number Diff line change
Expand Up @@ -1228,7 +1228,13 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
if (xzStream == NULL) {
close(fd);
} else {
if (__libxml2_xzcompressed(xzStream) > 0) {
/*
* Non-regular files like pipes can't be reopened.
* If a file isn't seekable, we pipe uncompressed
* input through xzlib.
*/
if ((lseek(fd, 0, SEEK_CUR) < 0) ||
(__libxml2_xzcompressed(xzStream) > 0)) {
buf->context = xzStream;
buf->readcallback = xmlXzfileRead;
buf->closecallback = xmlXzfileClose;
Expand All @@ -1255,12 +1261,13 @@ xmlInputDefaultOpen(xmlParserInputBufferPtr buf, const char *filename) {
if (gzStream == NULL) {
close(fd);
} else {
char buff4[4];

if ((gzread(gzStream, buff4, 4) > 0) &&
/*
* Non-regular files like pipes can't be reopened.
* If a file isn't seekable, we pipe uncompressed
* input through zlib.
*/
if ((lseek(fd, 0, SEEK_CUR) < 0) ||
(gzdirect(gzStream) == 0)) {
gzrewind(gzStream);

buf->context = gzStream;
buf->readcallback = xmlGzfileRead;
buf->closecallback = xmlGzfileClose;
Expand Down
5 changes: 3 additions & 2 deletions xmlreader.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
#ifdef __va_copy
#define va_copy(dest, src) __va_copy(dest, src)
#else
#define va_copy(dest, src) memcpy(dest, src, sizeof(va_list))
#define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
#endif
#endif

Expand Down Expand Up @@ -1750,7 +1750,8 @@ xmlTextReaderReadString(xmlTextReaderPtr reader)
case XML_CDATA_SECTION_NODE:
break;
case XML_ELEMENT_NODE:
if (xmlTextReaderDoExpand(reader) == -1)
if ((xmlTextReaderDoExpand(reader) == -1) ||
(node->children == NULL))
return(NULL);
break;
case XML_ATTRIBUTE_NODE:
Expand Down
2 changes: 1 addition & 1 deletion xmlstring.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
#ifdef __va_copy
#define va_copy(dest, src) __va_copy(dest, src)
#else
#define va_copy(dest, src) memcpy(dest, src, sizeof(va_list))
#define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
#endif
#endif

Expand Down
2 changes: 1 addition & 1 deletion xmlwriter.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
#ifdef __va_copy
#define va_copy(dest, src) __va_copy(dest, src)
#else
#define va_copy(dest, src) memcpy(dest, src, sizeof(va_list))
#define va_copy(dest, src) memcpy(&(dest), &(src), sizeof(va_list))
#endif
#endif

Expand Down
Loading

0 comments on commit 28090f6

Please sign in to comment.