Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6b8f442

Browse filesBrowse files
authored
[3.9] gh-126623: Update libexpat to 2.6.4, make future updates easier (GH-126792) (GH-126800)
(cherry picked from commit 3c99969)
1 parent ddca295 commit 6b8f442
Copy full SHA for 6b8f442

File tree

5 files changed

+80
-11
lines changed
Filter options

5 files changed

+80
-11
lines changed
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Upgrade libexpat to 2.6.4

‎Modules/expat/expat.h

Copy file name to clipboardExpand all lines: Modules/expat/expat.h
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ enum XML_Error {
130130
/* Added in 2.3.0. */
131131
XML_ERROR_NO_BUFFER,
132132
/* Added in 2.4.0. */
133-
XML_ERROR_AMPLIFICATION_LIMIT_BREACH
133+
XML_ERROR_AMPLIFICATION_LIMIT_BREACH,
134+
/* Added in 2.6.4. */
135+
XML_ERROR_NOT_STARTED,
134136
};
135137

136138
enum XML_Content_Type {
@@ -1066,7 +1068,7 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
10661068
*/
10671069
#define XML_MAJOR_VERSION 2
10681070
#define XML_MINOR_VERSION 6
1069-
#define XML_MICRO_VERSION 3
1071+
#define XML_MICRO_VERSION 4
10701072

10711073
#ifdef __cplusplus
10721074
}

‎Modules/expat/expat_external.h

Copy file name to clipboardExpand all lines: Modules/expat/expat_external.h
+4-5Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@
4040
#ifndef Expat_External_INCLUDED
4141
#define Expat_External_INCLUDED 1
4242

43+
/* Namespace external symbols to allow multiple libexpat version to
44+
co-exist. */
45+
#include "pyexpatns.h"
46+
4347
/* External API definitions */
4448

4549
/* Expat tries very hard to make the API boundary very specifically
@@ -64,11 +68,6 @@
6468
compiled with the cdecl calling convention as the default since
6569
system headers may assume the cdecl convention.
6670
*/
67-
68-
/* Namespace external symbols to allow multiple libexpat version to
69-
co-exist. */
70-
#include "pyexpatns.h"
71-
7271
#ifndef XMLCALL
7372
# if defined(_MSC_VER)
7473
# define XMLCALL __cdecl

‎Modules/expat/refresh.sh

Copy file name to clipboard
+57Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
#!/usr/bin/env bash
2+
#
3+
# Use this script to update libexpat
4+
5+
set -e
6+
set -o pipefail
7+
8+
if [[ "${BASH_VERSINFO[0]}" -lt 4 ]]; then
9+
echo "A bash version >= 4 required. Got: $BASH_VERSION" >&2
10+
exit 1
11+
fi
12+
13+
# Update this when updating to a new version after verifying that the changes
14+
# the update brings in are good. These values are used for verifying the SBOM, too.
15+
expected_libexpat_tag="R_2_6_4"
16+
expected_libexpat_version="2.6.4"
17+
expected_libexpat_sha256="fd03b7172b3bd7427a3e7a812063f74754f24542429b634e0db6511b53fb2278"
18+
19+
expat_dir="$(realpath "$(dirname -- "${BASH_SOURCE[0]}")")"
20+
cd ${expat_dir}
21+
22+
# Step 1: download and copy files
23+
curl --location "https://github.com/libexpat/libexpat/releases/download/${expected_libexpat_tag}/expat-${expected_libexpat_version}.tar.gz" > libexpat.tar.gz
24+
echo "${expected_libexpat_sha256} libexpat.tar.gz" | sha256sum --check
25+
26+
# Step 2: Pull files from the libexpat distribution
27+
declare -a lib_files
28+
lib_files=(
29+
ascii.h
30+
asciitab.h
31+
expat.h
32+
expat_external.h
33+
iasciitab.h
34+
internal.h
35+
latin1tab.h
36+
nametab.h
37+
siphash.h
38+
utf8tab.h
39+
winconfig.h
40+
xmlparse.c
41+
xmlrole.c
42+
xmlrole.h
43+
xmltok.c
44+
xmltok.h
45+
xmltok_impl.c
46+
xmltok_impl.h
47+
xmltok_ns.c
48+
)
49+
for f in "${lib_files[@]}"; do
50+
tar xzvf libexpat.tar.gz "expat-${expected_libexpat_version}/lib/${f}" --strip-components 2
51+
done
52+
rm libexpat.tar.gz
53+
54+
# Step 3: Add the namespacing include to expat_external.h
55+
sed -i 's/#define Expat_External_INCLUDED 1/&\n\n\/* Namespace external symbols to allow multiple libexpat version to\n co-exist. \*\/\n#include "pyexpatns.h"/' expat_external.h
56+
57+
echo "Updated; verify all is okay using git diff and git status."

‎Modules/expat/xmlparse.c

Copy file name to clipboardExpand all lines: Modules/expat/xmlparse.c
+14-4Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ba4cdf9bdb534f355a9def4c9e25d20ee8e72f95b0a4d930be52e563f5080196 (2.6.3+)
1+
/* c5625880f4bf417c1463deee4eb92d86ff413f802048621c57e25fe483eb59e4 (2.6.4+)
22
__ __ _
33
___\ \/ /_ __ __ _| |_
44
/ _ \\ /| '_ \ / _` | __|
@@ -40,6 +40,7 @@
4040
Copyright (c) 2023 Owain Davies <owaind@bath.edu>
4141
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <snild@sony.com>
4242
Copyright (c) 2024 Berkay Eren Ürün <berkay.ueruen@siemens.com>
43+
Copyright (c) 2024 Hanno Böck <hanno@gentoo.org>
4344
Licensed under the MIT license:
4445
4546
Permission is hereby granted, free of charge, to any person obtaining
@@ -2234,6 +2235,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
22342235
if (parser == NULL)
22352236
return XML_STATUS_ERROR;
22362237
switch (parser->m_parsingStatus.parsing) {
2238+
case XML_INITIALIZED:
2239+
parser->m_errorCode = XML_ERROR_NOT_STARTED;
2240+
return XML_STATUS_ERROR;
22372241
case XML_SUSPENDED:
22382242
if (resumable) {
22392243
parser->m_errorCode = XML_ERROR_SUSPENDED;
@@ -2244,7 +2248,7 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
22442248
case XML_FINISHED:
22452249
parser->m_errorCode = XML_ERROR_FINISHED;
22462250
return XML_STATUS_ERROR;
2247-
default:
2251+
case XML_PARSING:
22482252
if (resumable) {
22492253
#ifdef XML_DTD
22502254
if (parser->m_isParamEntity) {
@@ -2255,6 +2259,9 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) {
22552259
parser->m_parsingStatus.parsing = XML_SUSPENDED;
22562260
} else
22572261
parser->m_parsingStatus.parsing = XML_FINISHED;
2262+
break;
2263+
default:
2264+
assert(0);
22582265
}
22592266
return XML_STATUS_OK;
22602267
}
@@ -2519,6 +2526,9 @@ XML_ErrorString(enum XML_Error code) {
25192526
case XML_ERROR_AMPLIFICATION_LIMIT_BREACH:
25202527
return XML_L(
25212528
"limit on input amplification factor (from DTD and entities) breached");
2529+
/* Added in 2.6.4. */
2530+
case XML_ERROR_NOT_STARTED:
2531+
return XML_L("parser not started");
25222532
}
25232533
return NULL;
25242534
}
@@ -7856,7 +7866,7 @@ accountingReportDiff(XML_Parser rootParser,
78567866
assert(! rootParser->m_parentParser);
78577867

78587868
fprintf(stderr,
7859-
" (+" EXPAT_FMT_PTRDIFF_T("6") " bytes %s|%d, xmlparse.c:%d) %*s\"",
7869+
" (+" EXPAT_FMT_PTRDIFF_T("6") " bytes %s|%u, xmlparse.c:%d) %*s\"",
78607870
bytesMore, (account == XML_ACCOUNT_DIRECT) ? "DIR" : "EXP",
78617871
levelsAwayFromRootParser, source_line, 10, "");
78627872

@@ -7969,7 +7979,7 @@ entityTrackingReportStats(XML_Parser rootParser, ENTITY *entity,
79697979

79707980
fprintf(
79717981
stderr,
7972-
"expat: Entities(%p): Count %9d, depth %2d/%2d %*s%s%s; %s length %d (xmlparse.c:%d)\n",
7982+
"expat: Entities(%p): Count %9u, depth %2u/%2u %*s%s%s; %s length %d (xmlparse.c:%d)\n",
79737983
(void *)rootParser, rootParser->m_entity_stats.countEverOpened,
79747984
rootParser->m_entity_stats.currentDepth,
79757985
rootParser->m_entity_stats.maximumDepthSeen,

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.