Skip to content

Commit 7c6309c

Browse files
committed
Update the embedded copy of the expat XML parser to 2.1.0. It brings
with it a vareity of bug fixes, both security and behavior. See http://www.libexpat.org/ for the list. NOTE: I already backported the expat hash randomization fix in March. Fixes issue python#14340.
1 parent 1581067 commit 7c6309c

12 files changed

Lines changed: 374 additions & 258 deletions

File tree

Modules/expat/COPYING

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd
22
and Clark Cooper
3+
Copyright (c) 2001, 2002, 2003, 2004, 2005, 2006 Expat maintainers.
34

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

Modules/expat/amigaconfig.h

Lines changed: 0 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -10,66 +10,12 @@
1010
/* Define to 1 if you have the <check.h> header file. */
1111
#undef HAVE_CHECK_H
1212

13-
/* Define to 1 if you have the <dlfcn.h> header file. */
14-
#undef HAVE_DLFCN_H
15-
16-
/* Define to 1 if you have the <fcntl.h> header file. */
17-
#define HAVE_FCNTL_H 1
18-
19-
/* Define to 1 if you have the `getpagesize' function. */
20-
#undef HAVE_GETPAGESIZE
21-
22-
/* Define to 1 if you have the <inttypes.h> header file. */
23-
#define HAVE_INTTYPES_H 1
24-
2513
/* Define to 1 if you have the `memmove' function. */
2614
#define HAVE_MEMMOVE 1
2715

28-
/* Define to 1 if you have the <memory.h> header file. */
29-
#undef HAVE_MEMORY_H
30-
31-
/* Define to 1 if you have a working `mmap' system call. */
32-
#undef HAVE_MMAP
33-
34-
/* Define to 1 if you have the <stdint.h> header file. */
35-
#define HAVE_STDINT_H 1
36-
37-
/* Define to 1 if you have the <stdlib.h> header file. */
38-
#define HAVE_STDLIB_H 1
39-
40-
/* Define to 1 if you have the <strings.h> header file. */
41-
#define HAVE_STRINGS_H 1
42-
43-
/* Define to 1 if you have the <string.h> header file. */
44-
#define HAVE_STRING_H 1
45-
46-
/* Define to 1 if you have the <sys/stat.h> header file. */
47-
#define HAVE_SYS_STAT_H 1
48-
49-
/* Define to 1 if you have the <sys/types.h> header file. */
50-
#define HAVE_SYS_TYPES_H 1
51-
5216
/* Define to 1 if you have the <unistd.h> header file. */
5317
#define HAVE_UNISTD_H 1
5418

55-
/* Define to the address where bug reports for this package should be sent. */
56-
#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org"
57-
58-
/* Define to the full name of this package. */
59-
#define PACKAGE_NAME "expat"
60-
61-
/* Define to the full name and version of this package. */
62-
#define PACKAGE_STRING "expat 1.95.8"
63-
64-
/* Define to the one symbol short name of this package. */
65-
#undef PACKAGE_TARNAME
66-
67-
/* Define to the version of this package. */
68-
#define PACKAGE_VERSION "1.95.8"
69-
70-
/* Define to 1 if you have the ANSI C header files. */
71-
#define STDC_HEADERS 1
72-
7319
/* whether byteorder is bigendian */
7420
#define WORDS_BIGENDIAN
7521

@@ -83,14 +29,4 @@
8329
/* Define to make XML Namespaces functionality available. */
8430
#define XML_NS
8531

86-
/* Define to empty if `const' does not conform to ANSI C. */
87-
#undef const
88-
89-
/* Define to `long' if <sys/types.h> does not define. */
90-
#undef off_t
91-
92-
/* Define to `unsigned' if <sys/types.h> does not define. */
93-
#undef size_t
94-
95-
9632
#endif /* AMIGACONFIG_H */

Modules/expat/ascii.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,10 @@
8383
#define ASCII_LSQB 0x5B
8484
#define ASCII_RSQB 0x5D
8585
#define ASCII_UNDERSCORE 0x5F
86+
#define ASCII_LPAREN 0x28
87+
#define ASCII_RPAREN 0x29
88+
#define ASCII_FF 0x0C
89+
#define ASCII_SLASH 0x2F
90+
#define ASCII_HASH 0x23
91+
#define ASCII_PIPE 0x7C
92+
#define ASCII_COMMA 0x2C

Modules/expat/expat.h

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -742,6 +742,29 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
742742
XMLPARSEAPI(int)
743743
XML_GetIdAttributeIndex(XML_Parser parser);
744744

745+
#ifdef XML_ATTR_INFO
746+
/* Source file byte offsets for the start and end of attribute names and values.
747+
The value indices are exclusive of surrounding quotes; thus in a UTF-8 source
748+
file an attribute value of "blah" will yield:
749+
info->valueEnd - info->valueStart = 4 bytes.
750+
*/
751+
typedef struct {
752+
XML_Index nameStart; /* Offset to beginning of the attribute name. */
753+
XML_Index nameEnd; /* Offset after the attribute name's last byte. */
754+
XML_Index valueStart; /* Offset to beginning of the attribute value. */
755+
XML_Index valueEnd; /* Offset after the attribute value's last byte. */
756+
} XML_AttrInfo;
757+
758+
/* Returns an array of XML_AttrInfo structures for the attribute/value pairs
759+
passed in last call to the XML_StartElementHandler that were specified
760+
in the start-tag rather than defaulted. Each attribute/value pair counts
761+
as 1; thus the number of entries in the array is
762+
XML_GetSpecifiedAttributeCount(parser) / 2.
763+
*/
764+
XMLPARSEAPI(const XML_AttrInfo *)
765+
XML_GetAttributeInfo(XML_Parser parser);
766+
#endif
767+
745768
/* Parses some input. Returns XML_STATUS_ERROR if a fatal error is
746769
detected. The last call to XML_Parse must have isFinal true; len
747770
may be zero for this call (or any other).
@@ -994,7 +1017,9 @@ enum XML_FeatureEnum {
9941017
XML_FEATURE_MIN_SIZE,
9951018
XML_FEATURE_SIZEOF_XML_CHAR,
9961019
XML_FEATURE_SIZEOF_XML_LCHAR,
997-
XML_FEATURE_NS
1020+
XML_FEATURE_NS,
1021+
XML_FEATURE_LARGE_SIZE,
1022+
XML_FEATURE_ATTR_INFO
9981023
/* Additional features must be added to the end of this enum. */
9991024
};
10001025

@@ -1014,7 +1039,7 @@ XML_GetFeatureList(void);
10141039
change to major or minor version.
10151040
*/
10161041
#define XML_MAJOR_VERSION 2
1017-
#define XML_MINOR_VERSION 0
1042+
#define XML_MINOR_VERSION 1
10181043
#define XML_MICRO_VERSION 0
10191044

10201045
#ifdef __cplusplus

Modules/expat/expat_external.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,7 @@
77

88
/* External API definitions */
99

10-
/* Namespace external symbols to allow multiple libexpat version to
11-
co-exist. */
12-
#include "pyexpatns.h"
13-
14-
#if defined(_MSC_EXTENSIONS) && !defined(__CYGWIN__)
10+
#if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__)
1511
#define XML_USE_MSC_EXTENSIONS 1
1612
#endif
1713

@@ -38,9 +34,9 @@
3834
system headers may assume the cdecl convention.
3935
*/
4036
#ifndef XMLCALL
41-
#if defined(XML_USE_MSC_EXTENSIONS)
37+
#if defined(_MSC_VER)
4238
#define XMLCALL __cdecl
43-
#elif defined(__GNUC__) && defined(__i386)
39+
#elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER)
4440
#define XMLCALL __attribute__((cdecl))
4541
#else
4642
/* For any platform which uses this definition and supports more than

Modules/expat/internal.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
and therefore subject to change.
2121
*/
2222

23-
#if defined(__GNUC__) && defined(__i386__)
23+
#if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__)
2424
/* We'll use this version by default only where we know it helps.
2525
2626
regparm() generates warnings on Solaris boxes. See SF bug #692878.

Modules/expat/watcomconfig.h

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* expat_config.h for use with Open Watcom 1.5 and above. */
2+
3+
#ifndef WATCOMCONFIG_H
4+
#define WATCOMCONFIG_H
5+
6+
#ifdef __NT__
7+
#define WIN32_LEAN_AND_MEAN
8+
#include <windows.h>
9+
#undef WIN32_LEAN_AND_MEAN
10+
#endif
11+
12+
/* 1234 = LIL_ENDIAN, 4321 = BIGENDIAN */
13+
#define BYTEORDER 1234
14+
15+
/* Define to 1 if you have the `memmove' function. */
16+
#define HAVE_MEMMOVE 1
17+
18+
/* Define to 1 if you have the <unistd.h> header file. */
19+
#define HAVE_UNISTD_H 1
20+
21+
/* Define to the address where bug reports for this package should be sent. */
22+
#define PACKAGE_BUGREPORT "expat-bugs@mail.libexpat.org"
23+
24+
/* Define to the full name of this package. */
25+
#define PACKAGE_NAME "expat"
26+
27+
/* Define to the full name and version of this package. */
28+
#define PACKAGE_STRING "expat 2.0.0"
29+
30+
/* Define to the one symbol short name of this package. */
31+
#undef PACKAGE_TARNAME
32+
33+
/* Define to the version of this package. */
34+
#define PACKAGE_VERSION "2.0.0"
35+
36+
/* Define to specify how much context to retain around the current parse
37+
point. */
38+
#define XML_CONTEXT_BYTES 1024
39+
40+
/* Define to make parameter entity parsing functionality available. */
41+
#define XML_DTD 1
42+
43+
/* Define to make XML Namespaces functionality available. */
44+
#define XML_NS 1
45+
46+
#endif
47+

0 commit comments

Comments
 (0)