Skip to content

Commit 6ad96ea

Browse files
authored
Merge pull request #66 from ActiveState/BE-4504-python-2-7-expat-update-IIII
Be 4504 python 2 7 expat update iiii
2 parents 3e06fbb + 1e74097 commit 6ad96ea

23 files changed

+2346
-519
lines changed

Modules/expat/COPYING

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper
2-
Copyright (c) 2001-2017 Expat maintainers
2+
Copyright (c) 2001-2022 Expat maintainers
33

44
Permission is hereby granted, free of charge, to any person obtaining
55
a copy of this software and associated documentation files (the

Modules/expat/ascii.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
\___/_/\_\ .__/ \__,_|\__|
77
|_| XML parser
88
9-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
9+
Copyright (c) 1999-2000 Thai Open Source Software Center Ltd
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2007 Karl Waclawek <[email protected]>
13+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1114
Licensed under the MIT license:
1215
1316
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/asciitab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/expat.h

Lines changed: 68 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,18 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2001-2002 Greg Stein <[email protected]>
13+
Copyright (c) 2002-2016 Karl Waclawek <[email protected]>
14+
Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
15+
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
16+
Copyright (c) 2016 Thomas Beutlich <[email protected]>
17+
Copyright (c) 2017 Rhodri James <[email protected]>
18+
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]>
21+
Copyright (c) 2024 Taichi Haradaguchi <[email protected]>
1122
Licensed under the MIT license:
1223
1324
Permission is hereby granted, free of charge, to any person obtaining
@@ -115,7 +126,13 @@ enum XML_Error {
115126
XML_ERROR_RESERVED_PREFIX_XMLNS,
116127
XML_ERROR_RESERVED_NAMESPACE_URI,
117128
/* Added in 2.2.1. */
118-
XML_ERROR_INVALID_ARGUMENT
129+
XML_ERROR_INVALID_ARGUMENT,
130+
/* Added in 2.3.0. */
131+
XML_ERROR_NO_BUFFER,
132+
/* Added in 2.4.0. */
133+
XML_ERROR_AMPLIFICATION_LIMIT_BREACH,
134+
/* Added in 2.6.4. */
135+
XML_ERROR_NOT_STARTED,
119136
};
120137

121138
enum XML_Content_Type {
@@ -163,8 +180,10 @@ struct XML_cp {
163180
};
164181

165182
/* This is called for an element declaration. See above for
166-
description of the model argument. It's the caller's responsibility
167-
to free model when finished with it.
183+
description of the model argument. It's the user code's responsibility
184+
to free model when finished with it. See XML_FreeContentModel.
185+
There is no need to free the model from the handler, it can be kept
186+
around and freed at a later stage.
168187
*/
169188
typedef void(XMLCALL *XML_ElementDeclHandler)(void *userData,
170189
const XML_Char *name,
@@ -226,6 +245,17 @@ XML_ParserCreate(const XML_Char *encoding);
226245
and the local part will be concatenated without any separator.
227246
It is a programming error to use the separator '\0' with namespace
228247
triplets (see XML_SetReturnNSTriplet).
248+
If a namespace separator is chosen that can be part of a URI or
249+
part of an XML name, splitting an expanded name back into its
250+
1, 2 or 3 original parts on application level in the element handler
251+
may end up vulnerable, so these are advised against; sane choices for
252+
a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
253+
254+
Note that Expat does not validate namespace URIs (beyond encoding)
255+
against RFC 3986 today (and is not required to do so with regard to
256+
the XML 1.0 namespaces specification) but it may start doing that
257+
in future releases. Before that, an application using Expat must
258+
be ready to receive namespace URIs containing non-URI characters.
229259
*/
230260
XMLPARSEAPI(XML_Parser)
231261
XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
@@ -244,7 +274,7 @@ XML_ParserCreate_MM(const XML_Char *encoding,
244274
const XML_Memory_Handling_Suite *memsuite,
245275
const XML_Char *namespaceSeparator);
246276

247-
/* Prepare a parser object to be re-used. This is particularly
277+
/* Prepare a parser object to be reused. This is particularly
248278
valuable when memory allocation overhead is disproportionately high,
249279
such as when a large number of small documnents need to be parsed.
250280
All handlers are cleared from the parser, except for the
@@ -306,7 +336,7 @@ typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
306336
const XML_Char *pubid,
307337
int has_internal_subset);
308338

309-
/* This is called for the start of the DOCTYPE declaration when the
339+
/* This is called for the end of the DOCTYPE declaration when the
310340
closing > is encountered, but after processing any external
311341
subset.
312342
*/
@@ -318,7 +348,7 @@ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
318348
319349
For internal entities (<!ENTITY foo "bar">), value will
320350
be non-NULL and systemId, publicID, and notationName will be NULL.
321-
The value string is NOT nul-terminated; the length is provided in
351+
The value string is NOT null-terminated; the length is provided in
322352
the value_length argument. Since it is legal to have zero-length
323353
values, do not use this argument to test for internal entities.
324354
@@ -513,7 +543,7 @@ typedef struct {
513543
Otherwise it must return XML_STATUS_ERROR.
514544
515545
If info does not describe a suitable encoding, then the parser will
516-
return an XML_UNKNOWN_ENCODING error.
546+
return an XML_ERROR_UNKNOWN_ENCODING error.
517547
*/
518548
typedef int(XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
519549
const XML_Char *name,
@@ -707,7 +737,7 @@ XML_GetBase(XML_Parser parser);
707737
/* Returns the number of the attribute/value pairs passed in last call
708738
to the XML_StartElementHandler that were specified in the start-tag
709739
rather than defaulted. Each attribute/value pair counts as 2; thus
710-
this correspondds to an index into the atts array passed to the
740+
this corresponds to an index into the atts array passed to the
711741
XML_StartElementHandler. Returns -1 if parser == NULL.
712742
*/
713743
XMLPARSEAPI(int)
@@ -716,7 +746,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
716746
/* Returns the index of the ID attribute passed in the last call to
717747
XML_StartElementHandler, or -1 if there is no ID attribute or
718748
parser == NULL. Each attribute/value pair counts as 2; thus this
719-
correspondds to an index into the atts array passed to the
749+
corresponds to an index into the atts array passed to the
720750
XML_StartElementHandler.
721751
*/
722752
XMLPARSEAPI(int)
@@ -926,7 +956,7 @@ XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
926956
XMLPARSEAPI(int)
927957
XML_GetCurrentByteCount(XML_Parser parser);
928958

929-
/* If XML_CONTEXT_BYTES is defined, returns the input buffer, sets
959+
/* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets
930960
the integer pointed to by offset to the offset within this buffer
931961
of the current parse position, and sets the integer pointed to by size
932962
to the size of this buffer (the number of input bytes). Otherwise
@@ -997,7 +1027,12 @@ enum XML_FeatureEnum {
9971027
XML_FEATURE_SIZEOF_XML_LCHAR,
9981028
XML_FEATURE_NS,
9991029
XML_FEATURE_LARGE_SIZE,
1000-
XML_FEATURE_ATTR_INFO
1030+
XML_FEATURE_ATTR_INFO,
1031+
/* Added in Expat 2.4.0. */
1032+
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
1033+
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT,
1034+
/* Added in Expat 2.6.0. */
1035+
XML_FEATURE_GE
10011036
/* Additional features must be added to the end of this enum. */
10021037
};
10031038

@@ -1010,12 +1045,30 @@ typedef struct {
10101045
XMLPARSEAPI(const XML_Feature *)
10111046
XML_GetFeatureList(void);
10121047

1048+
#if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
1049+
/* Added in Expat 2.4.0 for XML_DTD defined and
1050+
* added in Expat 2.6.0 for XML_GE == 1. */
1051+
XMLPARSEAPI(XML_Bool)
1052+
XML_SetBillionLaughsAttackProtectionMaximumAmplification(
1053+
XML_Parser parser, float maximumAmplificationFactor);
1054+
1055+
/* Added in Expat 2.4.0 for XML_DTD defined and
1056+
* added in Expat 2.6.0 for XML_GE == 1. */
1057+
XMLPARSEAPI(XML_Bool)
1058+
XML_SetBillionLaughsAttackProtectionActivationThreshold(
1059+
XML_Parser parser, unsigned long long activationThresholdBytes);
1060+
#endif
1061+
1062+
/* Added in Expat 2.6.0. */
1063+
XMLPARSEAPI(XML_Bool)
1064+
XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
1065+
10131066
/* Expat follows the semantic versioning convention.
1014-
See http://semver.org.
1067+
See https://semver.org
10151068
*/
10161069
#define XML_MAJOR_VERSION 2
1017-
#define XML_MINOR_VERSION 2
1018-
#define XML_MICRO_VERSION 8
1070+
#define XML_MINOR_VERSION 6
1071+
#define XML_MICRO_VERSION 4
10191072

10201073
#ifdef __cplusplus
10211074
}

Modules/expat/expat_config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
#define XML_NS 1
1616
#define XML_DTD 1
17+
#define XML_GE 1
1718
#define XML_CONTEXT_BYTES 1024
1819

1920
#endif /* EXPAT_CONFIG_H */

Modules/expat/expat_external.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2000-2004 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2001-2002 Greg Stein <[email protected]>
13+
Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
14+
Copyright (c) 2016 Cristian Rodríguez <[email protected]>
15+
Copyright (c) 2016-2019 Sebastian Pipping <[email protected]>
16+
Copyright (c) 2017 Rhodri James <[email protected]>
17+
Copyright (c) 2018 Yury Gribov <[email protected]>
1118
Licensed under the MIT license:
1219
1320
Permission is hereby granted, free of charge, to any person obtaining
@@ -57,11 +64,6 @@
5764
compiled with the cdecl calling convention as the default since
5865
system headers may assume the cdecl convention.
5966
*/
60-
61-
/* Namespace external symbols to allow multiple libexpat version to
62-
co-exist. */
63-
#include "pyexpatns.h"
64-
6567
#ifndef XMLCALL
6668
# if defined(_MSC_VER)
6769
# define XMLCALL __cdecl

Modules/expat/iasciitab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/internal.h

Lines changed: 62 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,14 @@
2525
\___/_/\_\ .__/ \__,_|\__|
2626
|_| XML parser
2727
28-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
29-
Copyright (c) 2000-2017 Expat development team
28+
Copyright (c) 2002-2003 Fred L. Drake, Jr. <[email protected]>
29+
Copyright (c) 2002-2006 Karl Waclawek <[email protected]>
30+
Copyright (c) 2003 Greg Stein <[email protected]>
31+
Copyright (c) 2016-2024 Sebastian Pipping <[email protected]>
32+
Copyright (c) 2018 Yury Gribov <[email protected]>
33+
Copyright (c) 2019 David Loffredo <[email protected]>
34+
Copyright (c) 2023-2024 Sony Corporation / Snild Dolkow <[email protected]>
35+
Copyright (c) 2024 Taichi Haradaguchi <[email protected]>
3036
Licensed under the MIT license:
3137
3238
Permission is hereby granted, free of charge, to any person obtaining
@@ -101,22 +107,69 @@
101107
# endif
102108
#endif
103109

110+
#include <limits.h> // ULONG_MAX
111+
112+
#if defined(_WIN32) \
113+
&& (! defined(__USE_MINGW_ANSI_STDIO) \
114+
|| (1 - __USE_MINGW_ANSI_STDIO - 1 == 0))
115+
# define EXPAT_FMT_ULL(midpart) "%" midpart "I64u"
116+
# if defined(_WIN64) // Note: modifiers "td" and "zu" do not work for MinGW
117+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "I64d"
118+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "I64u"
119+
# else
120+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
121+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
122+
# endif
123+
#else
124+
# define EXPAT_FMT_ULL(midpart) "%" midpart "llu"
125+
# if ! defined(ULONG_MAX)
126+
# error Compiler did not define ULONG_MAX for us
127+
# elif ULONG_MAX == 18446744073709551615u // 2^64-1
128+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "ld"
129+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "lu"
130+
# else
131+
# define EXPAT_FMT_PTRDIFF_T(midpart) "%" midpart "d"
132+
# define EXPAT_FMT_SIZE_T(midpart) "%" midpart "u"
133+
# endif
134+
#endif
135+
104136
#ifndef UNUSED_P
105137
# define UNUSED_P(p) (void)p
106138
#endif
107139

140+
/* NOTE BEGIN If you ever patch these defaults to greater values
141+
for non-attack XML payload in your environment,
142+
please file a bug report with libexpat. Thank you!
143+
*/
144+
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT \
145+
100.0f
146+
#define EXPAT_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT \
147+
8388608 // 8 MiB, 2^23
148+
/* NOTE END */
149+
150+
#include "expat.h" // so we can use type XML_Parser below
151+
108152
#ifdef __cplusplus
109153
extern "C" {
110154
#endif
111155

112-
#ifdef XML_ENABLE_VISIBILITY
113-
# if XML_ENABLE_VISIBILITY
114-
__attribute__((visibility("default")))
115-
# endif
156+
void _INTERNAL_trim_to_complete_utf8_characters(const char *from,
157+
const char **fromLimRef);
158+
159+
#if defined(XML_GE) && XML_GE == 1
160+
unsigned long long testingAccountingGetCountBytesDirect(XML_Parser parser);
161+
unsigned long long testingAccountingGetCountBytesIndirect(XML_Parser parser);
162+
const char *unsignedCharToPrintable(unsigned char c);
163+
#endif
164+
165+
extern
166+
#if ! defined(XML_TESTING)
167+
const
168+
#endif
169+
XML_Bool g_reparseDeferralEnabledDefault; // written ONLY in runtests.c
170+
#if defined(XML_TESTING)
171+
extern unsigned int g_bytesScanned; // used for testing only
116172
#endif
117-
void
118-
_INTERNAL_trim_to_complete_utf8_characters(const char *from,
119-
const char **fromLimRef);
120173

121174
#ifdef __cplusplus
122175
}

Modules/expat/latin1tab.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
|_| XML parser
88
99
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
10+
Copyright (c) 2000 Clark Cooper <[email protected]>
11+
Copyright (c) 2002 Fred L. Drake, Jr. <[email protected]>
12+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1113
Licensed under the MIT license:
1214
1315
Permission is hereby granted, free of charge, to any person obtaining

Modules/expat/nametab.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
\___/_/\_\ .__/ \__,_|\__|
77
|_| XML parser
88
9-
Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10-
Copyright (c) 2000-2017 Expat development team
9+
Copyright (c) 2000 Clark Cooper <[email protected]>
10+
Copyright (c) 2017 Sebastian Pipping <[email protected]>
1111
Licensed under the MIT license:
1212
1313
Permission is hereby granted, free of charge, to any person obtaining

0 commit comments

Comments
 (0)