Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion Makefile.pre.in
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,7 @@ DTRACE_DEPS = \
# pyexpat's expat library

LIBEXPAT_OBJS= \
Modules/expat/xcs.o \
Modules/expat/xmlparse.o \
Modules/expat/xmlrole.o \
Modules/expat/xmltok.o
Expand All @@ -638,7 +639,7 @@ LIBEXPAT_HEADERS= \
Modules/expat/pyexpatns.h \
Modules/expat/siphash.h \
Modules/expat/utf8tab.h \
Modules/expat/xcsinc.c \
Modules/expat/xcs.h \
Modules/expat/xmlrole.h \
Modules/expat/xmltok.h \
Modules/expat/xmltok_impl.h \
Expand Down Expand Up @@ -1450,6 +1451,9 @@ PYTHON_HEADERS= \
# Build static libexpat.a
LIBEXPAT_CFLAGS=@LIBEXPAT_CFLAGS@ $(PY_STDMODULE_CFLAGS) $(CCSHARED)

Modules/expat/xcs.o: $(srcdir)/Modules/expat/xcs.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xcs.c

Modules/expat/xmlparse.o: $(srcdir)/Modules/expat/xmlparse.c $(LIBEXPAT_HEADERS) $(PYTHON_HEADERS)
$(CC) -c $(LIBEXPAT_CFLAGS) -o $@ $(srcdir)/Modules/expat/xmlparse.c

Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Update bundled `libexpat <https://libexpat.github.io/>`_ to version 2.8.5.
Update bundled `libexpat <https://libexpat.github.io/>`_ to version 2.9.0.
61 changes: 40 additions & 21 deletions Misc/sbom.spdx.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

99 changes: 72 additions & 27 deletions Modules/expat/expat.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
#ifndef Expat_INCLUDED
# define Expat_INCLUDED 1

# include <stdint.h> // for uint8_t
# include <stdint.h> // for int64_t, uint8_t, uint64_t
# include <stdlib.h>
# include "expat_external.h"

Expand Down Expand Up @@ -140,6 +140,26 @@ enum XML_Error {
XML_ERROR_NOT_STARTED,
};

/* Added in 2.9.0. */
enum XML_Prop_Error {
XML_PROP_ERROR_NONE = 0, // i.e. success

XML_PROP_ERROR_INVALID_KEY = 1, // i.e. the property is not known at all
XML_PROP_ERROR_INVALID_TYPE = 2, // i.e. the property is known but expects a
// different type (so a different
// getter/setter would need to be called)
XML_PROP_ERROR_INVALID_VALUE = 3, // i.e. the value is invalid (with a setter
// function) or a NULL-pointer (with a
// getter function)

XML_PROP_ERROR_PARSER_NULL = 4, // i.e. the parser argument is NULL
XML_PROP_ERROR_PARSER_NOT_ROOT = 5, // i.e. the parser is not a root parser
// but a subparser (and a root parser is
// needed)

/* potentially more error codes upcoming here */
};

enum XML_Content_Type {
XML_CTYPE_EMPTY = 1,
XML_CTYPE_ANY,
Expand Down Expand Up @@ -757,29 +777,6 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
XMLPARSEAPI(int)
XML_GetIdAttributeIndex(XML_Parser parser);

# ifdef XML_ATTR_INFO
/* Source file byte offsets for the start and end of attribute names and values.
The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
file an attribute value of "blah" will yield:
info->valueEnd - info->valueStart = 4 bytes.
*/
typedef struct {
XML_Index nameStart; /* Offset to beginning of the attribute name. */
XML_Index nameEnd; /* Offset after the attribute name's last byte. */
XML_Index valueStart; /* Offset to beginning of the attribute value. */
XML_Index valueEnd; /* Offset after the attribute value's last byte. */
} XML_AttrInfo;

/* Returns an array of XML_AttrInfo structures for the attribute/value pairs
passed in last call to the XML_StartElementHandler that were specified
in the start-tag rather than defaulted. Each attribute/value pair counts
as 1; thus the number of entries in the array is
XML_GetSpecifiedAttributeCount(parser) / 2.
*/
XMLPARSEAPI(const XML_AttrInfo *)
XML_GetAttributeInfo(XML_Parser parser);
# endif

/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
detected. The last call to XML_Parse must have isFinal true; len
may be zero for this call (or any other).
Expand Down Expand Up @@ -964,15 +961,24 @@ XML_GetErrorCode(XML_Parser parser);
return 0 to indicate an error.
Note: XML_GetCurrentByteIndex returns -1 to indicate an error.
*/
XML_ATTR_DEPRECATED("please use XML_GetCurrentLineNumber64 instead")
XMLPARSEAPI(XML_Size) XML_GetCurrentLineNumber(XML_Parser parser);
XMLPARSEAPI(uint64_t) XML_GetCurrentLineNumber64(XML_Parser parser);
XML_ATTR_DEPRECATED("please use XML_GetCurrentColumnNumber64 instead")
XMLPARSEAPI(XML_Size) XML_GetCurrentColumnNumber(XML_Parser parser);
XMLPARSEAPI(uint64_t) XML_GetCurrentColumnNumber64(XML_Parser parser);
XML_ATTR_DEPRECATED("please use XML_GetCurrentByteIndex64 instead")
XMLPARSEAPI(XML_Index) XML_GetCurrentByteIndex(XML_Parser parser);
XMLPARSEAPI(int64_t) XML_GetCurrentByteIndex64(XML_Parser parser);

/* Return the number of bytes in the current event.
Returns 0 if the event is in an internal entity.
*/
XML_ATTR_DEPRECATED("please use XML_GetCurrentByteCount64 instead")
XMLPARSEAPI(int)
XML_GetCurrentByteCount(XML_Parser parser);
XMLPARSEAPI(uint64_t)
XML_GetCurrentByteCount64(XML_Parser parser);

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

/* For backwards compatibility with previous versions. */
# define XML_GetErrorLineNumber XML_GetCurrentLineNumber
Expand Down Expand Up @@ -1040,14 +1049,15 @@ enum XML_FeatureEnum {
XML_FEATURE_UNICODE_WCHAR_T,
XML_FEATURE_DTD,
XML_FEATURE_CONTEXT_BYTES,
/* Added in Expat 1.95.5, removed in Expat 2.9.0. */
XML_FEATURE_MIN_SIZE,
XML_FEATURE_SIZEOF_XML_CHAR,
XML_FEATURE_SIZEOF_XML_LCHAR,
/* Added in Expat 2.0.0. */
XML_FEATURE_NS,
/* Added in Expat 2.0.1. */
XML_FEATURE_LARGE_SIZE,
/* Added in Expat 2.1.0. */
/* Added in Expat 2.1.0, removed in Expat 2.9.0. */
XML_FEATURE_ATTR_INFO,
/* Added in Expat 2.4.0. */
XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
Expand All @@ -1069,6 +1079,41 @@ typedef struct {
XMLPARSEAPI(const XML_Feature *)
XML_GetFeatureList(void);

/* Added in Expat 2.9.0. */
enum XML_Parser_Property {
# if defined(XML_TESTING)
XML_PROP_INVALID = 0,
# endif
# if XML_GE == 1
XML_PROP_ALLOC_TRACKER_ACTIVATION_THRESHOLD = 1, // of type `uint64_t`
XML_PROP_ALLOC_TRACKER_MAXIMUM_AMPLIFICATION = 2, // of type `double`
XML_PROP_BILLION_LAUGHS_ACTIVATION_THRESHOLD = 3, // of type `uint64_t`
XML_PROP_BILLION_LAUGHS_MAXIMUM_AMPLIFICATION = 4, // of type `double`
# endif
XML_PROP_REPARSE_DEFERRAL_ENABLED = 5, // of type `XML_Bool`
/* more properties upcoming here */
};

/* Added in Expat 2.9.0. */
XMLPARSEAPI(enum XML_Prop_Error)
XML_GetPropertyBool(XML_Parser parser, enum XML_Parser_Property property,
XML_Bool *value);
XMLPARSEAPI(enum XML_Prop_Error)
XML_GetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property,
double *value);
XMLPARSEAPI(enum XML_Prop_Error)
XML_GetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property,
uint64_t *value);
XMLPARSEAPI(enum XML_Prop_Error)
XML_SetPropertyBool(XML_Parser parser, enum XML_Parser_Property property,
XML_Bool value);
XMLPARSEAPI(enum XML_Prop_Error)
XML_SetPropertyDouble(XML_Parser parser, enum XML_Parser_Property property,
double value);
XMLPARSEAPI(enum XML_Prop_Error)
XML_SetPropertyUInt64(XML_Parser parser, enum XML_Parser_Property property,
uint64_t value);

# if defined(XML_DTD) || (defined(XML_GE) && XML_GE == 1)
/* Added in Expat 2.4.0 for XML_DTD defined and
* added in Expat 2.6.0 for XML_GE == 1. */
Expand Down Expand Up @@ -1101,8 +1146,8 @@ XML_SetReparseDeferralEnabled(XML_Parser parser, XML_Bool enabled);
See https://semver.org
*/
# define XML_MAJOR_VERSION 2
# define XML_MINOR_VERSION 8
# define XML_MICRO_VERSION 5
# define XML_MINOR_VERSION 9
# define XML_MICRO_VERSION 0

# ifdef __cplusplus
}
Expand Down
3 changes: 3 additions & 0 deletions Modules/expat/expat_external.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,9 @@ typedef char XML_LChar;
# endif /* XML_UNICODE */

# ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */
# if defined(__clang__) || defined(__GNUC__)
# warning Macro XML_LARGE_SIZE is deprecated, please use the 64bit location API functions instead.
# endif
typedef long long XML_Index;
typedef unsigned long long XML_Size;
# else
Expand Down
12 changes: 5 additions & 7 deletions Modules/expat/internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,11 @@
#if ! defined(INTERNAL_H)
# define INTERNAL_H 1

# ifndef XML_MIN_SIZE
# if ! defined(inline)
# ifdef __GNUC__
# define inline __inline
# endif /* __GNUC__ */
# endif
# endif /* XML_MIN_SIZE */
# if ! defined(inline)
# ifdef __GNUC__
# define inline __inline
# endif /* __GNUC__ */
# endif

# ifndef inline
# define inline
Expand Down
Loading
Loading