Skip to content

Commit 0071fb5

Browse files
gh-158876: Update bundled Expat to 2.9.0 (GH-158881)
Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent f37e821 commit 0071fb5

18 files changed

Lines changed: 765 additions & 468 deletions

‎Makefile.pre.in‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,7 @@ DTRACE_DEPS = \
618618
# pyexpat's expat library
619619

620620
LIBEXPAT_OBJS= \
621+
Modules/expat/xcs.o \
621622
Modules/expat/xmlparse.o \
622623
Modules/expat/xmlrole.o \
623624
Modules/expat/xmltok.o
@@ -638,7 +639,7 @@ LIBEXPAT_HEADERS= \
638639
Modules/expat/pyexpatns.h \
639640
Modules/expat/siphash.h \
640641
Modules/expat/utf8tab.h \
641-
Modules/expat/xcsinc.c \
642+
Modules/expat/xcs.h \
642643
Modules/expat/xmlrole.h \
643644
Modules/expat/xmltok.h \
644645
Modules/expat/xmltok_impl.h \
@@ -1451,6 +1452,9 @@ PYTHON_HEADERS= \
14511452
# Build static libexpat.a
14521453
LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)
14531454

1455+
Modules/expat/xcs.o: $(srcdir)/Modules/expat/xcs.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
1456+
$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xcs.c
1457+
14541458
Modules/expat/xmlparse.o: $(srcdir)/Modules/expat/xmlparse.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
14551459
$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlparse.c
14561460

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Update bundled `libexpat <https://libexpat.github.io/>`_ to version 2.9.0.

‎Misc/sbom.spdx.json‎

Lines changed: 40 additions & 21 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Modules/expat/expat.h‎

Lines changed: 72 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
#ifndef Expat_INCLUDED
4949
# define Expat_INCLUDED 1
5050

51-
# include <stdint.h> // for uint8_t
51+
# include <stdint.h> // for int64_t, uint8_t, uint64_t
5252
# include <stdlib.h>
5353
# include "expat_external.h"
5454

@@ -140,6 +140,26 @@ enum XML_Error {
140140
XML_ERROR_NOT_STARTED,
141141
};
142142

143+
/* Added in 2.9.0. */
144+
enum XML_Prop_Error {
145+
XML_PROP_ERROR_NONE = 0, // i.e. success
146+
147+
XML_PROP_ERROR_INVALID_KEY = 1, // i.e. the property is not known at all
148+
XML_PROP_ERROR_INVALID_TYPE = 2, // i.e. the property is known but expects a
149+
// different type (so a different
150+
// getter/setter would need to be called)
151+
XML_PROP_ERROR_INVALID_VALUE = 3, // i.e. the value is invalid (with a setter
152+
// function) or a NULL-pointer (with a
153+
// getter function)
154+
155+
XML_PROP_ERROR_PARSER_NULL = 4, // i.e. the parser argument is NULL
156+
XML_PROP_ERROR_PARSER_NOT_ROOT = 5, // i.e. the parser is not a root parser
157+
// but a subparser (and a root parser is
158+
// needed)
159+
160+
/* potentially more error codes upcoming here */
161+
};
162+
143163
enum XML_Content_Type {
144164
XML_CTYPE_EMPTY = 1,
145165
XML_CTYPE_ANY,
@@ -757,29 +777,6 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
757777
XMLPARSEAPI(int)
758778
XML_GetIdAttributeIndex(XML_Parser parser);
759779

760-
# ifdef XML_ATTR_INFO
761-
/* Source file byte offsets for the start and end of attribute names and values.
762-
The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
763-
file an attribute value of "blah" will yield:
764-
info->valueEnd - info->valueStart = 4 bytes.
765-
*/
766-
typedef struct {
767-
XML_Index nameStart; /* Offset to beginning of the attribute name. */
768-
XML_Index nameEnd; /* Offset after the attribute name's last byte. */
769-
XML_Index valueStart; /* Offset to beginning of the attribute value. */
770-
XML_Index valueEnd; /* Offset after the attribute value's last byte. */
771-
} XML_AttrInfo;
772-
773-
/* Returns an array of XML_AttrInfo structures for the attribute/value pairs
774-
passed in last call to the XML_StartElementHandler that were specified
775-
in the start-tag rather than defaulted. Each attribute/value pair counts
776-
as 1; thus the number of entries in the array is
777-
XML_GetSpecifiedAttributeCount(parser) / 2.
778-
*/
779-
XMLPARSEAPI(const XML_AttrInfo *)
780-
XML_GetAttributeInfo(XML_Parser parser);
781-
# endif
782-
783780
/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
784781
detected. The last call to XML_Parse must have isFinal true; len
785782
may be zero for this call (or any other).
@@ -964,15 +961,24 @@ XML_GetErrorCode(XML_Parser parser);
964961
return 0 to indicate an error.
965962
Note: XML_GetCurrentByteIndex returns -1 to indicate an error.
966963
*/
964+
XML_ATTR_DEPRECATED("please use XML_GetCurrentLineNumber64 instead")
967965
XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
966+
XMLPARSEAPI(uint64_t) XML_GetCurrentLineNumber64(XML_Parser parser);
967+
XML_ATTR_DEPRECATED("please use XML_GetCurrentColumnNumber64 instead")
968968
XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
969+
XMLPARSEAPI(uint64_t) XML_GetCurrentColumnNumber64(XML_Parser parser);
970+
XML_ATTR_DEPRECATED("please use XML_GetCurrentByteIndex64 instead")
969971
XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
972+
XMLPARSEAPI(int64_t) XML_GetCurrentByteIndex64(XML_Parser parser);
970973

971974
/* Return the number of bytes in the current event.
972975
Returns 0 if the event is in an internal entity.
973976
*/
977+
XML_ATTR_DEPRECATED("please use XML_GetCurrentByteCount64 instead")
974978
XMLPARSEAPI(int)
975979
XML_GetCurrentByteCount(XML_Parser parser);
980+
XMLPARSEAPI(uint64_t)
981+
XML_GetCurrentByteCount64(XML_Parser parser);
976982

977983
/* If XML_CONTEXT_BYTES is >=1, returns the input buffer, sets
978984
the integer pointed to by offset to the offset within this buffer
@@ -984,8 +990,11 @@ XML_GetCurrentByteCount(XML_Parser parser);
984990
NOTE: The character pointer returned should not be used outside
985991
the handler that makes the call.
986992
*/
993+
XML_ATTR_DEPRECATED("please use XML_GetInputContext64 instead")
987994
XMLPARSEAPI(const char *)
988995
XML_GetInputContext(XML_Parser parser, int *offset, int *size);
996+
XMLPARSEAPI(const char *)
997+
XML_GetInputContext64(XML_Parser parser, int64_t *offset, uint64_t *size);
989998

990999
/* For backwards compatibility with previous versions. */
9911000
# define XML_GetErrorLineNumber XML_GetCurrentLineNumber
@@ -1040,14 +1049,15 @@ enum XML_FeatureEnum {
10401049
XML_FEATURE_UNICODE_WCHAR_T,
10411050
XML_FEATURE_DTD,
10421051
XML_FEATURE_CONTEXT_BYTES,
1052+
/* Added in Expat 1.95.5, removed in Expat 2.9.0. */
10431053
XML_FEATURE_MIN_SIZE,
10441054
XML_FEATURE_SIZEOF_XML_CHAR,
10451055
XML_FEATURE_SIZEOF_XML_LCHAR,
10461056
/* Added in Expat 2.0.0. */
10471057
XML_FEATURE_NS,
10481058
/* Added in Expat 2.0.1. */
10491059
XML_FEATURE_LARGE_SIZE,
1050-
/* Added in Expat 2.1.0. */
1060+
/* Added in Expat 2.1.0, removed in Expat 2.9.0. */
10511061
XML_FEATURE_ATTR_INFO,
10521062
/* Added in Expat 2.4.0. */
10531063
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
@@ -1069,6 +1079,41 @@ typedef struct {
10691079
XMLPARSEAPI(const XML_Feature *)
10701080
XML_GetFeatureList(void);
10711081

1082+
/* Added in Expat 2.9.0. */
1083+
enum XML_Parser_Property {
1084+
# if defined(XML_TESTING)
1085+
XML_PROP_INVALID = 0,
1086+
# endif
1087+
# if XML_GE == 1
1088+
XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD = 1, // of type `uint64_t`
1089+
XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION = 2, // of type `double`
1090+
XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD = 3, // of type `uint64_t`
1091+
XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION = 4, // of type `double`
1092+
# endif
1093+
XML_PROP_REPARSE_DEFERRAL_ENABLED = 5, // of type `XML_Bool`
1094+
/* more properties upcoming here */
1095+
};
1096+
1097+
/* Added in Expat 2.9.0. */
1098+
XMLPARSEAPI(enum XML_Prop_Error)
1099+
XML_GetPropertyBool(XML_Parser parser, enum XML_Parser_Property property,
1100+
XML_Bool *value);
1101+
XMLPARSEAPI(enum XML_Prop_Error)
1102+
XML_GetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property,
1103+
double *value);
1104+
XMLPARSEAPI(enum XML_Prop_Error)
1105+
XML_GetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property,
1106+
uint64_t *value);
1107+
XMLPARSEAPI(enum XML_Prop_Error)
1108+
XML_SetPropertyBool(XML_Parser parser, enum XML_Parser_Property property,
1109+
XML_Bool value);
1110+
XMLPARSEAPI(enum XML_Prop_Error)
1111+
XML_SetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property,
1112+
double value);
1113+
XMLPARSEAPI(enum XML_Prop_Error)
1114+
XML_SetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property,
1115+
uint64_t value);
1116+
10721117
# if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
10731118
/* Added in Expat 2.4.0 for XML_DTD defined and
10741119
* added in Expat 2.6.0 for XML_GE == 1. */
@@ -1101,8 +1146,8 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
11011146
See https://semver.org
11021147
*/
11031148
# define XML_MAJOR_VERSION 2
1104-
# define XML_MINOR_VERSION 8
1105-
# define XML_MICRO_VERSION 5
1149+
# define XML_MINOR_VERSION 9
1150+
# define XML_MICRO_VERSION 0
11061151

11071152
# ifdef __cplusplus
11081153
}

‎Modules/expat/expat_external.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,9 @@ typedef char XML_LChar;
169169
# endif /* XML_UNICODE */
170170

171171
# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
172+
# if defined(__clang__) || defined(__GNUC__)
173+
# warning Macro XML_LARGE_SIZE is deprecated, please use the 64bit location API functions instead.
174+
# endif
172175
typedef long long XML_Index;
173176
typedef unsigned long long XML_Size;
174177
# else

‎Modules/expat/internal.h‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,11 @@
5656
#if ! defined(INTERNAL_H)
5757
# define INTERNAL_H 1
5858

59-
# ifndef XML_MIN_SIZE
60-
# if ! defined(inline)
61-
# ifdef __GNUC__
62-
# define inline __inline
63-
# endif /* __GNUC__ */
64-
# endif
65-
# endif /* XML_MIN_SIZE */
59+
# if ! defined(inline)
60+
# ifdef __GNUC__
61+
# define inline __inline
62+
# endif /* __GNUC__ */
63+
# endif
6664

6765
# ifndef inline
6866
# define inline

0 commit comments

Comments
 (0)