Skip to content

Commit 8c6f277

Browse files
sethmlarsonambv
andauthored
[3.8] Upgrade bundled libexpat to 2.6.0 (GH-115399) (GH-115475)
Manual backport due to code differences. (cherry picked from commit e071b0d) Co-authored-by: Łukasz Langa <[email protected]>
1 parent 1e7f79a commit 8c6f277

12 files changed

+402
-262
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update bundled libexpat to 2.6.0

Modules/expat/expat.h

+19-9
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected]>
1212
Copyright (c) 2001-2002 Greg Stein <[email protected]>
1313
Copyright (c) 2002-2016 Karl Waclawek <[email protected]>
14-
Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
14+
Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
1515
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
1616
Copyright (c) 2016 Thomas Beutlich <[email protected]>
1717
Copyright (c) 2017 Rhodri James <[email protected]>
1818
Copyright (c) 2022 Thijs Schreijer <[email protected]>
19+
Copyright (c) 2023 Hanno Böck <[email protected]>
20+
Copyright (c) 2023 Sony Corporation / Snild Dolkow <[email protected]>
1921
Licensed under the MIT license:
2022
2123
Permission is hereby granted, free of charge, to any person obtaining
@@ -269,7 +271,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
269271
const XML_Memory_Handling_Suite *memsuite,
270272
const XML_Char *namespaceSeparator);
271273

272-
/* Prepare a parser object to be re-used. This is particularly
274+
/* Prepare a parser object to be reused. This is particularly
273275
valuable when memory allocation overhead is disproportionately high,
274276
such as when a large number of small documnents need to be parsed.
275277
All handlers are cleared from the parser, except for the
@@ -951,7 +953,7 @@ XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
951953
XMLPARSEAPI(int)
952954
XML_GetCurrentByteCount(XML_Parser parser);
953955

954-
/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
956+
/* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets
955957
the integer pointed to by offset to the offset within this buffer
956958
of the current parse position, and sets the integer pointed to by size
957959
to the size of this buffer (the number of input bytes). Otherwise
@@ -1025,7 +1027,9 @@ enum XML_FeatureEnum {
10251027
XML_FEATURE_ATTR_INFO,
10261028
/* Added in Expat 2.4.0. */
10271029
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
1028-
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
1030+
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT,
1031+
/* Added in Expat 2.6.0. */
1032+
XML_FEATURE_GE
10291033
/* Additional features must be added to the end of this enum. */
10301034
};
10311035

@@ -1038,23 +1042,29 @@ typedef struct {
10381042
XMLPARSEAPI(const XML_Feature *)
10391043
XML_GetFeatureList(void);
10401044

1041-
#ifdef XML_DTD
1042-
/* Added in Expat 2.4.0. */
1045+
#if XML_GE == 1
1046+
/* Added in Expat 2.4.0 for XML_DTD defined and
1047+
* added in Expat 2.6.0 for XML_GE == 1. */
10431048
XMLPARSEAPI(XML_Bool)
10441049
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
10451050
XML_Parser parser, float maximumAmplificationFactor);
10461051

1047-
/* Added in Expat 2.4.0. */
1052+
/* Added in Expat 2.4.0 for XML_DTD defined and
1053+
* added in Expat 2.6.0 for XML_GE == 1. */
10481054
XMLPARSEAPI(XML_Bool)
10491055
XML_SetBillionLaughsAttackProtectionActivationThreshold(
10501056
XML_Parser parser, unsigned long long activationThresholdBytes);
10511057
#endif
10521058

1059+
/* Added in Expat 2.6.0. */
1060+
XMLPARSEAPI(XML_Bool)
1061+
XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
1062+
10531063
/* Expat follows the semantic versioning convention.
1054-
See http://semver.org.
1064+
See https://semver.org
10551065
*/
10561066
#define XML_MAJOR_VERSION 2
1057-
#define XML_MINOR_VERSION 5
1067+
#define XML_MINOR_VERSION 6
10581068
#define XML_MICRO_VERSION 0
10591069

10601070
#ifdef __cplusplus

Modules/expat/expat_config.h

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#define XML_NS 1
1818
#define XML_DTD 1
19+
#define XML_GE 1
1920
#define XML_CONTEXT_BYTES 1024
2021

2122
#endif /* EXPAT_CONFIG_H */

Modules/expat/internal.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,10 @@
2828
Copyright (c) 2002-2003 Fred L. Drake, Jr. <[email protected]>
2929
Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
3030
Copyright (c) 2003 Greg Stein <[email protected]>
31-
Copyright (c) 2016-2022 Sebastian Pipping <[email protected]>
31+
Copyright (c) 2016-2023 Sebastian Pipping <[email protected]>
3232
Copyright (c) 2018 Yury Gribov <[email protected]>
3333
Copyright (c) 2019 David Loffredo <[email protected]>
34+
Copyright (c) 2023 Sony Corporation / Snild Dolkow <[email protected]>
3435
Licensed under the MIT license:
3536
3637
Permission is hereby granted, free of charge, to any person obtaining
@@ -154,12 +155,15 @@ extern "C" {
154155
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
155156
const char **fromLimRef);
156157

157-
#if defined(XML_DTD)
158+
#if XML_GE == 1
158159
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
159160
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
160161
const char *unsignedCharToPrintable(unsigned char c);
161162
#endif
162163

164+
extern XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
165+
extern unsigned int g_parseAttempts; // used for testing only
166+
163167
#ifdef __cplusplus
164168
}
165169
#endif

Modules/expat/siphash.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
* if this code is included and compiled as C++; related GCC warning is:
107107
* warning: use of C++11 long long integer constant [-Wlong-long]
108108
*/
109-
#define _SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
109+
#define SIP_ULL(high, low) ((((uint64_t)high) << 32) | (low))
110110

111111
#define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ((x) >> (64 - (b))))
112112

@@ -190,10 +190,10 @@ sip_round(struct siphash *H, const int rounds) {
190190

191191
static struct siphash *
192192
sip24_init(struct siphash *H, const struct sipkey *key) {
193-
H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
194-
H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
195-
H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
196-
H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
193+
H->v0 = SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0];
194+
H->v1 = SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1];
195+
H->v2 = SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0];
196+
H->v3 = SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1];
197197

198198
H->p = H->buf;
199199
H->c = 0;

Modules/expat/winconfig.h

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
Copyright (c) 2000 Clark Cooper <[email protected]>
1010
Copyright (c) 2002 Greg Stein <[email protected]>
1111
Copyright (c) 2005 Karl Waclawek <[email protected]>
12-
Copyright (c) 2017-2021 Sebastian Pipping <[email protected]>
12+
Copyright (c) 2017-2023 Sebastian Pipping <[email protected]>
13+
Copyright (c) 2023 Orgad Shaneh <[email protected]>
1314
Licensed under the MIT license:
1415
1516
Permission is hereby granted, free of charge, to any person obtaining
@@ -35,7 +36,9 @@
3536
#ifndef WINCONFIG_H
3637
#define WINCONFIG_H
3738

38-
#define WIN32_LEAN_AND_MEAN
39+
#ifndef WIN32_LEAN_AND_MEAN
40+
# define WIN32_LEAN_AND_MEAN
41+
#endif
3942
#include <windows.h>
4043
#undef WIN32_LEAN_AND_MEAN
4144

0 commit comments

Comments
 (0)