Mercurial > cpython-lru_cache-weakref
annotate Modules/expat/xmlparse.c @ 79691:05c8928362ee
Merge __next__ method link fixes with 3.3.
| author | Ezio Melotti <ezio.melotti@gmail.com> |
|---|---|
| date | Fri, 12 Oct 2012 13:46:37 +0300 |
| parents | e4dc8be9a72f |
| children |
| rev | line source |
|---|---|
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1 /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2 See the file COPYING for copying permission. |
| 21930 | 3 */ |
| 4 | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5 #include <stddef.h> |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
6 #include <string.h> /* memset(), memcpy() */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
7 #include <assert.h> |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
8 #include <limits.h> /* UINT_MAX */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
9 #include <time.h> /* time() */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
10 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
11 #define XML_BUILDING_EXPAT 1 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
12 |
| 21930 | 13 #ifdef COMPILED_FROM_DSP |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
14 #include "winconfig.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
15 #elif defined(MACOS_CLASSIC) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
16 #include "macconfig.h" |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
17 #elif defined(__amigaos__) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
18 #include "amigaconfig.h" |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
19 #elif defined(__WATCOMC__) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
20 #include "watcomconfig.h" |
| 32911 | 21 #elif defined(HAVE_EXPAT_CONFIG_H) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
22 #include <expat_config.h> |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
23 #endif /* ndef COMPILED_FROM_DSP */ |
| 21930 | 24 |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
25 #include "ascii.h" |
| 21930 | 26 #include "expat.h" |
| 27 | |
| 28 #ifdef XML_UNICODE | |
| 29 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX | |
| 30 #define XmlConvert XmlUtf16Convert | |
| 31 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding | |
| 32 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS | |
| 33 #define XmlEncode XmlUtf16Encode | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
34 /* Using pointer subtraction to convert to integer type. */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
35 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((char *)(s) - (char *)NULL) & 1)) |
| 21930 | 36 typedef unsigned short ICHAR; |
| 37 #else | |
| 38 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX | |
| 39 #define XmlConvert XmlUtf8Convert | |
| 40 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding | |
| 41 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS | |
| 42 #define XmlEncode XmlUtf8Encode | |
| 43 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8) | |
| 44 typedef char ICHAR; | |
| 45 #endif | |
| 46 | |
| 47 | |
| 48 #ifndef XML_NS | |
| 49 | |
| 50 #define XmlInitEncodingNS XmlInitEncoding | |
| 51 #define XmlInitUnknownEncodingNS XmlInitUnknownEncoding | |
| 52 #undef XmlGetInternalEncodingNS | |
| 53 #define XmlGetInternalEncodingNS XmlGetInternalEncoding | |
| 54 #define XmlParseXmlDeclNS XmlParseXmlDecl | |
| 55 | |
| 56 #endif | |
| 57 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
58 #ifdef XML_UNICODE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
59 |
| 21930 | 60 #ifdef XML_UNICODE_WCHAR_T |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
61 #define XML_T(x) (const wchar_t)x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
62 #define XML_L(x) L ## x |
| 21930 | 63 #else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
64 #define XML_T(x) (const unsigned short)x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
65 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
66 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
67 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
68 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
69 |
| 21930 | 70 #define XML_T(x) x |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
71 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
72 |
| 21930 | 73 #endif |
| 74 | |
| 75 /* Round up n to be a multiple of sz, where sz is a power of 2. */ | |
| 76 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | |
| 77 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
78 /* Handle the case where memmove() doesn't exist. */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
79 #ifndef HAVE_MEMMOVE |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
80 #ifdef HAVE_BCOPY |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
81 #define memmove(d,s,l) bcopy((s),(d),(l)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
82 #else |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
83 #error memmove does not exist on this platform, nor is a substitute available |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
84 #endif /* HAVE_BCOPY */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
85 #endif /* HAVE_MEMMOVE */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
86 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
87 #include "internal.h" |
| 21930 | 88 #include "xmltok.h" |
| 89 #include "xmlrole.h" | |
| 90 | |
| 91 typedef const XML_Char *KEY; | |
| 92 | |
| 93 typedef struct { | |
| 94 KEY name; | |
| 95 } NAMED; | |
| 96 | |
| 97 typedef struct { | |
| 98 NAMED **v; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
99 unsigned char power; |
| 21930 | 100 size_t size; |
| 101 size_t used; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
102 const XML_Memory_Handling_Suite *mem; |
| 21930 | 103 } HASH_TABLE; |
| 104 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
105 /* Basic character hash algorithm, taken from Python's string hash: |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
106 h = h * 1000003 ^ character, the constant being a prime number. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
107 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
108 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
109 #ifdef XML_UNICODE |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
110 #define CHAR_HASH(h, c) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
111 (((h) * 0xF4243) ^ (unsigned short)(c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
112 #else |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
113 #define CHAR_HASH(h, c) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
114 (((h) * 0xF4243) ^ (unsigned char)(c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
115 #endif |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
116 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
117 /* For probing (after a collision) we need a step size relative prime |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
118 to the hash table size, which is a power of 2. We use double-hashing, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
119 since we can calculate a second hash value cheaply by taking those bits |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
120 of the first hash value that were discarded (masked out) when the table |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
121 index was calculated: index = hash & mask, where mask = table->size - 1. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
122 We limit the maximum step size to table->size / 4 (mask >> 2) and make |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
123 it odd, since odd numbers are always relative prime to a power of 2. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
124 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
125 #define SECOND_HASH(hash, mask, power) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
126 ((((hash) & ~(mask)) >> ((power) - 1)) & ((mask) >> 2)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
127 #define PROBE_STEP(hash, mask, power) \ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
128 ((unsigned char)((SECOND_HASH(hash, mask, power)) | 1)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
129 |
| 21930 | 130 typedef struct { |
| 131 NAMED **p; | |
| 132 NAMED **end; | |
| 133 } HASH_TABLE_ITER; | |
| 134 | |
| 135 #define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ | |
| 136 #define INIT_DATA_BUF_SIZE 1024 | |
| 137 #define INIT_ATTS_SIZE 16 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
138 #define INIT_ATTS_VERSION 0xFFFFFFFF |
| 21930 | 139 #define INIT_BLOCK_SIZE 1024 |
| 140 #define INIT_BUFFER_SIZE 1024 | |
| 141 | |
| 142 #define EXPAND_SPARE 24 | |
| 143 | |
| 144 typedef struct binding { | |
| 145 struct prefix *prefix; | |
| 146 struct binding *nextTagBinding; | |
| 147 struct binding *prevPrefixBinding; | |
| 148 const struct attribute_id *attId; | |
| 149 XML_Char *uri; | |
| 150 int uriLen; | |
| 151 int uriAlloc; | |
| 152 } BINDING; | |
| 153 | |
| 154 typedef struct prefix { | |
| 155 const XML_Char *name; | |
| 156 BINDING *binding; | |
| 157 } PREFIX; | |
| 158 | |
| 159 typedef struct { | |
| 160 const XML_Char *str; | |
| 161 const XML_Char *localPart; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
162 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
163 int strLen; |
| 21930 | 164 int uriLen; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
165 int prefixLen; |
| 21930 | 166 } TAG_NAME; |
| 167 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
168 /* TAG represents an open element. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
169 The name of the element is stored in both the document and API |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
170 encodings. The memory buffer 'buf' is a separately-allocated |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
171 memory area which stores the name. During the XML_Parse()/ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
172 XMLParseBuffer() when the element is open, the memory for the 'raw' |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
173 version of the name (in the document encoding) is shared with the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
174 document buffer. If the element is open across calls to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
175 XML_Parse()/XML_ParseBuffer(), the buffer is re-allocated to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
176 contain the 'raw' name as well. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
177 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
178 A parser re-uses these structures, maintaining a list of allocated |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
179 TAG objects in a free list. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
180 */ |
| 21930 | 181 typedef struct tag { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
182 struct tag *parent; /* parent of this element */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
183 const char *rawName; /* tagName in the original encoding */ |
| 21930 | 184 int rawNameLength; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
185 TAG_NAME name; /* tagName in the API encoding */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
186 char *buf; /* buffer for name components */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
187 char *bufEnd; /* end of the buffer */ |
| 21930 | 188 BINDING *bindings; |
| 189 } TAG; | |
| 190 | |
| 191 typedef struct { | |
| 192 const XML_Char *name; | |
| 193 const XML_Char *textPtr; | |
| 32911 | 194 int textLen; /* length in XML_Chars */ |
| 195 int processed; /* # of processed bytes - when suspended */ | |
| 21930 | 196 const XML_Char *systemId; |
| 197 const XML_Char *base; | |
| 198 const XML_Char *publicId; | |
| 199 const XML_Char *notation; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
200 XML_Bool open; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
201 XML_Bool is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
202 XML_Bool is_internal; /* true if declared in internal subset outside PE */ |
| 21930 | 203 } ENTITY; |
| 204 | |
| 205 typedef struct { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
206 enum XML_Content_Type type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
207 enum XML_Content_Quant quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
208 const XML_Char * name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
209 int firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
210 int lastchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
211 int childcnt; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
212 int nextsib; |
| 21930 | 213 } CONTENT_SCAFFOLD; |
| 214 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
215 #define INIT_SCAFFOLD_ELEMENTS 32 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
216 |
| 21930 | 217 typedef struct block { |
| 218 struct block *next; | |
| 219 int size; | |
| 220 XML_Char s[1]; | |
| 221 } BLOCK; | |
| 222 | |
| 223 typedef struct { | |
| 224 BLOCK *blocks; | |
| 225 BLOCK *freeBlocks; | |
| 226 const XML_Char *end; | |
| 227 XML_Char *ptr; | |
| 228 XML_Char *start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
229 const XML_Memory_Handling_Suite *mem; |
| 21930 | 230 } STRING_POOL; |
| 231 | |
| 232 /* The XML_Char before the name is used to determine whether | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
233 an attribute has been specified. */ |
| 21930 | 234 typedef struct attribute_id { |
| 235 XML_Char *name; | |
| 236 PREFIX *prefix; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
237 XML_Bool maybeTokenized; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
238 XML_Bool xmlns; |
| 21930 | 239 } ATTRIBUTE_ID; |
| 240 | |
| 241 typedef struct { | |
| 242 const ATTRIBUTE_ID *id; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
243 XML_Bool isCdata; |
| 21930 | 244 const XML_Char *value; |
| 245 } DEFAULT_ATTRIBUTE; | |
| 246 | |
| 247 typedef struct { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
248 unsigned long version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
249 unsigned long hash; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
250 const XML_Char *uriName; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
251 } NS_ATT; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
252 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
253 typedef struct { |
| 21930 | 254 const XML_Char *name; |
| 255 PREFIX *prefix; | |
| 256 const ATTRIBUTE_ID *idAtt; | |
| 257 int nDefaultAtts; | |
| 258 int allocDefaultAtts; | |
| 259 DEFAULT_ATTRIBUTE *defaultAtts; | |
| 260 } ELEMENT_TYPE; | |
| 261 | |
| 262 typedef struct { | |
| 263 HASH_TABLE generalEntities; | |
| 264 HASH_TABLE elementTypes; | |
| 265 HASH_TABLE attributeIds; | |
| 266 HASH_TABLE prefixes; | |
| 267 STRING_POOL pool; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
268 STRING_POOL entityValuePool; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
269 /* false once a parameter entity reference has been skipped */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
270 XML_Bool keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
271 /* true once an internal or external PE reference has been encountered; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
272 this includes the reference to an external subset */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
273 XML_Bool hasParamEntityRefs; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
274 XML_Bool standalone; |
| 21930 | 275 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
276 /* indicates if external PE has been read */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
277 XML_Bool paramEntityRead; |
| 21930 | 278 HASH_TABLE paramEntities; |
| 279 #endif /* XML_DTD */ | |
| 280 PREFIX defaultPrefix; | |
| 281 /* === scaffolding for building content model === */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
282 XML_Bool in_eldecl; |
| 21930 | 283 CONTENT_SCAFFOLD *scaffold; |
| 284 unsigned contentStringLen; | |
| 285 unsigned scaffSize; | |
| 286 unsigned scaffCount; | |
| 287 int scaffLevel; | |
| 288 int *scaffIndex; | |
| 289 } DTD; | |
| 290 | |
| 291 typedef struct open_internal_entity { | |
| 292 const char *internalEventPtr; | |
| 293 const char *internalEventEndPtr; | |
| 294 struct open_internal_entity *next; | |
| 295 ENTITY *entity; | |
| 32911 | 296 int startTagLevel; |
| 297 XML_Bool betweenDecl; /* WFC: PE Between Declarations */ | |
| 21930 | 298 } OPEN_INTERNAL_ENTITY; |
| 299 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
300 typedef enum XML_Error PTRCALL Processor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
301 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
302 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
303 const char **endPtr); |
| 21930 | 304 |
| 305 static Processor prologProcessor; | |
| 306 static Processor prologInitProcessor; | |
| 307 static Processor contentProcessor; | |
| 308 static Processor cdataSectionProcessor; | |
| 309 #ifdef XML_DTD | |
| 310 static Processor ignoreSectionProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
311 static Processor externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
312 static Processor externalParEntInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
313 static Processor entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
314 static Processor entityValueInitProcessor; |
| 21930 | 315 #endif /* XML_DTD */ |
| 316 static Processor epilogProcessor; | |
| 317 static Processor errorProcessor; | |
| 318 static Processor externalEntityInitProcessor; | |
| 319 static Processor externalEntityInitProcessor2; | |
| 320 static Processor externalEntityInitProcessor3; | |
| 321 static Processor externalEntityContentProcessor; | |
| 32911 | 322 static Processor internalEntityProcessor; |
| 21930 | 323 |
| 324 static enum XML_Error | |
| 325 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); | |
| 326 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
327 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, |
| 32911 | 328 const char *s, const char *next); |
| 21930 | 329 static enum XML_Error |
| 330 initializeEncoding(XML_Parser parser); | |
| 331 static enum XML_Error | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
332 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
333 const char *end, int tok, const char *next, const char **nextPtr, |
| 32911 | 334 XML_Bool haveMore); |
| 21930 | 335 static enum XML_Error |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
336 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 32911 | 337 XML_Bool betweenDecl); |
| 21930 | 338 static enum XML_Error |
| 339 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
340 const char *start, const char *end, const char **endPtr, |
| 32911 | 341 XML_Bool haveMore); |
| 21930 | 342 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
343 doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 344 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 345 #ifdef XML_DTD |
| 346 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
347 doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 348 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 349 #endif /* XML_DTD */ |
| 350 | |
| 351 static enum XML_Error | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
352 storeAtts(XML_Parser parser, const ENCODING *, const char *s, |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
353 TAG_NAME *tagNamePtr, BINDING **bindingsPtr); |
| 21930 | 354 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
355 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
356 const XML_Char *uri, BINDING **bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
357 static int |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
358 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, |
| 32911 | 359 XML_Bool isId, const XML_Char *dfltValue, XML_Parser parser); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
360 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
361 storeAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
362 const char *, const char *, STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
363 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
364 appendAttributeValue(XML_Parser parser, const ENCODING *, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
365 const char *, const char *, STRING_POOL *); |
| 21930 | 366 static ATTRIBUTE_ID * |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
367 getAttributeId(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
368 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
369 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
370 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); |
| 21930 | 371 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
372 storeEntityValue(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
373 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
374 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
375 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
376 const char *start, const char *end); |
| 21930 | 377 static int |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
378 reportComment(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
379 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
380 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
381 reportDefault(XML_Parser parser, const ENCODING *enc, const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
382 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
383 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
384 static const XML_Char * getContext(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
385 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
386 setContext(XML_Parser parser, const XML_Char *context); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
387 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
388 static void FASTCALL normalizePublicId(XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
389 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
390 static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
391 /* do not call if parentParser != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
392 static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); |
| 21930 | 393 static void |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
394 dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
395 static int |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
396 dtdCopy(XML_Parser oldParser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
397 DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
398 static int |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
399 copyEntityTable(XML_Parser oldParser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
400 HASH_TABLE *, STRING_POOL *, const HASH_TABLE *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
401 static NAMED * |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
402 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
403 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
404 hashTableInit(HASH_TABLE *, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
405 static void FASTCALL hashTableClear(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
406 static void FASTCALL hashTableDestroy(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
407 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
408 hashTableIterInit(HASH_TABLE_ITER *, const HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
409 static NAMED * FASTCALL hashTableIterNext(HASH_TABLE_ITER *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
410 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
411 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
412 poolInit(STRING_POOL *, const XML_Memory_Handling_Suite *ms); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
413 static void FASTCALL poolClear(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
414 static void FASTCALL poolDestroy(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
415 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
416 poolAppend(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
417 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
418 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
419 poolStoreString(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
420 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
421 static XML_Bool FASTCALL poolGrow(STRING_POOL *pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
422 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
423 poolCopyString(STRING_POOL *pool, const XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
424 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
425 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
426 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
427 poolAppendString(STRING_POOL *pool, const XML_Char *s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
428 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
429 static int FASTCALL nextScaffoldPart(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
430 static XML_Content * build_model(XML_Parser parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
431 static ELEMENT_TYPE * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
432 getElementType(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
433 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
434 |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
435 static unsigned long generate_hash_secret_salt(void); |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
436 static XML_Bool startParsing(XML_Parser parser); |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
437 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
438 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
439 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
440 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
441 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
442 DTD *dtd); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
443 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
444 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
445 parserInit(XML_Parser parser, const XML_Char *encodingName); |
| 21930 | 446 |
| 447 #define poolStart(pool) ((pool)->start) | |
| 448 #define poolEnd(pool) ((pool)->ptr) | |
| 449 #define poolLength(pool) ((pool)->ptr - (pool)->start) | |
| 450 #define poolChop(pool) ((void)--(pool->ptr)) | |
| 451 #define poolLastChar(pool) (((pool)->ptr)[-1]) | |
| 452 #define poolDiscard(pool) ((pool)->ptr = (pool)->start) | |
| 453 #define poolFinish(pool) ((pool)->start = (pool)->ptr) | |
| 454 #define poolAppendChar(pool, c) \ | |
| 455 (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ | |
| 456 ? 0 \ | |
| 457 : ((*((pool)->ptr)++ = c), 1)) | |
| 458 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
459 struct XML_ParserStruct { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
460 /* The first member must be userData so that the XML_GetUserData |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
461 macro works. */ |
| 21930 | 462 void *m_userData; |
| 463 void *m_handlerArg; | |
| 464 char *m_buffer; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
465 const XML_Memory_Handling_Suite m_mem; |
| 21930 | 466 /* first character to be parsed */ |
| 467 const char *m_bufferPtr; | |
| 468 /* past last character to be parsed */ | |
| 469 char *m_bufferEnd; | |
| 470 /* allocated end of buffer */ | |
| 471 const char *m_bufferLim; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
472 XML_Index m_parseEndByteIndex; |
| 21930 | 473 const char *m_parseEndPtr; |
| 474 XML_Char *m_dataBuf; | |
| 475 XML_Char *m_dataBufEnd; | |
| 476 XML_StartElementHandler m_startElementHandler; | |
| 477 XML_EndElementHandler m_endElementHandler; | |
| 478 XML_CharacterDataHandler m_characterDataHandler; | |
| 479 XML_ProcessingInstructionHandler m_processingInstructionHandler; | |
| 480 XML_CommentHandler m_commentHandler; | |
| 481 XML_StartCdataSectionHandler m_startCdataSectionHandler; | |
| 482 XML_EndCdataSectionHandler m_endCdataSectionHandler; | |
| 483 XML_DefaultHandler m_defaultHandler; | |
| 484 XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; | |
| 485 XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; | |
| 486 XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; | |
| 487 XML_NotationDeclHandler m_notationDeclHandler; | |
| 488 XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; | |
| 489 XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; | |
| 490 XML_NotStandaloneHandler m_notStandaloneHandler; | |
| 491 XML_ExternalEntityRefHandler m_externalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
492 XML_Parser m_externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
493 XML_SkippedEntityHandler m_skippedEntityHandler; |
| 21930 | 494 XML_UnknownEncodingHandler m_unknownEncodingHandler; |
| 495 XML_ElementDeclHandler m_elementDeclHandler; | |
| 496 XML_AttlistDeclHandler m_attlistDeclHandler; | |
| 497 XML_EntityDeclHandler m_entityDeclHandler; | |
| 498 XML_XmlDeclHandler m_xmlDeclHandler; | |
| 499 const ENCODING *m_encoding; | |
| 500 INIT_ENCODING m_initEncoding; | |
| 501 const ENCODING *m_internalEncoding; | |
| 502 const XML_Char *m_protocolEncodingName; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
503 XML_Bool m_ns; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
504 XML_Bool m_ns_triplets; |
| 21930 | 505 void *m_unknownEncodingMem; |
| 506 void *m_unknownEncodingData; | |
| 507 void *m_unknownEncodingHandlerData; | |
| 32911 | 508 void (XMLCALL *m_unknownEncodingRelease)(void *); |
| 21930 | 509 PROLOG_STATE m_prologState; |
| 510 Processor *m_processor; | |
| 511 enum XML_Error m_errorCode; | |
| 512 const char *m_eventPtr; | |
| 513 const char *m_eventEndPtr; | |
| 514 const char *m_positionPtr; | |
| 515 OPEN_INTERNAL_ENTITY *m_openInternalEntities; | |
| 32911 | 516 OPEN_INTERNAL_ENTITY *m_freeInternalEntities; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
517 XML_Bool m_defaultExpandInternalEntities; |
| 21930 | 518 int m_tagLevel; |
| 519 ENTITY *m_declEntity; | |
| 520 const XML_Char *m_doctypeName; | |
| 521 const XML_Char *m_doctypeSysid; | |
| 522 const XML_Char *m_doctypePubid; | |
| 523 const XML_Char *m_declAttributeType; | |
| 524 const XML_Char *m_declNotationName; | |
| 525 const XML_Char *m_declNotationPublicId; | |
| 526 ELEMENT_TYPE *m_declElementType; | |
| 527 ATTRIBUTE_ID *m_declAttributeId; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
528 XML_Bool m_declAttributeIsCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
529 XML_Bool m_declAttributeIsId; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
530 DTD *m_dtd; |
| 21930 | 531 const XML_Char *m_curBase; |
| 532 TAG *m_tagStack; | |
| 533 TAG *m_freeTagList; | |
| 534 BINDING *m_inheritedBindings; | |
| 535 BINDING *m_freeBindingList; | |
| 536 int m_attsSize; | |
| 537 int m_nSpecifiedAtts; | |
| 538 int m_idAttIndex; | |
| 539 ATTRIBUTE *m_atts; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
540 NS_ATT *m_nsAtts; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
541 unsigned long m_nsAttsVersion; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
542 unsigned char m_nsAttsPower; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
543 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
544 XML_AttrInfo *m_attInfo; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
545 #endif |
| 21930 | 546 POSITION m_position; |
| 547 STRING_POOL m_tempPool; | |
| 548 STRING_POOL m_temp2Pool; | |
| 549 char *m_groupConnector; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
550 unsigned int m_groupSize; |
| 21930 | 551 XML_Char m_namespaceSeparator; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
552 XML_Parser m_parentParser; |
| 32911 | 553 XML_ParsingStatus m_parsingStatus; |
| 21930 | 554 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
555 XML_Bool m_isParamEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
556 XML_Bool m_useForeignDTD; |
| 21930 | 557 enum XML_ParamEntityParsing m_paramEntityParsing; |
| 558 #endif | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
559 unsigned long m_hash_secret_salt; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
560 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
561 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
562 #define MALLOC(s) (parser->m_mem.malloc_fcn((s))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
563 #define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
564 #define FREE(p) (parser->m_mem.free_fcn((p))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
565 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
566 #define userData (parser->m_userData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
567 #define handlerArg (parser->m_handlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
568 #define startElementHandler (parser->m_startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
569 #define endElementHandler (parser->m_endElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
570 #define characterDataHandler (parser->m_characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
571 #define processingInstructionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
572 (parser->m_processingInstructionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
573 #define commentHandler (parser->m_commentHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
574 #define startCdataSectionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
575 (parser->m_startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
576 #define endCdataSectionHandler (parser->m_endCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
577 #define defaultHandler (parser->m_defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
578 #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
579 #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
580 #define unparsedEntityDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
581 (parser->m_unparsedEntityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
582 #define notationDeclHandler (parser->m_notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
583 #define startNamespaceDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
584 (parser->m_startNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
585 #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
586 #define notStandaloneHandler (parser->m_notStandaloneHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
587 #define externalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
588 (parser->m_externalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
589 #define externalEntityRefHandlerArg \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
590 (parser->m_externalEntityRefHandlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
591 #define internalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
592 (parser->m_internalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
593 #define skippedEntityHandler (parser->m_skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
594 #define unknownEncodingHandler (parser->m_unknownEncodingHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
595 #define elementDeclHandler (parser->m_elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
596 #define attlistDeclHandler (parser->m_attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
597 #define entityDeclHandler (parser->m_entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
598 #define xmlDeclHandler (parser->m_xmlDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
599 #define encoding (parser->m_encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
600 #define initEncoding (parser->m_initEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
601 #define internalEncoding (parser->m_internalEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
602 #define unknownEncodingMem (parser->m_unknownEncodingMem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
603 #define unknownEncodingData (parser->m_unknownEncodingData) |
| 21930 | 604 #define unknownEncodingHandlerData \ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
605 (parser->m_unknownEncodingHandlerData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
606 #define unknownEncodingRelease (parser->m_unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
607 #define protocolEncodingName (parser->m_protocolEncodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
608 #define ns (parser->m_ns) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
609 #define ns_triplets (parser->m_ns_triplets) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
610 #define prologState (parser->m_prologState) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
611 #define processor (parser->m_processor) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
612 #define errorCode (parser->m_errorCode) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
613 #define eventPtr (parser->m_eventPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
614 #define eventEndPtr (parser->m_eventEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
615 #define positionPtr (parser->m_positionPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
616 #define position (parser->m_position) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
617 #define openInternalEntities (parser->m_openInternalEntities) |
| 32911 | 618 #define freeInternalEntities (parser->m_freeInternalEntities) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
619 #define defaultExpandInternalEntities \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
620 (parser->m_defaultExpandInternalEntities) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
621 #define tagLevel (parser->m_tagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
622 #define buffer (parser->m_buffer) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
623 #define bufferPtr (parser->m_bufferPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
624 #define bufferEnd (parser->m_bufferEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
625 #define parseEndByteIndex (parser->m_parseEndByteIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
626 #define parseEndPtr (parser->m_parseEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
627 #define bufferLim (parser->m_bufferLim) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
628 #define dataBuf (parser->m_dataBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
629 #define dataBufEnd (parser->m_dataBufEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
630 #define _dtd (parser->m_dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
631 #define curBase (parser->m_curBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
632 #define declEntity (parser->m_declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
633 #define doctypeName (parser->m_doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
634 #define doctypeSysid (parser->m_doctypeSysid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
635 #define doctypePubid (parser->m_doctypePubid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
636 #define declAttributeType (parser->m_declAttributeType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
637 #define declNotationName (parser->m_declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
638 #define declNotationPublicId (parser->m_declNotationPublicId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
639 #define declElementType (parser->m_declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
640 #define declAttributeId (parser->m_declAttributeId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
641 #define declAttributeIsCdata (parser->m_declAttributeIsCdata) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
642 #define declAttributeIsId (parser->m_declAttributeIsId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
643 #define freeTagList (parser->m_freeTagList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
644 #define freeBindingList (parser->m_freeBindingList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
645 #define inheritedBindings (parser->m_inheritedBindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
646 #define tagStack (parser->m_tagStack) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
647 #define atts (parser->m_atts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
648 #define attsSize (parser->m_attsSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
649 #define nSpecifiedAtts (parser->m_nSpecifiedAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
650 #define idAttIndex (parser->m_idAttIndex) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
651 #define nsAtts (parser->m_nsAtts) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
652 #define nsAttsVersion (parser->m_nsAttsVersion) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
653 #define nsAttsPower (parser->m_nsAttsPower) |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
654 #define attInfo (parser->m_attInfo) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
655 #define tempPool (parser->m_tempPool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
656 #define temp2Pool (parser->m_temp2Pool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
657 #define groupConnector (parser->m_groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
658 #define groupSize (parser->m_groupSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
659 #define namespaceSeparator (parser->m_namespaceSeparator) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
660 #define parentParser (parser->m_parentParser) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
661 #define ps_parsing (parser->m_parsingStatus.parsing) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
662 #define ps_finalBuffer (parser->m_parsingStatus.finalBuffer) |
| 21930 | 663 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
664 #define isParamEntity (parser->m_isParamEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
665 #define useForeignDTD (parser->m_useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
666 #define paramEntityParsing (parser->m_paramEntityParsing) |
| 21930 | 667 #endif /* XML_DTD */ |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
668 #define hash_secret_salt (parser->m_hash_secret_salt) |
| 21930 | 669 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
670 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
671 XML_ParserCreate(const XML_Char *encodingName) |
| 21930 | 672 { |
| 673 return XML_ParserCreate_MM(encodingName, NULL, NULL); | |
| 674 } | |
| 675 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
676 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
677 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) |
| 21930 | 678 { |
| 679 XML_Char tmp[2]; | |
| 680 *tmp = nsSep; | |
| 681 return XML_ParserCreate_MM(encodingName, NULL, tmp); | |
| 682 } | |
| 683 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
684 static const XML_Char implicitContext[] = { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
685 ASCII_x, ASCII_m, ASCII_l, ASCII_EQUALS, ASCII_h, ASCII_t, ASCII_t, ASCII_p, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
686 ASCII_COLON, ASCII_SLASH, ASCII_SLASH, ASCII_w, ASCII_w, ASCII_w, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
687 ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, ASCII_o, ASCII_r, ASCII_g, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
688 ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, ASCII_SLASH, ASCII_1, ASCII_9, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
689 ASCII_9, ASCII_8, ASCII_SLASH, ASCII_n, ASCII_a, ASCII_m, ASCII_e, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
690 ASCII_s, ASCII_p, ASCII_a, ASCII_c, ASCII_e, '\0' |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
691 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
692 |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
693 static unsigned long |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
694 generate_hash_secret_salt(void) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
695 { |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
696 unsigned int seed = time(NULL) % UINT_MAX; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
697 srand(seed); |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
698 return rand(); |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
699 } |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
700 |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
701 static XML_Bool /* only valid for root parser */ |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
702 startParsing(XML_Parser parser) |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
703 { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
704 /* hash functions must be initialized before setContext() is called */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
705 if (hash_secret_salt == 0) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
706 hash_secret_salt = generate_hash_secret_salt(); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
707 if (ns) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
708 /* implicit context only set for root parser, since child |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
709 parsers (i.e. external entity parsers) will inherit it |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
710 */ |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
711 return setContext(parser, implicitContext); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
712 } |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
713 return XML_TRUE; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
714 } |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
715 |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
716 XML_Parser XMLCALL |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
717 XML_ParserCreate_MM(const XML_Char *encodingName, |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
718 const XML_Memory_Handling_Suite *memsuite, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
719 const XML_Char *nameSep) |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
720 { |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
721 return parserCreate(encodingName, memsuite, nameSep, NULL); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
722 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
723 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
724 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
725 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
726 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
727 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
728 DTD *dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
729 { |
| 21930 | 730 XML_Parser parser; |
| 731 | |
| 732 if (memsuite) { | |
| 733 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
734 parser = (XML_Parser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
735 memsuite->malloc_fcn(sizeof(struct XML_ParserStruct)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
736 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
737 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
738 mtemp->malloc_fcn = memsuite->malloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
739 mtemp->realloc_fcn = memsuite->realloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
740 mtemp->free_fcn = memsuite->free_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
741 } |
| 21930 | 742 } |
| 743 else { | |
| 744 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
745 parser = (XML_Parser)malloc(sizeof(struct XML_ParserStruct)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
746 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
747 mtemp = (XML_Memory_Handling_Suite *)&(parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
748 mtemp->malloc_fcn = malloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
749 mtemp->realloc_fcn = realloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
750 mtemp->free_fcn = free; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
751 } |
| 21930 | 752 } |
| 753 | |
| 754 if (!parser) | |
| 755 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
756 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
757 buffer = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
758 bufferLim = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
759 |
| 21930 | 760 attsSize = INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
761 atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
762 if (atts == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
763 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
764 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
765 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
766 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
767 attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo)); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
768 if (attInfo == NULL) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
769 FREE(atts); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
770 FREE(parser); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
771 return NULL; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
772 } |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
773 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
774 dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
775 if (dataBuf == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
776 FREE(atts); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
777 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
778 FREE(attInfo); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
779 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
780 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
781 return NULL; |
| 21930 | 782 } |
| 783 dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; | |
| 784 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
785 if (dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
786 _dtd = dtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
787 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
788 _dtd = dtdCreate(&parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
789 if (_dtd == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
790 FREE(dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
791 FREE(atts); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
792 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
793 FREE(attInfo); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
794 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
795 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
796 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
797 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
798 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
799 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
800 freeBindingList = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
801 freeTagList = NULL; |
| 32911 | 802 freeInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
803 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
804 groupSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
805 groupConnector = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
806 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
807 unknownEncodingHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
808 unknownEncodingHandlerData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
809 |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
810 namespaceSeparator = ASCII_EXCL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
811 ns = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
812 ns_triplets = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
813 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
814 nsAtts = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
815 nsAttsVersion = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
816 nsAttsPower = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
817 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
818 poolInit(&tempPool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
819 poolInit(&temp2Pool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
820 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
821 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
822 if (encodingName && !protocolEncodingName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
823 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
824 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
825 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
826 |
| 21930 | 827 if (nameSep) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
828 ns = XML_TRUE; |
| 21930 | 829 internalEncoding = XmlGetInternalEncodingNS(); |
| 830 namespaceSeparator = *nameSep; | |
| 831 } | |
| 832 else { | |
| 833 internalEncoding = XmlGetInternalEncoding(); | |
| 834 } | |
| 835 | |
| 836 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
837 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
838 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
839 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
840 parserInit(XML_Parser parser, const XML_Char *encodingName) |
| 21930 | 841 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
842 processor = prologInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
843 XmlPrologStateInit(&prologState); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
844 protocolEncodingName = (encodingName != NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
845 ? poolCopyString(&tempPool, encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
846 : NULL); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
847 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
848 XmlInitEncoding(&initEncoding, &encoding, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
849 userData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
850 handlerArg = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
851 startElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
852 endElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
853 characterDataHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
854 processingInstructionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
855 commentHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
856 startCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
857 endCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
858 defaultHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
859 startDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
860 endDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
861 unparsedEntityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
862 notationDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
863 startNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
864 endNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
865 notStandaloneHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
866 externalEntityRefHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
867 externalEntityRefHandlerArg = parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
868 skippedEntityHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
869 elementDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
870 attlistDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
871 entityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
872 xmlDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
873 bufferPtr = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
874 bufferEnd = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
875 parseEndByteIndex = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
876 parseEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
877 declElementType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
878 declAttributeId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
879 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
880 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
881 doctypeSysid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
882 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
883 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
884 declNotationName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
885 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
886 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
887 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
888 memset(&position, 0, sizeof(POSITION)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
889 errorCode = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
890 eventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
891 eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
892 positionPtr = NULL; |
| 32911 | 893 openInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
894 defaultExpandInternalEntities = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
895 tagLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
896 tagStack = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
897 inheritedBindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
898 nSpecifiedAtts = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
899 unknownEncodingMem = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
900 unknownEncodingRelease = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
901 unknownEncodingData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
902 parentParser = NULL; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
903 ps_parsing = XML_INITIALIZED; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
904 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
905 isParamEntity = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
906 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
907 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
908 #endif |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
909 hash_secret_salt = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
910 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
911 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
912 /* moves list of bindings to freeBindingList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
913 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
914 moveToFreeBindingList(XML_Parser parser, BINDING *bindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
915 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
916 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
917 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
918 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
919 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
920 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
921 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
922 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
923 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
924 XML_Bool XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
925 XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
926 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
927 TAG *tStk; |
| 32911 | 928 OPEN_INTERNAL_ENTITY *openEntityList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
929 if (parentParser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
930 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
931 /* move tagStack to freeTagList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
932 tStk = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
933 while (tStk) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
934 TAG *tag = tStk; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
935 tStk = tStk->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
936 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
937 moveToFreeBindingList(parser, tag->bindings); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
938 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
939 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
940 } |
| 32911 | 941 /* move openInternalEntities to freeInternalEntities */ |
| 942 openEntityList = openInternalEntities; | |
| 943 while (openEntityList) { | |
| 944 OPEN_INTERNAL_ENTITY *openEntity = openEntityList; | |
| 945 openEntityList = openEntity->next; | |
| 946 openEntity->next = freeInternalEntities; | |
| 947 freeInternalEntities = openEntity; | |
| 948 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
949 moveToFreeBindingList(parser, inheritedBindings); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
950 FREE(unknownEncodingMem); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
951 if (unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
952 unknownEncodingRelease(unknownEncodingData); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
953 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
954 poolClear(&temp2Pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
955 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
956 dtdReset(_dtd, &parser->m_mem); |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
957 return XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
958 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
959 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
960 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
961 XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
962 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
963 /* Block after XML_Parse()/XML_ParseBuffer() has been called. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
964 XXX There's no way for the caller to determine which of the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
965 XXX possible error cases caused the XML_STATUS_ERROR return. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
966 */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
967 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
968 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
969 if (encodingName == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
970 protocolEncodingName = NULL; |
| 21930 | 971 else { |
| 972 protocolEncodingName = poolCopyString(&tempPool, encodingName); | |
| 973 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
974 return XML_STATUS_ERROR; |
| 21930 | 975 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
976 return XML_STATUS_OK; |
| 21930 | 977 } |
| 978 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
979 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
980 XML_ExternalEntityParserCreate(XML_Parser oldParser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
981 const XML_Char *context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
982 const XML_Char *encodingName) |
| 21930 | 983 { |
| 984 XML_Parser parser = oldParser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
985 DTD *newDtd = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
986 DTD *oldDtd = _dtd; |
| 21930 | 987 XML_StartElementHandler oldStartElementHandler = startElementHandler; |
| 988 XML_EndElementHandler oldEndElementHandler = endElementHandler; | |
| 989 XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
990 XML_ProcessingInstructionHandler oldProcessingInstructionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
991 = processingInstructionHandler; |
| 21930 | 992 XML_CommentHandler oldCommentHandler = commentHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
993 XML_StartCdataSectionHandler oldStartCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
994 = startCdataSectionHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
995 XML_EndCdataSectionHandler oldEndCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
996 = endCdataSectionHandler; |
| 21930 | 997 XML_DefaultHandler oldDefaultHandler = defaultHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
998 XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
999 = unparsedEntityDeclHandler; |
| 21930 | 1000 XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1001 XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1002 = startNamespaceDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1003 XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1004 = endNamespaceDeclHandler; |
| 21930 | 1005 XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1006 XML_ExternalEntityRefHandler oldExternalEntityRefHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1007 = externalEntityRefHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1008 XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1009 XML_UnknownEncodingHandler oldUnknownEncodingHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1010 = unknownEncodingHandler; |
| 21930 | 1011 XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; |
| 1012 XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; | |
| 1013 XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; | |
| 1014 XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; | |
| 1015 ELEMENT_TYPE * oldDeclElementType = declElementType; | |
| 1016 | |
| 1017 void *oldUserData = userData; | |
| 1018 void *oldHandlerArg = handlerArg; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1019 XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1020 XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1021 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1022 enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1023 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1024 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1025 XML_Bool oldns_triplets = ns_triplets; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1026 /* Note that the new parser shares the same hash secret as the old |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1027 parser, so that dtdCopy and copyEntityTable can lookup values |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1028 from hash tables associated with either parser without us having |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1029 to worry which hash secrets each table has. |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1030 */ |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1031 unsigned long oldhash_secret_salt = hash_secret_salt; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1032 |
| 21930 | 1033 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1034 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1035 newDtd = oldDtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1036 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1037 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1038 /* Note that the magical uses of the pre-processor to make field |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1039 access look more like C++ require that `parser' be overwritten |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1040 here. This makes this function more painful to follow than it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1041 would be otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1042 */ |
| 21930 | 1043 if (ns) { |
| 1044 XML_Char tmp[2]; | |
| 1045 *tmp = namespaceSeparator; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1046 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); |
| 21930 | 1047 } |
| 1048 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1049 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); |
| 21930 | 1050 } |
| 1051 | |
| 1052 if (!parser) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1053 return NULL; |
| 21930 | 1054 |
| 1055 startElementHandler = oldStartElementHandler; | |
| 1056 endElementHandler = oldEndElementHandler; | |
| 1057 characterDataHandler = oldCharacterDataHandler; | |
| 1058 processingInstructionHandler = oldProcessingInstructionHandler; | |
| 1059 commentHandler = oldCommentHandler; | |
| 1060 startCdataSectionHandler = oldStartCdataSectionHandler; | |
| 1061 endCdataSectionHandler = oldEndCdataSectionHandler; | |
| 1062 defaultHandler = oldDefaultHandler; | |
| 1063 unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; | |
| 1064 notationDeclHandler = oldNotationDeclHandler; | |
| 1065 startNamespaceDeclHandler = oldStartNamespaceDeclHandler; | |
| 1066 endNamespaceDeclHandler = oldEndNamespaceDeclHandler; | |
| 1067 notStandaloneHandler = oldNotStandaloneHandler; | |
| 1068 externalEntityRefHandler = oldExternalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1069 skippedEntityHandler = oldSkippedEntityHandler; |
| 21930 | 1070 unknownEncodingHandler = oldUnknownEncodingHandler; |
| 1071 elementDeclHandler = oldElementDeclHandler; | |
| 1072 attlistDeclHandler = oldAttlistDeclHandler; | |
| 1073 entityDeclHandler = oldEntityDeclHandler; | |
| 1074 xmlDeclHandler = oldXmlDeclHandler; | |
| 1075 declElementType = oldDeclElementType; | |
| 1076 userData = oldUserData; | |
| 1077 if (oldUserData == oldHandlerArg) | |
| 1078 handlerArg = userData; | |
| 1079 else | |
| 1080 handlerArg = parser; | |
| 1081 if (oldExternalEntityRefHandlerArg != oldParser) | |
| 1082 externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; | |
| 1083 defaultExpandInternalEntities = oldDefaultExpandInternalEntities; | |
| 1084 ns_triplets = oldns_triplets; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1085 hash_secret_salt = oldhash_secret_salt; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1086 parentParser = oldParser; |
| 21930 | 1087 #ifdef XML_DTD |
| 1088 paramEntityParsing = oldParamEntityParsing; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1089 prologState.inEntityValue = oldInEntityValue; |
| 21930 | 1090 if (context) { |
| 1091 #endif /* XML_DTD */ | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1092 if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1093 || !setContext(parser, context)) { |
| 21930 | 1094 XML_ParserFree(parser); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1095 return NULL; |
| 21930 | 1096 } |
| 1097 processor = externalEntityInitProcessor; | |
| 1098 #ifdef XML_DTD | |
| 1099 } | |
| 1100 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1101 /* The DTD instance referenced by _dtd is shared between the document's |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1102 root parser and external PE parsers, therefore one does not need to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1103 call setContext. In addition, one also *must* not call setContext, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1104 because this would overwrite existing prefix->binding pointers in |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1105 _dtd with ones that get destroyed with the external PE parser. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1106 This would leave those prefixes with dangling pointers. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1107 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1108 isParamEntity = XML_TRUE; |
| 21930 | 1109 XmlPrologStateInitExternalEntity(&prologState); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1110 processor = externalParEntInitProcessor; |
| 21930 | 1111 } |
| 1112 #endif /* XML_DTD */ | |
| 1113 return parser; | |
| 1114 } | |
| 1115 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1116 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1117 destroyBindings(BINDING *bindings, XML_Parser parser) |
| 21930 | 1118 { |
| 1119 for (;;) { | |
| 1120 BINDING *b = bindings; | |
| 1121 if (!b) | |
| 1122 break; | |
| 1123 bindings = b->nextTagBinding; | |
| 1124 FREE(b->uri); | |
| 1125 FREE(b); | |
| 1126 } | |
| 1127 } | |
| 1128 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1129 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1130 XML_ParserFree(XML_Parser parser) |
| 21930 | 1131 { |
| 32911 | 1132 TAG *tagList; |
| 1133 OPEN_INTERNAL_ENTITY *entityList; | |
| 1134 if (parser == NULL) | |
| 1135 return; | |
| 1136 /* free tagStack and freeTagList */ | |
| 1137 tagList = tagStack; | |
| 21930 | 1138 for (;;) { |
| 1139 TAG *p; | |
| 32911 | 1140 if (tagList == NULL) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1141 if (freeTagList == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1142 break; |
| 32911 | 1143 tagList = freeTagList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1144 freeTagList = NULL; |
| 21930 | 1145 } |
| 32911 | 1146 p = tagList; |
| 1147 tagList = tagList->parent; | |
| 21930 | 1148 FREE(p->buf); |
| 1149 destroyBindings(p->bindings, parser); | |
| 1150 FREE(p); | |
| 1151 } | |
| 32911 | 1152 /* free openInternalEntities and freeInternalEntities */ |
| 1153 entityList = openInternalEntities; | |
| 1154 for (;;) { | |
| 1155 OPEN_INTERNAL_ENTITY *openEntity; | |
| 1156 if (entityList == NULL) { | |
| 1157 if (freeInternalEntities == NULL) | |
| 1158 break; | |
| 1159 entityList = freeInternalEntities; | |
| 1160 freeInternalEntities = NULL; | |
| 1161 } | |
| 1162 openEntity = entityList; | |
| 1163 entityList = entityList->next; | |
| 1164 FREE(openEntity); | |
| 1165 } | |
| 1166 | |
| 21930 | 1167 destroyBindings(freeBindingList, parser); |
| 1168 destroyBindings(inheritedBindings, parser); | |
| 1169 poolDestroy(&tempPool); | |
| 1170 poolDestroy(&temp2Pool); | |
| 1171 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1172 /* external parameter entity parsers share the DTD structure |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1173 parser->m_dtd with the root parser, so we must not destroy it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1174 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1175 if (!isParamEntity && _dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1176 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1177 if (_dtd) |
| 21930 | 1178 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1179 dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); |
| 21930 | 1180 FREE((void *)atts); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1181 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1182 FREE((void *)attInfo); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1183 #endif |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1184 FREE(groupConnector); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1185 FREE(buffer); |
| 21930 | 1186 FREE(dataBuf); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1187 FREE(nsAtts); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1188 FREE(unknownEncodingMem); |
| 21930 | 1189 if (unknownEncodingRelease) |
| 1190 unknownEncodingRelease(unknownEncodingData); | |
| 1191 FREE(parser); | |
| 1192 } | |
| 1193 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1194 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1195 XML_UseParserAsHandlerArg(XML_Parser parser) |
| 21930 | 1196 { |
| 1197 handlerArg = parser; | |
| 1198 } | |
| 1199 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1200 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1201 XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1202 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1203 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1204 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1205 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1206 return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1207 useForeignDTD = useDTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1208 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1209 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1210 return XML_ERROR_FEATURE_REQUIRES_XML_DTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1211 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1212 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1213 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1214 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1215 XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1216 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1217 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1218 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1219 return; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1220 ns_triplets = do_nst ? XML_TRUE : XML_FALSE; |
| 21930 | 1221 } |
| 1222 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1223 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1224 XML_SetUserData(XML_Parser parser, void *p) |
| 21930 | 1225 { |
| 1226 if (handlerArg == userData) | |
| 1227 handlerArg = userData = p; | |
| 1228 else | |
| 1229 userData = p; | |
| 1230 } | |
| 1231 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1232 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1233 XML_SetBase(XML_Parser parser, const XML_Char *p) |
| 21930 | 1234 { |
| 1235 if (p) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1236 p = poolCopyString(&_dtd->pool, p); |
| 21930 | 1237 if (!p) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1238 return XML_STATUS_ERROR; |
| 21930 | 1239 curBase = p; |
| 1240 } | |
| 1241 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1242 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1243 return XML_STATUS_OK; |
| 21930 | 1244 } |
| 1245 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1246 const XML_Char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1247 XML_GetBase(XML_Parser parser) |
| 21930 | 1248 { |
| 1249 return curBase; | |
| 1250 } | |
| 1251 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1252 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1253 XML_GetSpecifiedAttributeCount(XML_Parser parser) |
| 21930 | 1254 { |
| 1255 return nSpecifiedAtts; | |
| 1256 } | |
| 1257 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1258 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1259 XML_GetIdAttributeIndex(XML_Parser parser) |
| 21930 | 1260 { |
| 1261 return idAttIndex; | |
| 1262 } | |
| 1263 | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1264 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1265 const XML_AttrInfo * XMLCALL |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1266 XML_GetAttributeInfo(XML_Parser parser) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1267 { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1268 return attInfo; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1269 } |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1270 #endif |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1271 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1272 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1273 XML_SetElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1274 XML_StartElementHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1275 XML_EndElementHandler end) |
| 21930 | 1276 { |
| 1277 startElementHandler = start; | |
| 1278 endElementHandler = end; | |
| 1279 } | |
| 1280 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1281 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1282 XML_SetStartElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1283 XML_StartElementHandler start) { |
| 21930 | 1284 startElementHandler = start; |
| 1285 } | |
| 1286 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1287 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1288 XML_SetEndElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1289 XML_EndElementHandler end) { |
| 21930 | 1290 endElementHandler = end; |
| 1291 } | |
| 1292 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1293 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1294 XML_SetCharacterDataHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1295 XML_CharacterDataHandler handler) |
| 21930 | 1296 { |
| 1297 characterDataHandler = handler; | |
| 1298 } | |
| 1299 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1300 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1301 XML_SetProcessingInstructionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1302 XML_ProcessingInstructionHandler handler) |
| 21930 | 1303 { |
| 1304 processingInstructionHandler = handler; | |
| 1305 } | |
| 1306 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1307 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1308 XML_SetCommentHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1309 XML_CommentHandler handler) |
| 21930 | 1310 { |
| 1311 commentHandler = handler; | |
| 1312 } | |
| 1313 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1314 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1315 XML_SetCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1316 XML_StartCdataSectionHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1317 XML_EndCdataSectionHandler end) |
| 21930 | 1318 { |
| 1319 startCdataSectionHandler = start; | |
| 1320 endCdataSectionHandler = end; | |
| 1321 } | |
| 1322 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1323 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1324 XML_SetStartCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1325 XML_StartCdataSectionHandler start) { |
| 21930 | 1326 startCdataSectionHandler = start; |
| 1327 } | |
| 1328 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1329 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1330 XML_SetEndCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1331 XML_EndCdataSectionHandler end) { |
| 21930 | 1332 endCdataSectionHandler = end; |
| 1333 } | |
| 1334 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1335 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1336 XML_SetDefaultHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1337 XML_DefaultHandler handler) |
| 21930 | 1338 { |
| 1339 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1340 defaultExpandInternalEntities = XML_FALSE; |
| 21930 | 1341 } |
| 1342 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1343 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1344 XML_SetDefaultHandlerExpand(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1345 XML_DefaultHandler handler) |
| 21930 | 1346 { |
| 1347 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1348 defaultExpandInternalEntities = XML_TRUE; |
| 21930 | 1349 } |
| 1350 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1351 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1352 XML_SetDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1353 XML_StartDoctypeDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1354 XML_EndDoctypeDeclHandler end) |
| 21930 | 1355 { |
| 1356 startDoctypeDeclHandler = start; | |
| 1357 endDoctypeDeclHandler = end; | |
| 1358 } | |
| 1359 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1360 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1361 XML_SetStartDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1362 XML_StartDoctypeDeclHandler start) { |
| 21930 | 1363 startDoctypeDeclHandler = start; |
| 1364 } | |
| 1365 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1366 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1367 XML_SetEndDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1368 XML_EndDoctypeDeclHandler end) { |
| 21930 | 1369 endDoctypeDeclHandler = end; |
| 1370 } | |
| 1371 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1372 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1373 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1374 XML_UnparsedEntityDeclHandler handler) |
| 21930 | 1375 { |
| 1376 unparsedEntityDeclHandler = handler; | |
| 1377 } | |
| 1378 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1379 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1380 XML_SetNotationDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1381 XML_NotationDeclHandler handler) |
| 21930 | 1382 { |
| 1383 notationDeclHandler = handler; | |
| 1384 } | |
| 1385 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1386 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1387 XML_SetNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1388 XML_StartNamespaceDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1389 XML_EndNamespaceDeclHandler end) |
| 21930 | 1390 { |
| 1391 startNamespaceDeclHandler = start; | |
| 1392 endNamespaceDeclHandler = end; | |
| 1393 } | |
| 1394 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1395 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1396 XML_SetStartNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1397 XML_StartNamespaceDeclHandler start) { |
| 21930 | 1398 startNamespaceDeclHandler = start; |
| 1399 } | |
| 1400 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1401 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1402 XML_SetEndNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1403 XML_EndNamespaceDeclHandler end) { |
| 21930 | 1404 endNamespaceDeclHandler = end; |
| 1405 } | |
| 1406 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1407 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1408 XML_SetNotStandaloneHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1409 XML_NotStandaloneHandler handler) |
| 21930 | 1410 { |
| 1411 notStandaloneHandler = handler; | |
| 1412 } | |
| 1413 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1414 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1415 XML_SetExternalEntityRefHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1416 XML_ExternalEntityRefHandler handler) |
| 21930 | 1417 { |
| 1418 externalEntityRefHandler = handler; | |
| 1419 } | |
| 1420 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1421 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1422 XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) |
| 21930 | 1423 { |
| 1424 if (arg) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1425 externalEntityRefHandlerArg = (XML_Parser)arg; |
| 21930 | 1426 else |
| 1427 externalEntityRefHandlerArg = parser; | |
| 1428 } | |
| 1429 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1430 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1431 XML_SetSkippedEntityHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1432 XML_SkippedEntityHandler handler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1433 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1434 skippedEntityHandler = handler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1435 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1436 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1437 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1438 XML_SetUnknownEncodingHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1439 XML_UnknownEncodingHandler handler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1440 void *data) |
| 21930 | 1441 { |
| 1442 unknownEncodingHandler = handler; | |
| 1443 unknownEncodingHandlerData = data; | |
| 1444 } | |
| 1445 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1446 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1447 XML_SetElementDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1448 XML_ElementDeclHandler eldecl) |
| 21930 | 1449 { |
| 1450 elementDeclHandler = eldecl; | |
| 1451 } | |
| 1452 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1453 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1454 XML_SetAttlistDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1455 XML_AttlistDeclHandler attdecl) |
| 21930 | 1456 { |
| 1457 attlistDeclHandler = attdecl; | |
| 1458 } | |
| 1459 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1460 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1461 XML_SetEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1462 XML_EntityDeclHandler handler) |
| 21930 | 1463 { |
| 1464 entityDeclHandler = handler; | |
| 1465 } | |
| 1466 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1467 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1468 XML_SetXmlDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1469 XML_XmlDeclHandler handler) { |
| 21930 | 1470 xmlDeclHandler = handler; |
| 1471 } | |
| 1472 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1473 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1474 XML_SetParamEntityParsing(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1475 enum XML_ParamEntityParsing peParsing) |
| 21930 | 1476 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1477 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1478 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1479 return 0; |
| 21930 | 1480 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1481 paramEntityParsing = peParsing; |
| 21930 | 1482 return 1; |
| 1483 #else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1484 return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; |
| 21930 | 1485 #endif |
| 1486 } | |
| 1487 | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1488 int XMLCALL |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1489 XML_SetHashSalt(XML_Parser parser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1490 unsigned long hash_salt) |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1491 { |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1492 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1493 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1494 return 0; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1495 hash_secret_salt = hash_salt; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1496 return 1; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1497 } |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1498 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1499 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1500 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) |
| 21930 | 1501 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1502 switch (ps_parsing) { |
| 32911 | 1503 case XML_SUSPENDED: |
| 1504 errorCode = XML_ERROR_SUSPENDED; | |
| 1505 return XML_STATUS_ERROR; | |
| 1506 case XML_FINISHED: | |
| 1507 errorCode = XML_ERROR_FINISHED; | |
| 1508 return XML_STATUS_ERROR; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1509 case XML_INITIALIZED: |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1510 if (parentParser == NULL && !startParsing(parser)) { |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1511 errorCode = XML_ERROR_NO_MEMORY; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1512 return XML_STATUS_ERROR; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1513 } |
| 32911 | 1514 default: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1515 ps_parsing = XML_PARSING; |
| 32911 | 1516 } |
| 1517 | |
| 21930 | 1518 if (len == 0) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1519 ps_finalBuffer = (XML_Bool)isFinal; |
| 21930 | 1520 if (!isFinal) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1521 return XML_STATUS_OK; |
| 21930 | 1522 positionPtr = bufferPtr; |
| 32911 | 1523 parseEndPtr = bufferEnd; |
| 1524 | |
| 1525 /* If data are left over from last buffer, and we now know that these | |
| 1526 data are the final chunk of input, then we have to check them again | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1527 to detect errors based on that fact. |
| 32911 | 1528 */ |
| 1529 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1530 | |
| 1531 if (errorCode == XML_ERROR_NONE) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1532 switch (ps_parsing) { |
| 32911 | 1533 case XML_SUSPENDED: |
| 1534 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1535 positionPtr = bufferPtr; | |
| 1536 return XML_STATUS_SUSPENDED; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1537 case XML_INITIALIZED: |
| 32911 | 1538 case XML_PARSING: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1539 ps_parsing = XML_FINISHED; |
| 32911 | 1540 /* fall through */ |
| 1541 default: | |
| 1542 return XML_STATUS_OK; | |
| 1543 } | |
| 1544 } | |
| 21930 | 1545 eventEndPtr = eventPtr; |
| 1546 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1547 return XML_STATUS_ERROR; |
| 21930 | 1548 } |
| 1549 #ifndef XML_CONTEXT_BYTES | |
| 1550 else if (bufferPtr == bufferEnd) { | |
| 1551 const char *end; | |
| 1552 int nLeftOver; | |
| 32911 | 1553 enum XML_Error result; |
| 21930 | 1554 parseEndByteIndex += len; |
| 1555 positionPtr = s; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1556 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1557 |
| 21930 | 1558 errorCode = processor(parser, s, parseEndPtr = s + len, &end); |
| 32911 | 1559 |
| 21930 | 1560 if (errorCode != XML_ERROR_NONE) { |
| 1561 eventEndPtr = eventPtr; | |
| 1562 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1563 return XML_STATUS_ERROR; |
| 21930 | 1564 } |
| 32911 | 1565 else { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1566 switch (ps_parsing) { |
| 32911 | 1567 case XML_SUSPENDED: |
| 1568 result = XML_STATUS_SUSPENDED; | |
| 1569 break; | |
| 1570 case XML_INITIALIZED: | |
| 1571 case XML_PARSING: | |
| 1572 if (isFinal) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1573 ps_parsing = XML_FINISHED; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1574 return XML_STATUS_OK; |
| 32911 | 1575 } |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1576 /* fall through */ |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1577 default: |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1578 result = XML_STATUS_OK; |
| 32911 | 1579 } |
| 1580 } | |
| 1581 | |
| 21930 | 1582 XmlUpdatePosition(encoding, positionPtr, end, &position); |
| 1583 nLeftOver = s + len - end; | |
| 1584 if (nLeftOver) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1585 if (buffer == NULL || nLeftOver > bufferLim - buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1586 /* FIXME avoid integer overflow */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1587 char *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1588 temp = (buffer == NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1589 ? (char *)MALLOC(len * 2) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1590 : (char *)REALLOC(buffer, len * 2)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1591 if (temp == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1592 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1593 eventPtr = eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1594 processor = errorProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1595 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1596 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1597 buffer = temp; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1598 bufferLim = buffer + len * 2; |
| 21930 | 1599 } |
| 1600 memcpy(buffer, end, nLeftOver); | |
| 1601 } | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1602 bufferPtr = buffer; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1603 bufferEnd = buffer + nLeftOver; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1604 positionPtr = bufferPtr; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1605 parseEndPtr = bufferEnd; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1606 eventPtr = bufferPtr; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1607 eventEndPtr = bufferPtr; |
| 32911 | 1608 return result; |
| 21930 | 1609 } |
| 1610 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1611 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1612 void *buff = XML_GetBuffer(parser, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1613 if (buff == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1614 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1615 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1616 memcpy(buff, s, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1617 return XML_ParseBuffer(parser, len, isFinal); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1618 } |
| 21930 | 1619 } |
| 1620 } | |
| 1621 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1622 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1623 XML_ParseBuffer(XML_Parser parser, int len, int isFinal) |
| 21930 | 1624 { |
| 32911 | 1625 const char *start; |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1626 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1627 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1628 switch (ps_parsing) { |
| 32911 | 1629 case XML_SUSPENDED: |
| 1630 errorCode = XML_ERROR_SUSPENDED; | |
| 1631 return XML_STATUS_ERROR; | |
| 1632 case XML_FINISHED: | |
| 1633 errorCode = XML_ERROR_FINISHED; | |
| 1634 return XML_STATUS_ERROR; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1635 case XML_INITIALIZED: |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1636 if (parentParser == NULL && !startParsing(parser)) { |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1637 errorCode = XML_ERROR_NO_MEMORY; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1638 return XML_STATUS_ERROR; |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
1639 } |
| 32911 | 1640 default: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1641 ps_parsing = XML_PARSING; |
| 32911 | 1642 } |
| 1643 | |
| 1644 start = bufferPtr; | |
| 21930 | 1645 positionPtr = start; |
| 1646 bufferEnd += len; | |
| 32911 | 1647 parseEndPtr = bufferEnd; |
| 21930 | 1648 parseEndByteIndex += len; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1649 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1650 |
| 1651 errorCode = processor(parser, start, parseEndPtr, &bufferPtr); | |
| 1652 | |
| 1653 if (errorCode != XML_ERROR_NONE) { | |
| 21930 | 1654 eventEndPtr = eventPtr; |
| 1655 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1656 return XML_STATUS_ERROR; |
| 21930 | 1657 } |
| 32911 | 1658 else { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1659 switch (ps_parsing) { |
| 32911 | 1660 case XML_SUSPENDED: |
| 1661 result = XML_STATUS_SUSPENDED; | |
| 1662 break; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1663 case XML_INITIALIZED: |
| 32911 | 1664 case XML_PARSING: |
| 1665 if (isFinal) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1666 ps_parsing = XML_FINISHED; |
| 32911 | 1667 return result; |
| 1668 } | |
| 1669 default: ; /* should not happen */ | |
| 1670 } | |
| 1671 } | |
| 1672 | |
| 1673 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1674 positionPtr = bufferPtr; | |
| 1675 return result; | |
| 21930 | 1676 } |
| 1677 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1678 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1679 XML_GetBuffer(XML_Parser parser, int len) |
| 21930 | 1680 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1681 switch (ps_parsing) { |
| 32911 | 1682 case XML_SUSPENDED: |
| 1683 errorCode = XML_ERROR_SUSPENDED; | |
| 1684 return NULL; | |
| 1685 case XML_FINISHED: | |
| 1686 errorCode = XML_ERROR_FINISHED; | |
| 1687 return NULL; | |
| 1688 default: ; | |
| 1689 } | |
| 1690 | |
| 21930 | 1691 if (len > bufferLim - bufferEnd) { |
| 1692 /* FIXME avoid integer overflow */ | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1693 int neededSize = len + (int)(bufferEnd - bufferPtr); |
| 21930 | 1694 #ifdef XML_CONTEXT_BYTES |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1695 int keep = (int)(bufferPtr - buffer); |
| 21930 | 1696 |
| 1697 if (keep > XML_CONTEXT_BYTES) | |
| 1698 keep = XML_CONTEXT_BYTES; | |
| 1699 neededSize += keep; | |
| 1700 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1701 if (neededSize <= bufferLim - buffer) { | |
| 1702 #ifdef XML_CONTEXT_BYTES | |
| 1703 if (keep < bufferPtr - buffer) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1704 int offset = (int)(bufferPtr - buffer) - keep; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1705 memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1706 bufferEnd -= offset; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1707 bufferPtr -= offset; |
| 21930 | 1708 } |
| 1709 #else | |
| 1710 memmove(buffer, bufferPtr, bufferEnd - bufferPtr); | |
| 1711 bufferEnd = buffer + (bufferEnd - bufferPtr); | |
| 1712 bufferPtr = buffer; | |
| 1713 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1714 } | |
| 1715 else { | |
| 1716 char *newBuf; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1717 int bufferSize = (int)(bufferLim - bufferPtr); |
| 21930 | 1718 if (bufferSize == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1719 bufferSize = INIT_BUFFER_SIZE; |
| 21930 | 1720 do { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1721 bufferSize *= 2; |
| 21930 | 1722 } while (bufferSize < neededSize); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1723 newBuf = (char *)MALLOC(bufferSize); |
| 21930 | 1724 if (newBuf == 0) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1725 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1726 return NULL; |
| 21930 | 1727 } |
| 1728 bufferLim = newBuf + bufferSize; | |
| 1729 #ifdef XML_CONTEXT_BYTES | |
| 1730 if (bufferPtr) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1731 int keep = (int)(bufferPtr - buffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1732 if (keep > XML_CONTEXT_BYTES) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1733 keep = XML_CONTEXT_BYTES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1734 memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1735 FREE(buffer); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1736 buffer = newBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1737 bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1738 bufferPtr = buffer + keep; |
| 21930 | 1739 } |
| 1740 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1741 bufferEnd = newBuf + (bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1742 bufferPtr = buffer = newBuf; |
| 21930 | 1743 } |
| 1744 #else | |
| 1745 if (bufferPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1746 memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1747 FREE(buffer); |
| 21930 | 1748 } |
| 1749 bufferEnd = newBuf + (bufferEnd - bufferPtr); | |
| 1750 bufferPtr = buffer = newBuf; | |
| 1751 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1752 } | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1753 eventPtr = eventEndPtr = NULL; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1754 positionPtr = NULL; |
| 21930 | 1755 } |
| 1756 return bufferEnd; | |
| 1757 } | |
| 1758 | |
| 32911 | 1759 enum XML_Status XMLCALL |
| 1760 XML_StopParser(XML_Parser parser, XML_Bool resumable) | |
| 1761 { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1762 switch (ps_parsing) { |
| 32911 | 1763 case XML_SUSPENDED: |
| 1764 if (resumable) { | |
| 1765 errorCode = XML_ERROR_SUSPENDED; | |
| 1766 return XML_STATUS_ERROR; | |
| 1767 } | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1768 ps_parsing = XML_FINISHED; |
| 32911 | 1769 break; |
| 1770 case XML_FINISHED: | |
| 1771 errorCode = XML_ERROR_FINISHED; | |
| 1772 return XML_STATUS_ERROR; | |
| 1773 default: | |
| 1774 if (resumable) { | |
| 1775 #ifdef XML_DTD | |
| 1776 if (isParamEntity) { | |
| 1777 errorCode = XML_ERROR_SUSPEND_PE; | |
| 1778 return XML_STATUS_ERROR; | |
| 1779 } | |
| 1780 #endif | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1781 ps_parsing = XML_SUSPENDED; |
| 32911 | 1782 } |
| 1783 else | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1784 ps_parsing = XML_FINISHED; |
| 32911 | 1785 } |
| 1786 return XML_STATUS_OK; | |
| 1787 } | |
| 1788 | |
| 1789 enum XML_Status XMLCALL | |
| 1790 XML_ResumeParser(XML_Parser parser) | |
| 1791 { | |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1792 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1793 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1794 if (ps_parsing != XML_SUSPENDED) { |
| 32911 | 1795 errorCode = XML_ERROR_NOT_SUSPENDED; |
| 1796 return XML_STATUS_ERROR; | |
| 1797 } | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1798 ps_parsing = XML_PARSING; |
| 32911 | 1799 |
| 1800 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1801 | |
| 1802 if (errorCode != XML_ERROR_NONE) { | |
| 1803 eventEndPtr = eventPtr; | |
| 1804 processor = errorProcessor; | |
| 1805 return XML_STATUS_ERROR; | |
| 1806 } | |
| 1807 else { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1808 switch (ps_parsing) { |
| 32911 | 1809 case XML_SUSPENDED: |
| 1810 result = XML_STATUS_SUSPENDED; | |
| 1811 break; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
1812 case XML_INITIALIZED: |
| 32911 | 1813 case XML_PARSING: |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1814 if (ps_finalBuffer) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1815 ps_parsing = XML_FINISHED; |
| 32911 | 1816 return result; |
| 1817 } | |
| 1818 default: ; | |
| 1819 } | |
| 1820 } | |
| 1821 | |
| 1822 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1823 positionPtr = bufferPtr; | |
| 1824 return result; | |
| 1825 } | |
| 1826 | |
| 1827 void XMLCALL | |
| 1828 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) | |
| 1829 { | |
| 1830 assert(status != NULL); | |
| 1831 *status = parser->m_parsingStatus; | |
| 1832 } | |
| 1833 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1834 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1835 XML_GetErrorCode(XML_Parser parser) |
| 21930 | 1836 { |
| 1837 return errorCode; | |
| 1838 } | |
| 1839 | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1840 XML_Index XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1841 XML_GetCurrentByteIndex(XML_Parser parser) |
| 21930 | 1842 { |
| 1843 if (eventPtr) | |
| 1844 return parseEndByteIndex - (parseEndPtr - eventPtr); | |
| 1845 return -1; | |
| 1846 } | |
| 1847 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1848 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1849 XML_GetCurrentByteCount(XML_Parser parser) |
| 21930 | 1850 { |
| 1851 if (eventEndPtr && eventPtr) | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1852 return (int)(eventEndPtr - eventPtr); |
| 21930 | 1853 return 0; |
| 1854 } | |
| 1855 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1856 const char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1857 XML_GetInputContext(XML_Parser parser, int *offset, int *size) |
| 21930 | 1858 { |
| 1859 #ifdef XML_CONTEXT_BYTES | |
| 1860 if (eventPtr && buffer) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1861 *offset = (int)(eventPtr - buffer); |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1862 *size = (int)(bufferEnd - buffer); |
| 21930 | 1863 return buffer; |
| 1864 } | |
| 1865 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1866 return (char *) 0; | |
| 1867 } | |
| 1868 | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1869 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1870 XML_GetCurrentLineNumber(XML_Parser parser) |
| 21930 | 1871 { |
| 32911 | 1872 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1873 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1874 positionPtr = eventPtr; | |
| 1875 } | |
| 1876 return position.lineNumber + 1; | |
| 1877 } | |
| 1878 | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1879 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1880 XML_GetCurrentColumnNumber(XML_Parser parser) |
| 21930 | 1881 { |
| 32911 | 1882 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1883 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1884 positionPtr = eventPtr; | |
| 1885 } | |
| 1886 return position.columnNumber; | |
| 1887 } | |
| 1888 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1889 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1890 XML_FreeContentModel(XML_Parser parser, XML_Content *model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1891 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1892 FREE(model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1893 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1894 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1895 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1896 XML_MemMalloc(XML_Parser parser, size_t size) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1897 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1898 return MALLOC(size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1899 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1900 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1901 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1902 XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1903 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1904 return REALLOC(ptr, size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1905 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1906 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1907 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1908 XML_MemFree(XML_Parser parser, void *ptr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1909 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1910 FREE(ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1911 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1912 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1913 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1914 XML_DefaultCurrent(XML_Parser parser) |
| 21930 | 1915 { |
| 1916 if (defaultHandler) { | |
| 1917 if (openInternalEntities) | |
| 1918 reportDefault(parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1919 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1920 openInternalEntities->internalEventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1921 openInternalEntities->internalEventEndPtr); |
| 21930 | 1922 else |
| 1923 reportDefault(parser, encoding, eventPtr, eventEndPtr); | |
| 1924 } | |
| 1925 } | |
| 1926 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1927 const XML_LChar * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1928 XML_ErrorString(enum XML_Error code) |
| 21930 | 1929 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1930 static const XML_LChar* const message[] = { |
| 21930 | 1931 0, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1932 XML_L("out of memory"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1933 XML_L("syntax error"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1934 XML_L("no element found"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1935 XML_L("not well-formed (invalid token)"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1936 XML_L("unclosed token"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1937 XML_L("partial character"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1938 XML_L("mismatched tag"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1939 XML_L("duplicate attribute"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1940 XML_L("junk after document element"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1941 XML_L("illegal parameter entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1942 XML_L("undefined entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1943 XML_L("recursive entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1944 XML_L("asynchronous entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1945 XML_L("reference to invalid character number"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1946 XML_L("reference to binary entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1947 XML_L("reference to external entity in attribute"), |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1948 XML_L("XML or text declaration not at start of entity"), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1949 XML_L("unknown encoding"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1950 XML_L("encoding specified in XML declaration is incorrect"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1951 XML_L("unclosed CDATA section"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1952 XML_L("error in processing external entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1953 XML_L("document is not standalone"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1954 XML_L("unexpected parser state - please send a bug report"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1955 XML_L("entity declared in parameter entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1956 XML_L("requested feature requires XML_DTD support in Expat"), |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1957 XML_L("cannot change setting once parsing has begun"), |
| 32911 | 1958 XML_L("unbound prefix"), |
| 1959 XML_L("must not undeclare prefix"), | |
| 1960 XML_L("incomplete markup in parameter entity"), | |
| 1961 XML_L("XML declaration not well-formed"), | |
| 1962 XML_L("text declaration not well-formed"), | |
| 1963 XML_L("illegal character(s) in public id"), | |
| 1964 XML_L("parser suspended"), | |
| 1965 XML_L("parser not suspended"), | |
| 1966 XML_L("parsing aborted"), | |
| 1967 XML_L("parsing finished"), | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1968 XML_L("cannot suspend in external parameter entity"), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1969 XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1970 XML_L("reserved prefix (xmlns) must not be declared or undeclared"), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
1971 XML_L("prefix must not be bound to one of the reserved namespace names") |
| 21930 | 1972 }; |
| 1973 if (code > 0 && code < sizeof(message)/sizeof(message[0])) | |
| 1974 return message[code]; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1975 return NULL; |
| 21930 | 1976 } |
| 1977 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1978 const XML_LChar * XMLCALL |
| 21930 | 1979 XML_ExpatVersion(void) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1980 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1981 /* V1 is used to string-ize the version number. However, it would |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1982 string-ize the actual version macro *names* unless we get them |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1983 substituted before being passed to V1. CPP is defined to expand |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1984 a macro, then rescan for more expansions. Thus, we use V2 to expand |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1985 the version macros, then CPP will expand the resulting V1() macro |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1986 with the correct numerals. */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1987 /* ### I'm assuming cpp is portable in this respect... */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1988 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1989 #define V1(a,b,c) XML_L(#a)XML_L(".")XML_L(#b)XML_L(".")XML_L(#c) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1990 #define V2(a,b,c) XML_L("expat_")V1(a,b,c) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1991 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1992 return V2(XML_MAJOR_VERSION, XML_MINOR_VERSION, XML_MICRO_VERSION); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1993 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1994 #undef V1 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1995 #undef V2 |
| 21930 | 1996 } |
| 1997 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
1998 XML_Expat_Version XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1999 XML_ExpatVersionInfo(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2000 { |
| 21930 | 2001 XML_Expat_Version version; |
| 2002 | |
| 2003 version.major = XML_MAJOR_VERSION; | |
| 2004 version.minor = XML_MINOR_VERSION; | |
| 2005 version.micro = XML_MICRO_VERSION; | |
| 2006 | |
| 2007 return version; | |
| 2008 } | |
| 2009 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2010 const XML_Feature * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2011 XML_GetFeatureList(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2012 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2013 static const XML_Feature features[] = { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2014 {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2015 sizeof(XML_Char)}, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2016 {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2017 sizeof(XML_LChar)}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2018 #ifdef XML_UNICODE |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2019 {XML_FEATURE_UNICODE, XML_L("XML_UNICODE"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2020 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2021 #ifdef XML_UNICODE_WCHAR_T |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2022 {XML_FEATURE_UNICODE_WCHAR_T, XML_L("XML_UNICODE_WCHAR_T"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2023 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2024 #ifdef XML_DTD |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2025 {XML_FEATURE_DTD, XML_L("XML_DTD"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2026 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2027 #ifdef XML_CONTEXT_BYTES |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2028 {XML_FEATURE_CONTEXT_BYTES, XML_L("XML_CONTEXT_BYTES"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2029 XML_CONTEXT_BYTES}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2030 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2031 #ifdef XML_MIN_SIZE |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2032 {XML_FEATURE_MIN_SIZE, XML_L("XML_MIN_SIZE"), 0}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2033 #endif |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2034 #ifdef XML_NS |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2035 {XML_FEATURE_NS, XML_L("XML_NS"), 0}, |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2036 #endif |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2037 #ifdef XML_LARGE_SIZE |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2038 {XML_FEATURE_LARGE_SIZE, XML_L("XML_LARGE_SIZE"), 0}, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2039 #endif |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2040 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2041 {XML_FEATURE_ATTR_INFO, XML_L("XML_ATTR_INFO"), 0}, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2042 #endif |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2043 {XML_FEATURE_END, NULL, 0} |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2044 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2045 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2046 return features; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2047 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2048 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2049 /* Initially tag->rawName always points into the parse buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2050 for those TAG instances opened while the current parse buffer was |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2051 processed, and not yet closed, we need to store tag->rawName in a more |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2052 permanent location, since the parse buffer is about to be discarded. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2053 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2054 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2055 storeRawNames(XML_Parser parser) |
| 21930 | 2056 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2057 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2058 while (tag) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2059 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2060 int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2061 char *rawNameBuf = tag->buf + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2062 /* Stop if already stored. Since tagStack is a stack, we can stop |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2063 at the first entry that has already been copied; everything |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2064 below it in the stack is already been accounted for in a |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2065 previous call to this function. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2066 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2067 if (tag->rawName == rawNameBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2068 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2069 /* For re-use purposes we need to ensure that the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2070 size of tag->buf is a multiple of sizeof(XML_Char). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2071 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2072 bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2073 if (bufSize > tag->bufEnd - tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2074 char *temp = (char *)REALLOC(tag->buf, bufSize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2075 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2076 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2077 /* if tag->name.str points to tag->buf (only when namespace |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2078 processing is off) then we have to update it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2079 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2080 if (tag->name.str == (XML_Char *)tag->buf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2081 tag->name.str = (XML_Char *)temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2082 /* if tag->name.localPart is set (when namespace processing is on) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2083 then update it as well, since it will always point into tag->buf |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2084 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2085 if (tag->name.localPart) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2086 tag->name.localPart = (XML_Char *)temp + (tag->name.localPart - |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2087 (XML_Char *)tag->buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2088 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2089 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2090 rawNameBuf = temp + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2091 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2092 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2093 tag->rawName = rawNameBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2094 tag = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2095 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2096 return XML_TRUE; |
| 21930 | 2097 } |
| 2098 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2099 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2100 contentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2101 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2102 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2103 const char **endPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2104 { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2105 enum XML_Error result = doContent(parser, 0, encoding, start, end, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2106 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2107 if (result == XML_ERROR_NONE) { |
| 2108 if (!storeRawNames(parser)) | |
| 2109 return XML_ERROR_NO_MEMORY; | |
| 2110 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2111 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2112 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2113 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2114 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2115 externalEntityInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2116 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2117 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2118 const char **endPtr) |
| 21930 | 2119 { |
| 2120 enum XML_Error result = initializeEncoding(parser); | |
| 2121 if (result != XML_ERROR_NONE) | |
| 2122 return result; | |
| 2123 processor = externalEntityInitProcessor2; | |
| 2124 return externalEntityInitProcessor2(parser, start, end, endPtr); | |
| 2125 } | |
| 2126 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2127 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2128 externalEntityInitProcessor2(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2129 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2130 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2131 const char **endPtr) |
| 21930 | 2132 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2133 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 21930 | 2134 int tok = XmlContentTok(encoding, start, end, &next); |
| 2135 switch (tok) { | |
| 2136 case XML_TOK_BOM: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2137 /* If we are at the end of the buffer, this would cause the next stage, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2138 i.e. externalEntityInitProcessor3, to pass control directly to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2139 doContent (by detecting XML_TOK_NONE) without processing any xml text |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2140 declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2141 */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2142 if (next == end && !ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2143 *endPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2144 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2145 } |
| 21930 | 2146 start = next; |
| 2147 break; | |
| 2148 case XML_TOK_PARTIAL: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2149 if (!ps_finalBuffer) { |
| 21930 | 2150 *endPtr = start; |
| 2151 return XML_ERROR_NONE; | |
| 2152 } | |
| 2153 eventPtr = start; | |
| 2154 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2155 case XML_TOK_PARTIAL_CHAR: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2156 if (!ps_finalBuffer) { |
| 21930 | 2157 *endPtr = start; |
| 2158 return XML_ERROR_NONE; | |
| 2159 } | |
| 2160 eventPtr = start; | |
| 2161 return XML_ERROR_PARTIAL_CHAR; | |
| 2162 } | |
| 2163 processor = externalEntityInitProcessor3; | |
| 2164 return externalEntityInitProcessor3(parser, start, end, endPtr); | |
| 2165 } | |
| 2166 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2167 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2168 externalEntityInitProcessor3(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2169 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2170 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2171 const char **endPtr) |
| 21930 | 2172 { |
| 32911 | 2173 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2174 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 32911 | 2175 eventPtr = start; |
| 2176 tok = XmlContentTok(encoding, start, end, &next); | |
| 2177 eventEndPtr = next; | |
| 2178 | |
| 21930 | 2179 switch (tok) { |
| 2180 case XML_TOK_XML_DECL: | |
| 2181 { | |
| 32911 | 2182 enum XML_Error result; |
| 2183 result = processXmlDecl(parser, 1, start, next); | |
| 21930 | 2184 if (result != XML_ERROR_NONE) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2185 return result; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2186 switch (ps_parsing) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2187 case XML_SUSPENDED: |
| 32911 | 2188 *endPtr = next; |
| 2189 return XML_ERROR_NONE; | |
| 2190 case XML_FINISHED: | |
| 2191 return XML_ERROR_ABORTED; | |
| 2192 default: | |
| 2193 start = next; | |
| 2194 } | |
| 21930 | 2195 } |
| 2196 break; | |
| 2197 case XML_TOK_PARTIAL: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2198 if (!ps_finalBuffer) { |
| 21930 | 2199 *endPtr = start; |
| 2200 return XML_ERROR_NONE; | |
| 2201 } | |
| 2202 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2203 case XML_TOK_PARTIAL_CHAR: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2204 if (!ps_finalBuffer) { |
| 21930 | 2205 *endPtr = start; |
| 2206 return XML_ERROR_NONE; | |
| 2207 } | |
| 2208 return XML_ERROR_PARTIAL_CHAR; | |
| 2209 } | |
| 2210 processor = externalEntityContentProcessor; | |
| 2211 tagLevel = 1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2212 return externalEntityContentProcessor(parser, start, end, endPtr); |
| 21930 | 2213 } |
| 2214 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2215 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2216 externalEntityContentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2217 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2218 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2219 const char **endPtr) |
| 21930 | 2220 { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2221 enum XML_Error result = doContent(parser, 1, encoding, start, end, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2222 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2223 if (result == XML_ERROR_NONE) { |
| 2224 if (!storeRawNames(parser)) | |
| 2225 return XML_ERROR_NO_MEMORY; | |
| 2226 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2227 return result; |
| 21930 | 2228 } |
| 2229 | |
| 2230 static enum XML_Error | |
| 2231 doContent(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2232 int startTagLevel, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2233 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2234 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2235 const char *end, |
| 32911 | 2236 const char **nextPtr, |
| 2237 XML_Bool haveMore) | |
| 21930 | 2238 { |
| 32911 | 2239 /* save one level of indirection */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2240 DTD * const dtd = _dtd; |
| 32911 | 2241 |
| 21930 | 2242 const char **eventPP; |
| 2243 const char **eventEndPP; | |
| 2244 if (enc == encoding) { | |
| 2245 eventPP = &eventPtr; | |
| 2246 eventEndPP = &eventEndPtr; | |
| 2247 } | |
| 2248 else { | |
| 2249 eventPP = &(openInternalEntities->internalEventPtr); | |
| 2250 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 2251 } | |
| 2252 *eventPP = s; | |
| 32911 | 2253 |
| 21930 | 2254 for (;;) { |
| 2255 const char *next = s; /* XmlContentTok doesn't always set the last arg */ | |
| 2256 int tok = XmlContentTok(enc, s, end, &next); | |
| 2257 *eventEndPP = next; | |
| 2258 switch (tok) { | |
| 2259 case XML_TOK_TRAILING_CR: | |
| 32911 | 2260 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2261 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2262 return XML_ERROR_NONE; |
| 21930 | 2263 } |
| 2264 *eventEndPP = end; | |
| 2265 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2266 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2267 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2268 } |
| 2269 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2270 reportDefault(parser, enc, s, end); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2271 /* We are at the end of the final buffer, should we check for |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2272 XML_SUSPENDED, XML_FINISHED? |
| 32911 | 2273 */ |
| 21930 | 2274 if (startTagLevel == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2275 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2276 if (tagLevel != startTagLevel) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2277 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2278 *nextPtr = end; |
| 21930 | 2279 return XML_ERROR_NONE; |
| 2280 case XML_TOK_NONE: | |
| 32911 | 2281 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2282 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2283 return XML_ERROR_NONE; |
| 21930 | 2284 } |
| 2285 if (startTagLevel > 0) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2286 if (tagLevel != startTagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2287 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2288 *nextPtr = s; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2289 return XML_ERROR_NONE; |
| 21930 | 2290 } |
| 2291 return XML_ERROR_NO_ELEMENTS; | |
| 2292 case XML_TOK_INVALID: | |
| 2293 *eventPP = next; | |
| 2294 return XML_ERROR_INVALID_TOKEN; | |
| 2295 case XML_TOK_PARTIAL: | |
| 32911 | 2296 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2297 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2298 return XML_ERROR_NONE; |
| 21930 | 2299 } |
| 2300 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2301 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 2302 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2303 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2304 return XML_ERROR_NONE; |
| 21930 | 2305 } |
| 2306 return XML_ERROR_PARTIAL_CHAR; | |
| 2307 case XML_TOK_ENTITY_REF: | |
| 2308 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2309 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2310 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2311 XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2312 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2313 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2314 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2315 if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2316 characterDataHandler(handlerArg, &ch, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2317 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2318 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2319 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2320 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2321 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2322 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2323 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2324 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2325 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2326 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2327 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2328 /* First, determine if a check for an existing declaration is needed; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2329 if yes, check that the entity exists, and that it is internal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2330 otherwise call the skipped entity or default handler. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2331 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2332 if (!dtd->hasParamEntityRefs || dtd->standalone) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2333 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2334 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2335 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2336 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2337 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2338 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2339 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2340 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2341 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2342 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2343 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2344 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2345 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2346 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2347 if (entity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2348 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2349 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2350 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2351 if (!defaultExpandInternalEntities) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2352 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2353 skippedEntityHandler(handlerArg, entity->name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2354 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2355 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2356 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2357 } |
| 32911 | 2358 result = processInternalEntity(parser, entity, XML_FALSE); |
| 2359 if (result != XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2360 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2361 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2362 else if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2363 const XML_Char *context; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2364 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2365 context = getContext(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2366 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2367 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2368 return XML_ERROR_NO_MEMORY; |
| 32911 | 2369 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2370 context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2371 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2372 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2373 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2374 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2375 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2376 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2377 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2378 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2379 break; |
| 21930 | 2380 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2381 case XML_TOK_START_TAG_NO_ATTS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2382 /* fall through */ |
| 21930 | 2383 case XML_TOK_START_TAG_WITH_ATTS: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2384 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2385 TAG *tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2386 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2387 XML_Char *toPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2388 if (freeTagList) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2389 tag = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2390 freeTagList = freeTagList->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2391 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2392 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2393 tag = (TAG *)MALLOC(sizeof(TAG)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2394 if (!tag) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2395 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2396 tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2397 if (!tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2398 FREE(tag); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2399 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2400 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2401 tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2402 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2403 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2404 tag->parent = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2405 tagStack = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2406 tag->name.localPart = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2407 tag->name.prefix = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2408 tag->rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2409 tag->rawNameLength = XmlNameLength(enc, tag->rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2410 ++tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2411 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2412 const char *rawNameEnd = tag->rawName + tag->rawNameLength; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2413 const char *fromPtr = tag->rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2414 toPtr = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2415 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2416 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2417 int convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2418 XmlConvert(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2419 &fromPtr, rawNameEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2420 (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2421 convLen = (int)(toPtr - (XML_Char *)tag->buf); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2422 if (fromPtr == rawNameEnd) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2423 tag->name.strLen = convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2424 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2425 } |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2426 bufSize = (int)(tag->bufEnd - tag->buf) << 1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2427 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2428 char *temp = (char *)REALLOC(tag->buf, bufSize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2429 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2430 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2431 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2432 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2433 toPtr = (XML_Char *)temp + convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2434 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2435 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2436 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2437 tag->name.str = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2438 *toPtr = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2439 result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2440 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2441 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2442 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2443 startElementHandler(handlerArg, tag->name.str, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2444 (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2445 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2446 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2447 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2448 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2449 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2450 case XML_TOK_EMPTY_ELEMENT_NO_ATTS: |
| 21930 | 2451 /* fall through */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2452 case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: |
| 21930 | 2453 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2454 const char *rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2455 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2456 BINDING *bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2457 XML_Bool noElmHandlers = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2458 TAG_NAME name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2459 name.str = poolStoreString(&tempPool, enc, rawName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2460 rawName + XmlNameLength(enc, rawName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2461 if (!name.str) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2462 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2463 poolFinish(&tempPool); |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2464 result = storeAtts(parser, enc, s, &name, &bindings); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2465 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2466 return result; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2467 poolFinish(&tempPool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2468 if (startElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2469 startElementHandler(handlerArg, name.str, (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2470 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2471 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2472 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2473 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2474 *eventPP = *eventEndPP; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2475 endElementHandler(handlerArg, name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2476 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2477 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2478 if (noElmHandlers && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2479 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2480 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2481 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2482 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2483 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2484 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2485 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2486 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2487 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2488 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2489 } |
| 21930 | 2490 } |
| 2491 if (tagLevel == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2492 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2493 break; |
| 2494 case XML_TOK_END_TAG: | |
| 2495 if (tagLevel == startTagLevel) | |
| 2496 return XML_ERROR_ASYNC_ENTITY; | |
| 2497 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2498 int len; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2499 const char *rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2500 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2501 tagStack = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2502 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2503 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2504 rawName = s + enc->minBytesPerChar*2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2505 len = XmlNameLength(enc, rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2506 if (len != tag->rawNameLength |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2507 || memcmp(tag->rawName, rawName, len) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2508 *eventPP = rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2509 return XML_ERROR_TAG_MISMATCH; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2510 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2511 --tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2512 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2513 const XML_Char *localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2514 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2515 XML_Char *uri; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2516 localPart = tag->name.localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2517 if (ns && localPart) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2518 /* localPart and prefix may have been overwritten in |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2519 tag->name.str, since this points to the binding->uri |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2520 buffer which gets re-used; so we have to add them again |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2521 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2522 uri = (XML_Char *)tag->name.str + tag->name.uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2523 /* don't need to check for space - already done in storeAtts() */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2524 while (*localPart) *uri++ = *localPart++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2525 prefix = (XML_Char *)tag->name.prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2526 if (ns_triplets && prefix) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2527 *uri++ = namespaceSeparator; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2528 while (*prefix) *uri++ = *prefix++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2529 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2530 *uri = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2531 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2532 endElementHandler(handlerArg, tag->name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2533 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2534 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2535 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2536 while (tag->bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2537 BINDING *b = tag->bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2538 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2539 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2540 tag->bindings = tag->bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2541 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2542 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2543 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2544 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2545 if (tagLevel == 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2546 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2547 } |
| 2548 break; | |
| 2549 case XML_TOK_CHAR_REF: | |
| 2550 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2551 int n = XmlCharRefNumber(enc, s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2552 if (n < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2553 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2554 if (characterDataHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2555 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2556 characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2557 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2558 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2559 reportDefault(parser, enc, s, next); |
| 21930 | 2560 } |
| 2561 break; | |
| 2562 case XML_TOK_XML_DECL: | |
| 2563 return XML_ERROR_MISPLACED_XML_PI; | |
| 2564 case XML_TOK_DATA_NEWLINE: | |
| 2565 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2566 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2567 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2568 } |
| 2569 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2570 reportDefault(parser, enc, s, next); |
| 21930 | 2571 break; |
| 2572 case XML_TOK_CDATA_SECT_OPEN: | |
| 2573 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2574 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2575 if (startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2576 startCdataSectionHandler(handlerArg); |
| 21930 | 2577 #if 0 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2578 /* Suppose you doing a transformation on a document that involves |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2579 changing only the character data. You set up a defaultHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2580 and a characterDataHandler. The defaultHandler simply copies |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2581 characters through. The characterDataHandler does the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2582 transformation and writes the characters out escaping them as |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2583 necessary. This case will fail to work if we leave out the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2584 following two lines (because & and < inside CDATA sections will |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2585 be incorrectly escaped). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2586 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2587 However, now we have a start/endCdataSectionHandler, so it seems |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2588 easier to let the user deal with this. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2589 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2590 else if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2591 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 2592 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2593 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2594 reportDefault(parser, enc, s, next); |
| 32911 | 2595 result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); |
| 2596 if (result != XML_ERROR_NONE) | |
| 2597 return result; | |
| 2598 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2599 processor = cdataSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2600 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2601 } |
| 21930 | 2602 } |
| 2603 break; | |
| 2604 case XML_TOK_TRAILING_RSQB: | |
| 32911 | 2605 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2606 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2607 return XML_ERROR_NONE; |
| 21930 | 2608 } |
| 2609 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2610 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2611 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2612 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2613 characterDataHandler(handlerArg, dataBuf, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2614 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2615 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2616 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2617 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2618 (XML_Char *)s, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2619 (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 2620 } |
| 2621 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2622 reportDefault(parser, enc, s, end); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2623 /* We are at the end of the final buffer, should we check for |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2624 XML_SUSPENDED, XML_FINISHED? |
| 32911 | 2625 */ |
| 21930 | 2626 if (startTagLevel == 0) { |
| 2627 *eventPP = end; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2628 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2629 } |
| 2630 if (tagLevel != startTagLevel) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2631 *eventPP = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2632 return XML_ERROR_ASYNC_ENTITY; |
| 21930 | 2633 } |
| 32911 | 2634 *nextPtr = end; |
| 21930 | 2635 return XML_ERROR_NONE; |
| 2636 case XML_TOK_DATA_CHARS: | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2637 { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2638 XML_CharacterDataHandler charDataHandler = characterDataHandler; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2639 if (charDataHandler) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2640 if (MUST_CONVERT(enc, s)) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2641 for (;;) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2642 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2643 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2644 *eventEndPP = s; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2645 charDataHandler(handlerArg, dataBuf, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2646 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2647 if (s == next) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2648 break; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2649 *eventPP = s; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2650 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2651 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2652 else |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2653 charDataHandler(handlerArg, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2654 (XML_Char *)s, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2655 (int)((XML_Char *)next - (XML_Char *)s)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2656 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2657 else if (defaultHandler) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2658 reportDefault(parser, enc, s, next); |
| 21930 | 2659 } |
| 2660 break; | |
| 2661 case XML_TOK_PI: | |
| 2662 if (!reportProcessingInstruction(parser, enc, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2663 return XML_ERROR_NO_MEMORY; |
| 21930 | 2664 break; |
| 2665 case XML_TOK_COMMENT: | |
| 2666 if (!reportComment(parser, enc, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2667 return XML_ERROR_NO_MEMORY; |
| 21930 | 2668 break; |
| 2669 default: | |
| 2670 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2671 reportDefault(parser, enc, s, next); |
| 21930 | 2672 break; |
| 2673 } | |
| 2674 *eventPP = s = next; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2675 switch (ps_parsing) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2676 case XML_SUSPENDED: |
| 32911 | 2677 *nextPtr = next; |
| 2678 return XML_ERROR_NONE; | |
| 2679 case XML_FINISHED: | |
| 2680 return XML_ERROR_ABORTED; | |
| 2681 default: ; | |
| 2682 } | |
| 21930 | 2683 } |
| 2684 /* not reached */ | |
| 2685 } | |
| 2686 | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2687 /* Precondition: all arguments must be non-NULL; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2688 Purpose: |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2689 - normalize attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2690 - check attributes for well-formedness |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2691 - generate namespace aware attribute names (URI, prefix) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2692 - build list of attributes for startElementHandler |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2693 - default attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2694 - process namespace declarations (check and report them) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2695 - generate namespace aware element name (URI, prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2696 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2697 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2698 storeAtts(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2699 const char *attStr, TAG_NAME *tagNamePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2700 BINDING **bindingsPtr) |
| 21930 | 2701 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2702 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2703 ELEMENT_TYPE *elementType; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2704 int nDefaultAtts; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2705 const XML_Char **appAtts; /* the attribute list for the application */ |
| 21930 | 2706 int attIndex = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2707 int prefixLen; |
| 21930 | 2708 int i; |
| 2709 int n; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2710 XML_Char *uri; |
| 21930 | 2711 int nPrefixes = 0; |
| 2712 BINDING *binding; | |
| 2713 const XML_Char *localPart; | |
| 2714 | |
| 2715 /* lookup the element type name */ | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2716 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, tagNamePtr->str,0); |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2717 if (!elementType) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2718 const XML_Char *name = poolCopyString(&dtd->pool, tagNamePtr->str); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2719 if (!name) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2720 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2721 elementType = (ELEMENT_TYPE *)lookup(parser, &dtd->elementTypes, name, |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2722 sizeof(ELEMENT_TYPE)); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2723 if (!elementType) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2724 return XML_ERROR_NO_MEMORY; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2725 if (ns && !setElementTypePrefix(parser, elementType)) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2726 return XML_ERROR_NO_MEMORY; |
| 21930 | 2727 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2728 nDefaultAtts = elementType->nDefaultAtts; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2729 |
| 21930 | 2730 /* get the attributes from the tokenizer */ |
| 2731 n = XmlGetAttributes(enc, attStr, attsSize, atts); | |
| 2732 if (n + nDefaultAtts > attsSize) { | |
| 2733 int oldAttsSize = attsSize; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2734 ATTRIBUTE *temp; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2735 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2736 XML_AttrInfo *temp2; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2737 #endif |
| 21930 | 2738 attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2739 temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2740 if (temp == NULL) |
| 21930 | 2741 return XML_ERROR_NO_MEMORY; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2742 atts = temp; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2743 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2744 temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo)); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2745 if (temp2 == NULL) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2746 return XML_ERROR_NO_MEMORY; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2747 attInfo = temp2; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2748 #endif |
| 21930 | 2749 if (n > oldAttsSize) |
| 2750 XmlGetAttributes(enc, attStr, n, atts); | |
| 2751 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2752 |
| 21930 | 2753 appAtts = (const XML_Char **)atts; |
| 2754 for (i = 0; i < n; i++) { | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2755 ATTRIBUTE *currAtt = &atts[i]; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2756 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2757 XML_AttrInfo *currAttInfo = &attInfo[i]; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2758 #endif |
| 21930 | 2759 /* add the name and value to the attribute list */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2760 ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2761 currAtt->name |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2762 + XmlNameLength(enc, currAtt->name)); |
| 21930 | 2763 if (!attId) |
| 2764 return XML_ERROR_NO_MEMORY; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2765 #ifdef XML_ATTR_INFO |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2766 currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2767 currAttInfo->nameEnd = currAttInfo->nameStart + |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2768 XmlNameLength(enc, currAtt->name); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2769 currAttInfo->valueStart = parseEndByteIndex - |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2770 (parseEndPtr - currAtt->valuePtr); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2771 currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2772 #endif |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2773 /* Detect duplicate attributes by their QNames. This does not work when |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2774 namespace processing is turned on and different prefixes for the same |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2775 namespace are used. For this case we have a check further down. |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2776 */ |
| 21930 | 2777 if ((attId->name)[-1]) { |
| 2778 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2779 eventPtr = atts[i].name; |
| 21930 | 2780 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 2781 } | |
| 2782 (attId->name)[-1] = 1; | |
| 2783 appAtts[attIndex++] = attId->name; | |
| 2784 if (!atts[i].normalized) { | |
| 2785 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2786 XML_Bool isCdata = XML_TRUE; |
| 21930 | 2787 |
| 2788 /* figure out whether declared as other than CDATA */ | |
| 2789 if (attId->maybeTokenized) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2790 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2791 for (j = 0; j < nDefaultAtts; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2792 if (attId == elementType->defaultAtts[j].id) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2793 isCdata = elementType->defaultAtts[j].isCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2794 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2795 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2796 } |
| 21930 | 2797 } |
| 2798 | |
| 2799 /* normalize the attribute value */ | |
| 2800 result = storeAttributeValue(parser, enc, isCdata, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2801 atts[i].valuePtr, atts[i].valueEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2802 &tempPool); |
| 21930 | 2803 if (result) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2804 return result; |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2805 appAtts[attIndex] = poolStart(&tempPool); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2806 poolFinish(&tempPool); |
| 21930 | 2807 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2808 else { |
| 21930 | 2809 /* the value did not need normalizing */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2810 appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2811 atts[i].valueEnd); |
| 21930 | 2812 if (appAtts[attIndex] == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2813 return XML_ERROR_NO_MEMORY; |
| 21930 | 2814 poolFinish(&tempPool); |
| 2815 } | |
| 2816 /* handle prefixed attribute names */ | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2817 if (attId->prefix) { |
| 21930 | 2818 if (attId->xmlns) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2819 /* deal with namespace declarations here */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2820 enum XML_Error result = addBinding(parser, attId->prefix, attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2821 appAtts[attIndex], bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2822 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2823 return result; |
| 21930 | 2824 --attIndex; |
| 2825 } | |
| 2826 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2827 /* deal with other prefixed names later */ |
| 21930 | 2828 attIndex++; |
| 2829 nPrefixes++; | |
| 2830 (attId->name)[-1] = 2; | |
| 2831 } | |
| 2832 } | |
| 2833 else | |
| 2834 attIndex++; | |
| 2835 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2836 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2837 /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2838 nSpecifiedAtts = attIndex; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2839 if (elementType->idAtt && (elementType->idAtt->name)[-1]) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2840 for (i = 0; i < attIndex; i += 2) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2841 if (appAtts[i] == elementType->idAtt->name) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2842 idAttIndex = i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2843 break; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2844 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2845 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2846 else |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2847 idAttIndex = -1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2848 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2849 /* do attribute defaulting */ |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2850 for (i = 0; i < nDefaultAtts; i++) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2851 const DEFAULT_ATTRIBUTE *da = elementType->defaultAtts + i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2852 if (!(da->id->name)[-1] && da->value) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2853 if (da->id->prefix) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2854 if (da->id->xmlns) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2855 enum XML_Error result = addBinding(parser, da->id->prefix, da->id, |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2856 da->value, bindingsPtr); |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2857 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2858 return result; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2859 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2860 else { |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2861 (da->id->name)[-1] = 2; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2862 nPrefixes++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2863 appAtts[attIndex++] = da->id->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2864 appAtts[attIndex++] = da->value; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2865 } |
| 21930 | 2866 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2867 else { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2868 (da->id->name)[-1] = 1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2869 appAtts[attIndex++] = da->id->name; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2870 appAtts[attIndex++] = da->value; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2871 } |
| 21930 | 2872 } |
| 2873 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2874 appAtts[attIndex] = 0; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2875 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2876 /* expand prefixed attribute names, check for duplicates, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2877 and clear flags that say whether attributes were specified */ |
| 21930 | 2878 i = 0; |
| 2879 if (nPrefixes) { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2880 int j; /* hash table index */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2881 unsigned long version = nsAttsVersion; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2882 int nsAttsSize = (int)1 << nsAttsPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2883 /* size of hash table must be at least 2 * (# of prefixed attributes) */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2884 if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2885 NS_ATT *temp; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2886 /* hash table size must also be a power of 2 and >= 8 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2887 while (nPrefixes >> nsAttsPower++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2888 if (nsAttsPower < 3) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2889 nsAttsPower = 3; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2890 nsAttsSize = (int)1 << nsAttsPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2891 temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT)); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2892 if (!temp) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2893 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2894 nsAtts = temp; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2895 version = 0; /* force re-initialization of nsAtts hash table */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2896 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2897 /* using a version flag saves us from initializing nsAtts every time */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2898 if (!version) { /* initialize version flags when version wraps around */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2899 version = INIT_ATTS_VERSION; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2900 for (j = nsAttsSize; j != 0; ) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2901 nsAtts[--j].version = version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2902 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2903 nsAttsVersion = --version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2904 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2905 /* expand prefixed names and check for duplicates */ |
| 21930 | 2906 for (; i < attIndex; i += 2) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2907 const XML_Char *s = appAtts[i]; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2908 if (s[-1] == 2) { /* prefixed */ |
| 21930 | 2909 ATTRIBUTE_ID *id; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2910 const BINDING *b; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2911 unsigned long uriHash = hash_secret_salt; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2912 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2913 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2914 b = id->prefix->binding; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2915 if (!b) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2916 return XML_ERROR_UNBOUND_PREFIX; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2917 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2918 /* as we expand the name we also calculate its hash value */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2919 for (j = 0; j < b->uriLen; j++) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2920 const XML_Char c = b->uri[j]; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2921 if (!poolAppendChar(&tempPool, c)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2922 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2923 uriHash = CHAR_HASH(uriHash, c); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2924 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2925 while (*s++ != XML_T(ASCII_COLON)) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2926 ; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2927 do { /* copies null terminator */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2928 const XML_Char c = *s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2929 if (!poolAppendChar(&tempPool, *s)) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2930 return XML_ERROR_NO_MEMORY; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2931 uriHash = CHAR_HASH(uriHash, c); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2932 } while (*s++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2933 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2934 { /* Check hash table for duplicate of expanded name (uriName). |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
2935 Derived from code in lookup(parser, HASH_TABLE *table, ...). |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2936 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2937 unsigned char step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2938 unsigned long mask = nsAttsSize - 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2939 j = uriHash & mask; /* index into hash table */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2940 while (nsAtts[j].version == version) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2941 /* for speed we compare stored hash values first */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2942 if (uriHash == nsAtts[j].hash) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2943 const XML_Char *s1 = poolStart(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2944 const XML_Char *s2 = nsAtts[j].uriName; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2945 /* s1 is null terminated, but not s2 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2946 for (; *s1 == *s2 && *s1 != 0; s1++, s2++); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2947 if (*s1 == 0) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2948 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2949 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2950 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2951 step = PROBE_STEP(uriHash, mask, nsAttsPower); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2952 j < step ? (j += nsAttsSize - step) : (j -= step); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2953 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2954 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2955 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2956 if (ns_triplets) { /* append namespace separator and prefix */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2957 tempPool.ptr[-1] = namespaceSeparator; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2958 s = b->prefix->name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2959 do { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2960 if (!poolAppendChar(&tempPool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2961 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2962 } while (*s++); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2963 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2964 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2965 /* store expanded name in attribute list */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2966 s = poolStart(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2967 poolFinish(&tempPool); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2968 appAtts[i] = s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2969 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2970 /* fill empty slot with new version, uriName and hash value */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2971 nsAtts[j].version = version; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2972 nsAtts[j].hash = uriHash; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2973 nsAtts[j].uriName = s; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2974 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2975 if (!--nPrefixes) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2976 i += 2; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2977 break; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
2978 } |
| 21930 | 2979 } |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2980 else /* not prefixed */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2981 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
| 21930 | 2982 } |
| 2983 } | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2984 /* clear flags for the remaining attributes */ |
| 21930 | 2985 for (; i < attIndex; i += 2) |
| 2986 ((XML_Char *)(appAtts[i]))[-1] = 0; | |
| 2987 for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) | |
| 2988 binding->attId->name[-1] = 0; | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2989 |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2990 if (!ns) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2991 return XML_ERROR_NONE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2992 |
| 21930 | 2993 /* expand the element type name */ |
| 2994 if (elementType->prefix) { | |
| 2995 binding = elementType->prefix->binding; | |
| 2996 if (!binding) | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2997 return XML_ERROR_UNBOUND_PREFIX; |
| 21930 | 2998 localPart = tagNamePtr->str; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
2999 while (*localPart++ != XML_T(ASCII_COLON)) |
| 21930 | 3000 ; |
| 3001 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3002 else if (dtd->defaultPrefix.binding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3003 binding = dtd->defaultPrefix.binding; |
| 21930 | 3004 localPart = tagNamePtr->str; |
| 3005 } | |
| 3006 else | |
| 3007 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3008 prefixLen = 0; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3009 if (ns_triplets && binding->prefix->name) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3010 for (; binding->prefix->name[prefixLen++];) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3011 ; /* prefixLen includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3012 } |
| 21930 | 3013 tagNamePtr->localPart = localPart; |
| 3014 tagNamePtr->uriLen = binding->uriLen; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3015 tagNamePtr->prefix = binding->prefix->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3016 tagNamePtr->prefixLen = prefixLen; |
| 21930 | 3017 for (i = 0; localPart[i++];) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3018 ; /* i includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3019 n = i + binding->uriLen + prefixLen; |
| 21930 | 3020 if (n > binding->uriAlloc) { |
| 3021 TAG *p; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3022 uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); |
| 21930 | 3023 if (!uri) |
| 3024 return XML_ERROR_NO_MEMORY; | |
| 3025 binding->uriAlloc = n + EXPAND_SPARE; | |
| 3026 memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); | |
| 3027 for (p = tagStack; p; p = p->parent) | |
| 3028 if (p->name.str == binding->uri) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3029 p->name.str = uri; |
| 21930 | 3030 FREE(binding->uri); |
| 3031 binding->uri = uri; | |
| 3032 } | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3033 /* if namespaceSeparator != '\0' then uri includes it already */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3034 uri = binding->uri + binding->uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3035 memcpy(uri, localPart, i * sizeof(XML_Char)); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3036 /* we always have a namespace separator between localPart and prefix */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3037 if (prefixLen) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3038 uri += i - 1; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3039 *uri = namespaceSeparator; /* replace null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3040 memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3041 } |
| 21930 | 3042 tagNamePtr->str = binding->uri; |
| 3043 return XML_ERROR_NONE; | |
| 3044 } | |
| 3045 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3046 /* addBinding() overwrites the value of prefix->binding without checking. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3047 Therefore one must keep track of the old value outside of addBinding(). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3048 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3049 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3050 addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3051 const XML_Char *uri, BINDING **bindingsPtr) |
| 21930 | 3052 { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3053 static const XML_Char xmlNamespace[] = { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3054 ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3055 ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3056 ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_X, ASCII_M, ASCII_L, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3057 ASCII_SLASH, ASCII_1, ASCII_9, ASCII_9, ASCII_8, ASCII_SLASH, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3058 ASCII_n, ASCII_a, ASCII_m, ASCII_e, ASCII_s, ASCII_p, ASCII_a, ASCII_c, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3059 ASCII_e, '\0' |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3060 }; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3061 static const int xmlLen = |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3062 (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3063 static const XML_Char xmlnsNamespace[] = { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3064 ASCII_h, ASCII_t, ASCII_t, ASCII_p, ASCII_COLON, ASCII_SLASH, ASCII_SLASH, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3065 ASCII_w, ASCII_w, ASCII_w, ASCII_PERIOD, ASCII_w, ASCII_3, ASCII_PERIOD, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3066 ASCII_o, ASCII_r, ASCII_g, ASCII_SLASH, ASCII_2, ASCII_0, ASCII_0, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3067 ASCII_0, ASCII_SLASH, ASCII_x, ASCII_m, ASCII_l, ASCII_n, ASCII_s, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3068 ASCII_SLASH, '\0' |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3069 }; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3070 static const int xmlnsLen = |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3071 (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3072 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3073 XML_Bool mustBeXML = XML_FALSE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3074 XML_Bool isXML = XML_TRUE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3075 XML_Bool isXMLNS = XML_TRUE; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3076 |
| 21930 | 3077 BINDING *b; |
| 3078 int len; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3079 |
| 32911 | 3080 /* empty URI is only valid for default namespace per XML NS 1.0 (not 1.1) */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3081 if (*uri == XML_T('\0') && prefix->name) |
| 32911 | 3082 return XML_ERROR_UNDECLARING_PREFIX; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3083 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3084 if (prefix->name |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3085 && prefix->name[0] == XML_T(ASCII_x) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3086 && prefix->name[1] == XML_T(ASCII_m) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3087 && prefix->name[2] == XML_T(ASCII_l)) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3088 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3089 /* Not allowed to bind xmlns */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3090 if (prefix->name[3] == XML_T(ASCII_n) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3091 && prefix->name[4] == XML_T(ASCII_s) |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3092 && prefix->name[5] == XML_T('\0')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3093 return XML_ERROR_RESERVED_PREFIX_XMLNS; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3094 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3095 if (prefix->name[3] == XML_T('\0')) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3096 mustBeXML = XML_TRUE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3097 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3098 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3099 for (len = 0; uri[len]; len++) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3100 if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3101 isXML = XML_FALSE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3102 |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3103 if (!mustBeXML && isXMLNS |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3104 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3105 isXMLNS = XML_FALSE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3106 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3107 isXML = isXML && len == xmlLen; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3108 isXMLNS = isXMLNS && len == xmlnsLen; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3109 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3110 if (mustBeXML != isXML) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3111 return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3112 : XML_ERROR_RESERVED_NAMESPACE_URI; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3113 |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3114 if (isXMLNS) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3115 return XML_ERROR_RESERVED_NAMESPACE_URI; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3116 |
| 21930 | 3117 if (namespaceSeparator) |
| 3118 len++; | |
| 3119 if (freeBindingList) { | |
| 3120 b = freeBindingList; | |
| 3121 if (len > b->uriAlloc) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3122 XML_Char *temp = (XML_Char *)REALLOC(b->uri, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3123 sizeof(XML_Char) * (len + EXPAND_SPARE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3124 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3125 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3126 b->uri = temp; |
| 21930 | 3127 b->uriAlloc = len + EXPAND_SPARE; |
| 3128 } | |
| 3129 freeBindingList = b->nextTagBinding; | |
| 3130 } | |
| 3131 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3132 b = (BINDING *)MALLOC(sizeof(BINDING)); |
| 21930 | 3133 if (!b) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3134 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3135 b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 21930 | 3136 if (!b->uri) { |
| 3137 FREE(b); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3138 return XML_ERROR_NO_MEMORY; |
| 21930 | 3139 } |
| 3140 b->uriAlloc = len + EXPAND_SPARE; | |
| 3141 } | |
| 3142 b->uriLen = len; | |
| 3143 memcpy(b->uri, uri, len * sizeof(XML_Char)); | |
| 3144 if (namespaceSeparator) | |
| 3145 b->uri[len - 1] = namespaceSeparator; | |
| 3146 b->prefix = prefix; | |
| 3147 b->attId = attId; | |
| 3148 b->prevPrefixBinding = prefix->binding; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
3149 /* NULL binding when default namespace undeclared */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3150 if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3151 prefix->binding = NULL; |
| 21930 | 3152 else |
| 3153 prefix->binding = b; | |
| 3154 b->nextTagBinding = *bindingsPtr; | |
| 3155 *bindingsPtr = b; | |
| 32911 | 3156 /* if attId == NULL then we are not starting a namespace scope */ |
| 3157 if (attId && startNamespaceDeclHandler) | |
| 21930 | 3158 startNamespaceDeclHandler(handlerArg, prefix->name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3159 prefix->binding ? uri : 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3160 return XML_ERROR_NONE; |
| 21930 | 3161 } |
| 3162 | |
| 3163 /* The idea here is to avoid using stack for each CDATA section when | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3164 the whole file is parsed with one call. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3165 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3166 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3167 cdataSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3168 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3169 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3170 const char **endPtr) |
| 21930 | 3171 { |
| 32911 | 3172 enum XML_Error result = doCdataSection(parser, encoding, &start, end, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3173 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3174 if (result != XML_ERROR_NONE) |
| 3175 return result; | |
| 21930 | 3176 if (start) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3177 if (parentParser) { /* we are parsing an external entity */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3178 processor = externalEntityContentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3179 return externalEntityContentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3180 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3181 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3182 processor = contentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3183 return contentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3184 } |
| 21930 | 3185 } |
| 3186 return result; | |
| 3187 } | |
| 3188 | |
| 32911 | 3189 /* startPtr gets set to non-null if the section is closed, and to null if |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3190 the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3191 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3192 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3193 doCdataSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3194 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3195 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3196 const char *end, |
| 32911 | 3197 const char **nextPtr, |
| 3198 XML_Bool haveMore) | |
| 21930 | 3199 { |
| 3200 const char *s = *startPtr; | |
| 3201 const char **eventPP; | |
| 3202 const char **eventEndPP; | |
| 3203 if (enc == encoding) { | |
| 3204 eventPP = &eventPtr; | |
| 3205 *eventPP = s; | |
| 3206 eventEndPP = &eventEndPtr; | |
| 3207 } | |
| 3208 else { | |
| 3209 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3210 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3211 } | |
| 3212 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3213 *startPtr = NULL; |
| 32911 | 3214 |
| 21930 | 3215 for (;;) { |
| 3216 const char *next; | |
| 3217 int tok = XmlCdataSectionTok(enc, s, end, &next); | |
| 3218 *eventEndPP = next; | |
| 3219 switch (tok) { | |
| 3220 case XML_TOK_CDATA_SECT_CLOSE: | |
| 3221 if (endCdataSectionHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3222 endCdataSectionHandler(handlerArg); |
| 21930 | 3223 #if 0 |
| 3224 /* see comment under XML_TOK_CDATA_SECT_OPEN */ | |
| 3225 else if (characterDataHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3226 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 3227 #endif |
| 3228 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3229 reportDefault(parser, enc, s, next); |
| 21930 | 3230 *startPtr = next; |
| 32911 | 3231 *nextPtr = next; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3232 if (ps_parsing == XML_FINISHED) |
| 32911 | 3233 return XML_ERROR_ABORTED; |
| 3234 else | |
| 3235 return XML_ERROR_NONE; | |
| 21930 | 3236 case XML_TOK_DATA_NEWLINE: |
| 3237 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3238 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3239 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 3240 } |
| 3241 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3242 reportDefault(parser, enc, s, next); |
| 21930 | 3243 break; |
| 3244 case XML_TOK_DATA_CHARS: | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3245 { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3246 XML_CharacterDataHandler charDataHandler = characterDataHandler; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3247 if (charDataHandler) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3248 if (MUST_CONVERT(enc, s)) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3249 for (;;) { |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3250 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3251 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3252 *eventEndPP = next; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3253 charDataHandler(handlerArg, dataBuf, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3254 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3255 if (s == next) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3256 break; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3257 *eventPP = s; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3258 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3259 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3260 else |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3261 charDataHandler(handlerArg, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3262 (XML_Char *)s, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3263 (int)((XML_Char *)next - (XML_Char *)s)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3264 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3265 else if (defaultHandler) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3266 reportDefault(parser, enc, s, next); |
| 21930 | 3267 } |
| 3268 break; | |
| 3269 case XML_TOK_INVALID: | |
| 3270 *eventPP = next; | |
| 3271 return XML_ERROR_INVALID_TOKEN; | |
| 3272 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3273 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3274 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3275 return XML_ERROR_NONE; |
| 21930 | 3276 } |
| 3277 return XML_ERROR_PARTIAL_CHAR; | |
| 3278 case XML_TOK_PARTIAL: | |
| 3279 case XML_TOK_NONE: | |
| 32911 | 3280 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3281 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3282 return XML_ERROR_NONE; |
| 21930 | 3283 } |
| 3284 return XML_ERROR_UNCLOSED_CDATA_SECTION; | |
| 3285 default: | |
| 3286 *eventPP = next; | |
| 3287 return XML_ERROR_UNEXPECTED_STATE; | |
| 3288 } | |
| 32911 | 3289 |
| 21930 | 3290 *eventPP = s = next; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3291 switch (ps_parsing) { |
| 32911 | 3292 case XML_SUSPENDED: |
| 3293 *nextPtr = next; | |
| 3294 return XML_ERROR_NONE; | |
| 3295 case XML_FINISHED: | |
| 3296 return XML_ERROR_ABORTED; | |
| 3297 default: ; | |
| 3298 } | |
| 21930 | 3299 } |
| 3300 /* not reached */ | |
| 3301 } | |
| 3302 | |
| 3303 #ifdef XML_DTD | |
| 3304 | |
| 3305 /* The idea here is to avoid using stack for each IGNORE section when | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3306 the whole file is parsed with one call. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3307 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3308 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3309 ignoreSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3310 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3311 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3312 const char **endPtr) |
| 21930 | 3313 { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3314 enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3315 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3316 if (result != XML_ERROR_NONE) |
| 3317 return result; | |
| 21930 | 3318 if (start) { |
| 3319 processor = prologProcessor; | |
| 3320 return prologProcessor(parser, start, end, endPtr); | |
| 3321 } | |
| 3322 return result; | |
| 3323 } | |
| 3324 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3325 /* startPtr gets set to non-null is the section is closed, and to null |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3326 if the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3327 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3328 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3329 doIgnoreSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3330 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3331 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3332 const char *end, |
| 32911 | 3333 const char **nextPtr, |
| 3334 XML_Bool haveMore) | |
| 21930 | 3335 { |
| 3336 const char *next; | |
| 3337 int tok; | |
| 3338 const char *s = *startPtr; | |
| 3339 const char **eventPP; | |
| 3340 const char **eventEndPP; | |
| 3341 if (enc == encoding) { | |
| 3342 eventPP = &eventPtr; | |
| 3343 *eventPP = s; | |
| 3344 eventEndPP = &eventEndPtr; | |
| 3345 } | |
| 3346 else { | |
| 3347 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3348 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3349 } | |
| 3350 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3351 *startPtr = NULL; |
| 21930 | 3352 tok = XmlIgnoreSectionTok(enc, s, end, &next); |
| 3353 *eventEndPP = next; | |
| 3354 switch (tok) { | |
| 3355 case XML_TOK_IGNORE_SECT: | |
| 3356 if (defaultHandler) | |
| 3357 reportDefault(parser, enc, s, next); | |
| 3358 *startPtr = next; | |
| 32911 | 3359 *nextPtr = next; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3360 if (ps_parsing == XML_FINISHED) |
| 32911 | 3361 return XML_ERROR_ABORTED; |
| 3362 else | |
| 3363 return XML_ERROR_NONE; | |
| 21930 | 3364 case XML_TOK_INVALID: |
| 3365 *eventPP = next; | |
| 3366 return XML_ERROR_INVALID_TOKEN; | |
| 3367 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3368 if (haveMore) { |
| 21930 | 3369 *nextPtr = s; |
| 3370 return XML_ERROR_NONE; | |
| 3371 } | |
| 3372 return XML_ERROR_PARTIAL_CHAR; | |
| 3373 case XML_TOK_PARTIAL: | |
| 3374 case XML_TOK_NONE: | |
| 32911 | 3375 if (haveMore) { |
| 21930 | 3376 *nextPtr = s; |
| 3377 return XML_ERROR_NONE; | |
| 3378 } | |
| 3379 return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ | |
| 3380 default: | |
| 3381 *eventPP = next; | |
| 3382 return XML_ERROR_UNEXPECTED_STATE; | |
| 3383 } | |
| 3384 /* not reached */ | |
| 3385 } | |
| 3386 | |
| 3387 #endif /* XML_DTD */ | |
| 3388 | |
| 3389 static enum XML_Error | |
| 3390 initializeEncoding(XML_Parser parser) | |
| 3391 { | |
| 3392 const char *s; | |
| 3393 #ifdef XML_UNICODE | |
| 3394 char encodingBuf[128]; | |
| 3395 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3396 s = NULL; |
| 21930 | 3397 else { |
| 3398 int i; | |
| 3399 for (i = 0; protocolEncodingName[i]; i++) { | |
| 3400 if (i == sizeof(encodingBuf) - 1 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3401 || (protocolEncodingName[i] & ~0x7f) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3402 encodingBuf[0] = '\0'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3403 break; |
| 21930 | 3404 } |
| 3405 encodingBuf[i] = (char)protocolEncodingName[i]; | |
| 3406 } | |
| 3407 encodingBuf[i] = '\0'; | |
| 3408 s = encodingBuf; | |
| 3409 } | |
| 3410 #else | |
| 3411 s = protocolEncodingName; | |
| 3412 #endif | |
| 3413 if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) | |
| 3414 return XML_ERROR_NONE; | |
| 3415 return handleUnknownEncoding(parser, protocolEncodingName); | |
| 3416 } | |
| 3417 | |
| 3418 static enum XML_Error | |
| 3419 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3420 const char *s, const char *next) |
| 21930 | 3421 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3422 const char *encodingName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3423 const XML_Char *storedEncName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3424 const ENCODING *newEncoding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3425 const char *version = NULL; |
| 21930 | 3426 const char *versionend; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3427 const XML_Char *storedversion = NULL; |
| 21930 | 3428 int standalone = -1; |
| 3429 if (!(ns | |
| 3430 ? XmlParseXmlDeclNS | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3431 : XmlParseXmlDecl)(isGeneralTextEntity, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3432 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3433 s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3434 next, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3435 &eventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3436 &version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3437 &versionend, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3438 &encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3439 &newEncoding, |
| 32911 | 3440 &standalone)) { |
| 3441 if (isGeneralTextEntity) | |
| 3442 return XML_ERROR_TEXT_DECL; | |
| 3443 else | |
| 3444 return XML_ERROR_XML_DECL; | |
| 3445 } | |
| 21930 | 3446 if (!isGeneralTextEntity && standalone == 1) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3447 _dtd->standalone = XML_TRUE; |
| 21930 | 3448 #ifdef XML_DTD |
| 3449 if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) | |
| 3450 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | |
| 3451 #endif /* XML_DTD */ | |
| 3452 } | |
| 3453 if (xmlDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3454 if (encodingName != NULL) { |
| 21930 | 3455 storedEncName = poolStoreString(&temp2Pool, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3456 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3457 encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3458 encodingName |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3459 + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3460 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3461 return XML_ERROR_NO_MEMORY; |
| 21930 | 3462 poolFinish(&temp2Pool); |
| 3463 } | |
| 3464 if (version) { | |
| 3465 storedversion = poolStoreString(&temp2Pool, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3466 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3467 version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3468 versionend - encoding->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3469 if (!storedversion) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3470 return XML_ERROR_NO_MEMORY; |
| 21930 | 3471 } |
| 3472 xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); | |
| 3473 } | |
| 3474 else if (defaultHandler) | |
| 3475 reportDefault(parser, encoding, s, next); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3476 if (protocolEncodingName == NULL) { |
| 21930 | 3477 if (newEncoding) { |
| 3478 if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3479 eventPtr = encodingName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3480 return XML_ERROR_INCORRECT_ENCODING; |
| 21930 | 3481 } |
| 3482 encoding = newEncoding; | |
| 3483 } | |
| 3484 else if (encodingName) { | |
| 3485 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3486 if (!storedEncName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3487 storedEncName = poolStoreString( |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3488 &temp2Pool, encoding, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3489 encodingName + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3490 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3491 return XML_ERROR_NO_MEMORY; |
| 21930 | 3492 } |
| 3493 result = handleUnknownEncoding(parser, storedEncName); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3494 poolClear(&temp2Pool); |
| 21930 | 3495 if (result == XML_ERROR_UNKNOWN_ENCODING) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3496 eventPtr = encodingName; |
| 21930 | 3497 return result; |
| 3498 } | |
| 3499 } | |
| 3500 | |
| 3501 if (storedEncName || storedversion) | |
| 3502 poolClear(&temp2Pool); | |
| 3503 | |
| 3504 return XML_ERROR_NONE; | |
| 3505 } | |
| 3506 | |
| 3507 static enum XML_Error | |
| 3508 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | |
| 3509 { | |
| 3510 if (unknownEncodingHandler) { | |
| 3511 XML_Encoding info; | |
| 3512 int i; | |
| 3513 for (i = 0; i < 256; i++) | |
| 3514 info.map[i] = -1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3515 info.convert = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3516 info.data = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3517 info.release = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3518 if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3519 &info)) { |
| 21930 | 3520 ENCODING *enc; |
| 3521 unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); | |
| 3522 if (!unknownEncodingMem) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3523 if (info.release) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3524 info.release(info.data); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3525 return XML_ERROR_NO_MEMORY; |
| 21930 | 3526 } |
| 3527 enc = (ns | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3528 ? XmlInitUnknownEncodingNS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3529 : XmlInitUnknownEncoding)(unknownEncodingMem, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3530 info.map, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3531 info.convert, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3532 info.data); |
| 21930 | 3533 if (enc) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3534 unknownEncodingData = info.data; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3535 unknownEncodingRelease = info.release; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3536 encoding = enc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3537 return XML_ERROR_NONE; |
| 21930 | 3538 } |
| 3539 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3540 if (info.release != NULL) |
| 21930 | 3541 info.release(info.data); |
| 3542 } | |
| 3543 return XML_ERROR_UNKNOWN_ENCODING; | |
| 3544 } | |
| 3545 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3546 static enum XML_Error PTRCALL |
| 21930 | 3547 prologInitProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3548 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3549 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3550 const char **nextPtr) |
| 21930 | 3551 { |
| 3552 enum XML_Error result = initializeEncoding(parser); | |
| 3553 if (result != XML_ERROR_NONE) | |
| 3554 return result; | |
| 3555 processor = prologProcessor; | |
| 3556 return prologProcessor(parser, s, end, nextPtr); | |
| 3557 } | |
| 3558 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3559 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3560 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3561 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3562 externalParEntInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3563 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3564 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3565 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3566 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3567 enum XML_Error result = initializeEncoding(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3568 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3569 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3570 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3571 /* we know now that XML_Parse(Buffer) has been called, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3572 so we consider the external parameter entity read */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3573 _dtd->paramEntityRead = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3574 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3575 if (prologState.inEntityValue) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3576 processor = entityValueInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3577 return entityValueInitProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3578 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3579 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3580 processor = externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3581 return externalParEntProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3582 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3583 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3584 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3585 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3586 entityValueInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3587 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3588 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3589 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3590 { |
| 32911 | 3591 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3592 const char *start = s; |
| 32911 | 3593 const char *next = start; |
| 3594 eventPtr = start; | |
| 3595 | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3596 for (;;) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3597 tok = XmlPrologTok(encoding, start, end, &next); |
| 32911 | 3598 eventEndPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3599 if (tok <= 0) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3600 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
| 32911 | 3601 *nextPtr = s; |
| 3602 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3603 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3604 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3605 case XML_TOK_INVALID: |
| 32911 | 3606 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3607 case XML_TOK_PARTIAL: |
| 32911 | 3608 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3609 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3610 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3611 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3612 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3613 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3614 } |
| 32911 | 3615 /* found end of entity value - can store it now */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3616 return storeEntityValue(parser, encoding, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3617 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3618 else if (tok == XML_TOK_XML_DECL) { |
| 32911 | 3619 enum XML_Error result; |
| 3620 result = processXmlDecl(parser, 0, start, next); | |
| 3621 if (result != XML_ERROR_NONE) | |
| 3622 return result; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3623 switch (ps_parsing) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3624 case XML_SUSPENDED: |
| 32911 | 3625 *nextPtr = next; |
| 3626 return XML_ERROR_NONE; | |
| 3627 case XML_FINISHED: | |
| 3628 return XML_ERROR_ABORTED; | |
| 3629 default: | |
| 3630 *nextPtr = next; | |
| 3631 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3632 /* stop scanning for text declaration - we found one */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3633 processor = entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3634 return entityValueProcessor(parser, next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3635 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3636 /* If we are at the end of the buffer, this would cause XmlPrologTok to |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3637 return XML_TOK_NONE on the next call, which would then cause the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3638 function to exit with *nextPtr set to s - that is what we want for other |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3639 tokens, but not for the BOM - we would rather like to skip it; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3640 then, when this routine is entered the next time, XmlPrologTok will |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3641 return XML_TOK_INVALID, since the BOM is still in the buffer |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3642 */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3643 else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3644 *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3645 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3646 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3647 start = next; |
| 32911 | 3648 eventPtr = start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3649 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3650 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3651 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3652 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3653 externalParEntProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3654 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3655 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3656 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3657 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3658 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3659 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3660 |
| 32911 | 3661 tok = XmlPrologTok(encoding, s, end, &next); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3662 if (tok <= 0) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3663 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3664 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3665 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3666 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3667 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3668 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3669 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3670 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3671 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3672 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3673 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3674 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3675 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3676 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3677 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3678 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3679 /* This would cause the next stage, i.e. doProlog to be passed XML_TOK_BOM. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3680 However, when parsing an external subset, doProlog will not accept a BOM |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3681 as valid, and report a syntax error, so we have to skip the BOM |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3682 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3683 else if (tok == XML_TOK_BOM) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3684 s = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3685 tok = XmlPrologTok(encoding, s, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3686 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3687 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3688 processor = prologProcessor; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3689 return doProlog(parser, encoding, s, end, tok, next, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3690 nextPtr, (XML_Bool)!ps_finalBuffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3691 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3692 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3693 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3694 entityValueProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3695 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3696 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3697 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3698 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3699 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3700 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3701 const ENCODING *enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3702 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3703 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3704 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3705 tok = XmlPrologTok(enc, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3706 if (tok <= 0) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3707 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3708 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3709 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3710 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3711 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3712 case XML_TOK_INVALID: |
| 32911 | 3713 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3714 case XML_TOK_PARTIAL: |
| 32911 | 3715 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3716 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3717 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3718 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3719 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3720 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3721 } |
| 32911 | 3722 /* found end of entity value - can store it now */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3723 return storeEntityValue(parser, enc, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3724 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3725 start = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3726 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3727 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3728 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3729 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3730 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3731 static enum XML_Error PTRCALL |
| 21930 | 3732 prologProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3733 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3734 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3735 const char **nextPtr) |
| 21930 | 3736 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3737 const char *next = s; |
| 21930 | 3738 int tok = XmlPrologTok(encoding, s, end, &next); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3739 return doProlog(parser, encoding, s, end, tok, next, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3740 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 21930 | 3741 } |
| 3742 | |
| 3743 static enum XML_Error | |
| 3744 doProlog(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3745 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3746 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3747 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3748 int tok, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3749 const char *next, |
| 32911 | 3750 const char **nextPtr, |
| 3751 XML_Bool haveMore) | |
| 21930 | 3752 { |
| 3753 #ifdef XML_DTD | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3754 static const XML_Char externalSubsetName[] = { ASCII_HASH , '\0' }; |
| 21930 | 3755 #endif /* XML_DTD */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3756 static const XML_Char atypeCDATA[] = |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3757 { ASCII_C, ASCII_D, ASCII_A, ASCII_T, ASCII_A, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3758 static const XML_Char atypeID[] = { ASCII_I, ASCII_D, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3759 static const XML_Char atypeIDREF[] = |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3760 { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3761 static const XML_Char atypeIDREFS[] = |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3762 { ASCII_I, ASCII_D, ASCII_R, ASCII_E, ASCII_F, ASCII_S, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3763 static const XML_Char atypeENTITY[] = |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3764 { ASCII_E, ASCII_N, ASCII_T, ASCII_I, ASCII_T, ASCII_Y, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3765 static const XML_Char atypeENTITIES[] = { ASCII_E, ASCII_N, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3766 ASCII_T, ASCII_I, ASCII_T, ASCII_I, ASCII_E, ASCII_S, '\0' }; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3767 static const XML_Char atypeNMTOKEN[] = { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3768 ASCII_N, ASCII_M, ASCII_T, ASCII_O, ASCII_K, ASCII_E, ASCII_N, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3769 static const XML_Char atypeNMTOKENS[] = { ASCII_N, ASCII_M, ASCII_T, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3770 ASCII_O, ASCII_K, ASCII_E, ASCII_N, ASCII_S, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3771 static const XML_Char notationPrefix[] = { ASCII_N, ASCII_O, ASCII_T, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3772 ASCII_A, ASCII_T, ASCII_I, ASCII_O, ASCII_N, ASCII_LPAREN, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3773 static const XML_Char enumValueSep[] = { ASCII_PIPE, '\0' }; |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3774 static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3775 |
| 32911 | 3776 /* save one level of indirection */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3777 DTD * const dtd = _dtd; |
| 21930 | 3778 |
| 3779 const char **eventPP; | |
| 3780 const char **eventEndPP; | |
| 3781 enum XML_Content_Quant quant; | |
| 3782 | |
| 3783 if (enc == encoding) { | |
| 3784 eventPP = &eventPtr; | |
| 3785 eventEndPP = &eventEndPtr; | |
| 3786 } | |
| 3787 else { | |
| 3788 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3789 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3790 } | |
| 32911 | 3791 |
| 21930 | 3792 for (;;) { |
| 3793 int role; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3794 XML_Bool handleDefault = XML_TRUE; |
| 21930 | 3795 *eventPP = s; |
| 3796 *eventEndPP = next; | |
| 3797 if (tok <= 0) { | |
| 32911 | 3798 if (haveMore && tok != XML_TOK_INVALID) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3799 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3800 return XML_ERROR_NONE; |
| 21930 | 3801 } |
| 3802 switch (tok) { | |
| 3803 case XML_TOK_INVALID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3804 *eventPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3805 return XML_ERROR_INVALID_TOKEN; |
| 21930 | 3806 case XML_TOK_PARTIAL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3807 return XML_ERROR_UNCLOSED_TOKEN; |
| 21930 | 3808 case XML_TOK_PARTIAL_CHAR: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3809 return XML_ERROR_PARTIAL_CHAR; |
|
58439
1f715a377ed0
Merged revisions 77680 via svnmerge from
Matthias Klose <doko@ubuntu.com>
parents:
39610
diff
changeset
|
3810 case -XML_TOK_PROLOG_S: |
|
1f715a377ed0
Merged revisions 77680 via svnmerge from
Matthias Klose <doko@ubuntu.com>
parents:
39610
diff
changeset
|
3811 tok = -tok; |
|
1f715a377ed0
Merged revisions 77680 via svnmerge from
Matthias Klose <doko@ubuntu.com>
parents:
39610
diff
changeset
|
3812 break; |
| 21930 | 3813 case XML_TOK_NONE: |
| 3814 #ifdef XML_DTD | |
| 32911 | 3815 /* for internal PE NOT referenced between declarations */ |
| 3816 if (enc != encoding && !openInternalEntities->betweenDecl) { | |
| 3817 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3818 return XML_ERROR_NONE; |
| 32911 | 3819 } |
| 3820 /* WFC: PE Between Declarations - must check that PE contains | |
| 3821 complete markup, not only for external PEs, but also for | |
| 3822 internal PEs if the reference occurs between declarations. | |
| 3823 */ | |
| 3824 if (isParamEntity || enc != encoding) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3825 if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3826 == XML_ROLE_ERROR) |
| 32911 | 3827 return XML_ERROR_INCOMPLETE_PE; |
| 3828 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3829 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3830 } |
| 21930 | 3831 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3832 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 3833 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3834 tok = -tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3835 next = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3836 break; |
| 21930 | 3837 } |
| 3838 } | |
| 3839 role = XmlTokenRole(&prologState, tok, s, next, enc); | |
| 3840 switch (role) { | |
| 3841 case XML_ROLE_XML_DECL: | |
| 3842 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3843 enum XML_Error result = processXmlDecl(parser, 0, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3844 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3845 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3846 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3847 handleDefault = XML_FALSE; |
| 21930 | 3848 } |
| 3849 break; | |
| 3850 case XML_ROLE_DOCTYPE_NAME: | |
| 3851 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3852 doctypeName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3853 if (!doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3854 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3855 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3856 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3857 handleDefault = XML_FALSE; |
| 21930 | 3858 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3859 doctypeSysid = NULL; /* always initialize to NULL */ |
| 21930 | 3860 break; |
| 3861 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | |
| 3862 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3863 startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3864 doctypePubid, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3865 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3866 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3867 handleDefault = XML_FALSE; |
| 21930 | 3868 } |
| 3869 break; | |
| 3870 #ifdef XML_DTD | |
| 3871 case XML_ROLE_TEXT_DECL: | |
| 3872 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3873 enum XML_Error result = processXmlDecl(parser, 1, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3874 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3875 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3876 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3877 handleDefault = XML_FALSE; |
| 21930 | 3878 } |
| 3879 break; | |
| 3880 #endif /* XML_DTD */ | |
| 3881 case XML_ROLE_DOCTYPE_PUBLIC_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3882 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3883 useForeignDTD = XML_FALSE; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
3884 declEntity = (ENTITY *)lookup(parser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
3885 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3886 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3887 sizeof(ENTITY)); |
| 21930 | 3888 if (!declEntity) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3889 return XML_ERROR_NO_MEMORY; |
| 21930 | 3890 #endif /* XML_DTD */ |
| 32911 | 3891 dtd->hasParamEntityRefs = XML_TRUE; |
| 3892 if (startDoctypeDeclHandler) { | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3893 XML_Char *pubId; |
| 32911 | 3894 if (!XmlIsPublicId(enc, s, next, eventPP)) |
| 3895 return XML_ERROR_PUBLICID; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3896 pubId = poolStoreString(&tempPool, enc, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3897 s + enc->minBytesPerChar, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3898 next - enc->minBytesPerChar); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3899 if (!pubId) |
| 32911 | 3900 return XML_ERROR_NO_MEMORY; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3901 normalizePublicId(pubId); |
| 32911 | 3902 poolFinish(&tempPool); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3903 doctypePubid = pubId; |
| 32911 | 3904 handleDefault = XML_FALSE; |
| 3905 goto alreadyChecked; | |
| 3906 } | |
| 21930 | 3907 /* fall through */ |
| 3908 case XML_ROLE_ENTITY_PUBLIC_ID: | |
| 3909 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 3910 return XML_ERROR_PUBLICID; |
| 3911 alreadyChecked: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3912 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3913 XML_Char *tem = poolStoreString(&dtd->pool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3914 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3915 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3916 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3917 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3918 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3919 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3920 declEntity->publicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3921 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3922 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3923 handleDefault = XML_FALSE; |
| 21930 | 3924 } |
| 3925 break; | |
| 3926 case XML_ROLE_DOCTYPE_CLOSE: | |
| 3927 if (doctypeName) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3928 startDoctypeDeclHandler(handlerArg, doctypeName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3929 doctypeSysid, doctypePubid, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3930 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3931 handleDefault = XML_FALSE; |
| 21930 | 3932 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3933 /* doctypeSysid will be non-NULL in the case of a previous |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3934 XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3935 was not set, indicating an external subset |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3936 */ |
| 21930 | 3937 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3938 if (doctypeSysid || useForeignDTD) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3939 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3940 dtd->hasParamEntityRefs = XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3941 if (paramEntityParsing && externalEntityRefHandler) { |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
3942 ENTITY *entity = (ENTITY *)lookup(parser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
3943 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3944 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3945 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3946 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3947 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3948 if (useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3949 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3950 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3951 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3952 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3953 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3954 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3955 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3956 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3957 if (dtd->paramEntityRead) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3958 if (!dtd->standalone && |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
3959 notStandaloneHandler && |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3960 !notStandaloneHandler(handlerArg)) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3961 return XML_ERROR_NOT_STANDALONE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3962 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3963 /* if we didn't read the foreign DTD then this means that there |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3964 is no external subset and we must reset dtd->hasParamEntityRefs |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3965 */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3966 else if (!doctypeSysid) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3967 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3968 /* end of DTD - no need to update dtd->keepProcessing */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3969 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3970 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3971 } |
| 21930 | 3972 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3973 if (endDoctypeDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3974 endDoctypeDeclHandler(handlerArg); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3975 handleDefault = XML_FALSE; |
| 21930 | 3976 } |
| 3977 break; | |
| 3978 case XML_ROLE_INSTANCE_START: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3979 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3980 /* if there is no DOCTYPE declaration then now is the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3981 last chance to read the foreign DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3982 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3983 if (useForeignDTD) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
3984 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3985 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3986 if (paramEntityParsing && externalEntityRefHandler) { |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
3987 ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3988 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3989 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3990 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3991 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3992 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3993 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3994 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3995 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3996 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3997 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3998 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3999 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4000 if (dtd->paramEntityRead) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4001 if (!dtd->standalone && |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4002 notStandaloneHandler && |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4003 !notStandaloneHandler(handlerArg)) |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4004 return XML_ERROR_NOT_STANDALONE; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4005 } |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4006 /* if we didn't read the foreign DTD then this means that there |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4007 is no external subset and we must reset dtd->hasParamEntityRefs |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4008 */ |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4009 else |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4010 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4011 /* end of DTD - no need to update dtd->keepProcessing */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4012 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4013 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4014 #endif /* XML_DTD */ |
| 21930 | 4015 processor = contentProcessor; |
| 4016 return contentProcessor(parser, s, end, nextPtr); | |
| 4017 case XML_ROLE_ATTLIST_ELEMENT_NAME: | |
| 4018 declElementType = getElementType(parser, enc, s, next); | |
| 4019 if (!declElementType) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4020 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4021 goto checkAttListDeclHandler; |
| 21930 | 4022 case XML_ROLE_ATTRIBUTE_NAME: |
| 4023 declAttributeId = getAttributeId(parser, enc, s, next); | |
| 4024 if (!declAttributeId) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4025 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4026 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4027 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4028 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4029 goto checkAttListDeclHandler; |
| 21930 | 4030 case XML_ROLE_ATTRIBUTE_TYPE_CDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4031 declAttributeIsCdata = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4032 declAttributeType = atypeCDATA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4033 goto checkAttListDeclHandler; |
| 21930 | 4034 case XML_ROLE_ATTRIBUTE_TYPE_ID: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4035 declAttributeIsId = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4036 declAttributeType = atypeID; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4037 goto checkAttListDeclHandler; |
| 21930 | 4038 case XML_ROLE_ATTRIBUTE_TYPE_IDREF: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4039 declAttributeType = atypeIDREF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4040 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4041 case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4042 declAttributeType = atypeIDREFS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4043 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4044 case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4045 declAttributeType = atypeENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4046 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4047 case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4048 declAttributeType = atypeENTITIES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4049 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4050 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4051 declAttributeType = atypeNMTOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4052 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4053 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4054 declAttributeType = atypeNMTOKENS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4055 checkAttListDeclHandler: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4056 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4057 handleDefault = XML_FALSE; |
| 21930 | 4058 break; |
| 4059 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | |
| 4060 case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4061 if (dtd->keepProcessing && attlistDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4062 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4063 if (declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4064 prefix = enumValueSep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4065 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4066 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4067 prefix = (role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4068 ? notationPrefix |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4069 : enumValueStart); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4070 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4071 if (!poolAppendString(&tempPool, prefix)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4072 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4073 if (!poolAppend(&tempPool, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4074 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4075 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4076 handleDefault = XML_FALSE; |
| 21930 | 4077 } |
| 4078 break; | |
| 4079 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | |
| 4080 case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4081 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4082 if (!defineAttribute(declElementType, declAttributeId, |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4083 declAttributeIsCdata, declAttributeIsId, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4084 0, parser)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4085 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4086 if (attlistDeclHandler && declAttributeType) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4087 if (*declAttributeType == XML_T(ASCII_LPAREN) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4088 || (*declAttributeType == XML_T(ASCII_N) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4089 && declAttributeType[1] == XML_T(ASCII_O))) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4090 /* Enumerated or Notation type */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4091 if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4092 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4093 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4094 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4095 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4096 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4097 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4098 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4099 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4100 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4101 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4102 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4103 } |
| 21930 | 4104 } |
| 4105 break; | |
| 4106 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: | |
| 4107 case XML_ROLE_FIXED_ATTRIBUTE_VALUE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4108 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4109 const XML_Char *attVal; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4110 enum XML_Error result = |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4111 storeAttributeValue(parser, enc, declAttributeIsCdata, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4112 s + enc->minBytesPerChar, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4113 next - enc->minBytesPerChar, |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
4114 &dtd->pool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4115 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4116 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4117 attVal = poolStart(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4118 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4119 /* ID attributes aren't allowed to have a default */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4120 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4121 declAttributeIsCdata, XML_FALSE, attVal, parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4122 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4123 if (attlistDeclHandler && declAttributeType) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4124 if (*declAttributeType == XML_T(ASCII_LPAREN) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4125 || (*declAttributeType == XML_T(ASCII_N) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4126 && declAttributeType[1] == XML_T(ASCII_O))) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4127 /* Enumerated or Notation type */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4128 if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4129 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4130 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4131 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4132 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4133 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4134 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4135 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4136 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4137 attVal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4138 role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4139 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4140 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4141 } |
| 21930 | 4142 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4143 break; |
| 21930 | 4144 case XML_ROLE_ENTITY_VALUE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4145 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4146 enum XML_Error result = storeEntityValue(parser, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4147 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4148 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4149 if (declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4150 declEntity->textPtr = poolStart(&dtd->entityValuePool); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4151 declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4152 poolFinish(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4153 if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4154 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4155 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4156 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4157 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4158 declEntity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4159 declEntity->textLen, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4160 curBase, 0, 0, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4161 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4162 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4163 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4164 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4165 poolDiscard(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4166 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4167 return result; |
| 21930 | 4168 } |
| 4169 break; | |
| 4170 case XML_ROLE_DOCTYPE_SYSTEM_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4171 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4172 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4173 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4174 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 4175 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4176 doctypeSysid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4177 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4178 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4179 if (doctypeSysid == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4180 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4181 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4182 handleDefault = XML_FALSE; |
| 21930 | 4183 } |
| 4184 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4185 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4186 /* use externalSubsetName to make doctypeSysid non-NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4187 for the case where no startDoctypeDeclHandler is set */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4188 doctypeSysid = externalSubsetName; |
| 21930 | 4189 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4190 if (!dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4191 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4192 && !paramEntityParsing |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4193 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4194 && notStandaloneHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4195 && !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4196 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4197 #ifndef XML_DTD |
| 4198 break; | |
| 4199 #else /* XML_DTD */ | |
| 4200 if (!declEntity) { | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
4201 declEntity = (ENTITY *)lookup(parser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
4202 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4203 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4204 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4205 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4206 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4207 declEntity->publicId = NULL; |
| 21930 | 4208 } |
| 4209 /* fall through */ | |
| 4210 #endif /* XML_DTD */ | |
| 4211 case XML_ROLE_ENTITY_SYSTEM_ID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4212 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4213 declEntity->systemId = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4214 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4215 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4216 if (!declEntity->systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4217 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4218 declEntity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4219 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4220 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4221 handleDefault = XML_FALSE; |
| 21930 | 4222 } |
| 4223 break; | |
| 4224 case XML_ROLE_ENTITY_COMPLETE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4225 if (dtd->keepProcessing && declEntity && entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4226 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4227 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4228 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4229 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4230 0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4231 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4232 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4233 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4234 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4235 handleDefault = XML_FALSE; |
| 21930 | 4236 } |
| 4237 break; | |
| 4238 case XML_ROLE_ENTITY_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4239 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4240 declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4241 if (!declEntity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4242 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4243 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4244 if (unparsedEntityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4245 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4246 unparsedEntityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4247 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4248 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4249 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4250 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4251 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4252 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4253 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4254 else if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4255 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4256 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4257 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4258 0,0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4259 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4260 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4261 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4262 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4263 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4264 } |
| 21930 | 4265 } |
| 4266 break; | |
| 4267 case XML_ROLE_GENERAL_ENTITY_NAME: | |
| 4268 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4269 if (XmlPredefinedEntityName(enc, s, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4270 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4271 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4272 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4273 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4274 const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4275 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4276 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
4277 declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4278 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4279 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4280 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4281 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4282 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4283 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4284 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4285 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4286 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4287 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4288 declEntity->is_param = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4289 /* if we have a parent parser or are reading an internal parameter |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4290 entity, then the entity declaration is not considered "internal" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4291 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4292 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4293 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4294 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4295 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4296 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4297 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4298 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4299 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4300 } |
| 21930 | 4301 } |
| 4302 break; | |
| 4303 case XML_ROLE_PARAM_ENTITY_NAME: | |
| 4304 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4305 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4306 const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4307 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4308 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
4309 declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4310 name, sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4311 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4312 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4313 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4314 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4315 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4316 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4317 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4318 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4319 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4320 declEntity->is_param = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4321 /* if we have a parent parser or are reading an internal parameter |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4322 entity, then the entity declaration is not considered "internal" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4323 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4324 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4325 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4326 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4327 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4328 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4329 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4330 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4331 declEntity = NULL; |
| 21930 | 4332 } |
| 4333 #else /* not XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4334 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4335 #endif /* XML_DTD */ |
| 21930 | 4336 break; |
| 4337 case XML_ROLE_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4338 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4339 declNotationName = NULL; |
| 21930 | 4340 if (notationDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4341 declNotationName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4342 if (!declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4343 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4344 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4345 handleDefault = XML_FALSE; |
| 21930 | 4346 } |
| 4347 break; | |
| 4348 case XML_ROLE_NOTATION_PUBLIC_ID: | |
| 4349 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 4350 return XML_ERROR_PUBLICID; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4351 if (declNotationName) { /* means notationDeclHandler != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4352 XML_Char *tem = poolStoreString(&tempPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4353 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4354 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4355 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4356 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4357 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4358 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4359 declNotationPublicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4360 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4361 handleDefault = XML_FALSE; |
| 21930 | 4362 } |
| 4363 break; | |
| 4364 case XML_ROLE_NOTATION_SYSTEM_ID: | |
| 4365 if (declNotationName && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4366 const XML_Char *systemId |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4367 = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4368 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4369 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4370 if (!systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4371 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4372 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4373 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4374 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4375 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4376 systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4377 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4378 handleDefault = XML_FALSE; |
| 21930 | 4379 } |
| 4380 poolClear(&tempPool); | |
| 4381 break; | |
| 4382 case XML_ROLE_NOTATION_NO_SYSTEM_ID: | |
| 4383 if (declNotationPublicId && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4384 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4385 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4386 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4387 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4388 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4389 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4390 handleDefault = XML_FALSE; |
| 21930 | 4391 } |
| 4392 poolClear(&tempPool); | |
| 4393 break; | |
| 4394 case XML_ROLE_ERROR: | |
| 4395 switch (tok) { | |
| 4396 case XML_TOK_PARAM_ENTITY_REF: | |
| 32911 | 4397 /* PE references in internal subset are |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4398 not allowed within declarations. */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4399 return XML_ERROR_PARAM_ENTITY_REF; |
| 21930 | 4400 case XML_TOK_XML_DECL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4401 return XML_ERROR_MISPLACED_XML_PI; |
| 21930 | 4402 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4403 return XML_ERROR_SYNTAX; |
| 21930 | 4404 } |
| 4405 #ifdef XML_DTD | |
| 4406 case XML_ROLE_IGNORE_SECT: | |
| 4407 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4408 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4409 if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4410 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4411 handleDefault = XML_FALSE; |
| 32911 | 4412 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); |
| 4413 if (result != XML_ERROR_NONE) | |
| 4414 return result; | |
| 4415 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4416 processor = ignoreSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4417 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4418 } |
| 21930 | 4419 } |
| 4420 break; | |
| 4421 #endif /* XML_DTD */ | |
| 4422 case XML_ROLE_GROUP_OPEN: | |
| 4423 if (prologState.level >= groupSize) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4424 if (groupSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4425 char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4426 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4427 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4428 groupConnector = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4429 if (dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4430 int *temp = (int *)REALLOC(dtd->scaffIndex, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4431 groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4432 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4433 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4434 dtd->scaffIndex = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4435 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4436 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4437 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4438 groupConnector = (char *)MALLOC(groupSize = 32); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4439 if (!groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4440 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4441 } |
| 21930 | 4442 } |
| 4443 groupConnector[prologState.level] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4444 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4445 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4446 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4447 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4448 dtd->scaffIndex[dtd->scaffLevel] = myindex; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4449 dtd->scaffLevel++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4450 dtd->scaffold[myindex].type = XML_CTYPE_SEQ; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4451 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4452 handleDefault = XML_FALSE; |
| 21930 | 4453 } |
| 4454 break; | |
| 4455 case XML_ROLE_GROUP_SEQUENCE: | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4456 if (groupConnector[prologState.level] == ASCII_PIPE) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4457 return XML_ERROR_SYNTAX; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4458 groupConnector[prologState.level] = ASCII_COMMA; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4459 if (dtd->in_eldecl && elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4460 handleDefault = XML_FALSE; |
| 21930 | 4461 break; |
| 4462 case XML_ROLE_GROUP_CHOICE: | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4463 if (groupConnector[prologState.level] == ASCII_COMMA) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4464 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4465 if (dtd->in_eldecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4466 && !groupConnector[prologState.level] |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4467 && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4468 != XML_CTYPE_MIXED) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4469 ) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4470 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4471 = XML_CTYPE_CHOICE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4472 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4473 handleDefault = XML_FALSE; |
| 21930 | 4474 } |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4475 groupConnector[prologState.level] = ASCII_PIPE; |
| 21930 | 4476 break; |
| 4477 case XML_ROLE_PARAM_ENTITY_REF: | |
| 4478 #ifdef XML_DTD | |
| 4479 case XML_ROLE_INNER_PARAM_ENTITY_REF: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4480 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4481 if (!paramEntityParsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4482 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4483 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4484 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4485 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4486 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4487 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4488 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4489 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4490 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
4491 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4492 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4493 /* first, determine if a check for an existing declaration is needed; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4494 if yes, check that the entity exists, and that it is internal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4495 otherwise call the skipped entity handler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4496 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4497 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4498 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4499 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4500 : !dtd->hasParamEntityRefs)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4501 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4502 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4503 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4504 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4505 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4506 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4507 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4508 /* cannot report skipped entities in declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4509 if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4510 skippedEntityHandler(handlerArg, name, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4511 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4512 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4513 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4514 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4515 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4516 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4517 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4518 enum XML_Error result; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4519 XML_Bool betweenDecl = |
| 32911 | 4520 (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); |
| 4521 result = processInternalEntity(parser, entity, betweenDecl); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4522 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4523 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4524 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4525 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4526 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4527 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4528 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4529 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4530 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4531 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4532 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4533 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4534 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4535 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4536 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4537 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4538 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4539 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4540 if (!dtd->paramEntityRead) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4541 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4542 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4543 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4544 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4545 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4546 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4547 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4548 } |
| 21930 | 4549 } |
| 4550 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4551 if (!dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4552 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4553 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4554 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4555 break; |
| 4556 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4557 /* Element declaration stuff */ |
| 21930 | 4558 |
| 4559 case XML_ROLE_ELEMENT_NAME: | |
| 4560 if (elementDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4561 declElementType = getElementType(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4562 if (!declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4563 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4564 dtd->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4565 dtd->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4566 dtd->in_eldecl = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4567 handleDefault = XML_FALSE; |
| 21930 | 4568 } |
| 4569 break; | |
| 4570 | |
| 4571 case XML_ROLE_CONTENT_ANY: | |
| 4572 case XML_ROLE_CONTENT_EMPTY: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4573 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4574 if (elementDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4575 XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4576 if (!content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4577 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4578 content->quant = XML_CQUANT_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4579 content->name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4580 content->numchildren = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4581 content->children = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4582 content->type = ((role == XML_ROLE_CONTENT_ANY) ? |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4583 XML_CTYPE_ANY : |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4584 XML_CTYPE_EMPTY); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4585 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4586 elementDeclHandler(handlerArg, declElementType->name, content); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4587 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4588 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4589 dtd->in_eldecl = XML_FALSE; |
| 21930 | 4590 } |
| 4591 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4592 |
| 21930 | 4593 case XML_ROLE_CONTENT_PCDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4594 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4595 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4596 = XML_CTYPE_MIXED; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4597 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4598 handleDefault = XML_FALSE; |
| 21930 | 4599 } |
| 4600 break; | |
| 4601 | |
| 4602 case XML_ROLE_CONTENT_ELEMENT: | |
| 4603 quant = XML_CQUANT_NONE; | |
| 4604 goto elementContent; | |
| 4605 case XML_ROLE_CONTENT_ELEMENT_OPT: | |
| 4606 quant = XML_CQUANT_OPT; | |
| 4607 goto elementContent; | |
| 4608 case XML_ROLE_CONTENT_ELEMENT_REP: | |
| 4609 quant = XML_CQUANT_REP; | |
| 4610 goto elementContent; | |
| 4611 case XML_ROLE_CONTENT_ELEMENT_PLUS: | |
| 4612 quant = XML_CQUANT_PLUS; | |
| 4613 elementContent: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4614 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4615 ELEMENT_TYPE *el; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4616 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4617 int nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4618 const char *nxt = (quant == XML_CQUANT_NONE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4619 ? next |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4620 : next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4621 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4622 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4623 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4624 dtd->scaffold[myindex].type = XML_CTYPE_NAME; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4625 dtd->scaffold[myindex].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4626 el = getElementType(parser, enc, s, nxt); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4627 if (!el) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4628 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4629 name = el->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4630 dtd->scaffold[myindex].name = name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4631 nameLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4632 for (; name[nameLen++]; ); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4633 dtd->contentStringLen += nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4634 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4635 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4636 } |
| 21930 | 4637 break; |
| 4638 | |
| 4639 case XML_ROLE_GROUP_CLOSE: | |
| 4640 quant = XML_CQUANT_NONE; | |
| 4641 goto closeGroup; | |
| 4642 case XML_ROLE_GROUP_CLOSE_OPT: | |
| 4643 quant = XML_CQUANT_OPT; | |
| 4644 goto closeGroup; | |
| 4645 case XML_ROLE_GROUP_CLOSE_REP: | |
| 4646 quant = XML_CQUANT_REP; | |
| 4647 goto closeGroup; | |
| 4648 case XML_ROLE_GROUP_CLOSE_PLUS: | |
| 4649 quant = XML_CQUANT_PLUS; | |
| 4650 closeGroup: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4651 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4652 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4653 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4654 dtd->scaffLevel--; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4655 dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4656 if (dtd->scaffLevel == 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4657 if (!handleDefault) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4658 XML_Content *model = build_model(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4659 if (!model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4660 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4661 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4662 elementDeclHandler(handlerArg, declElementType->name, model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4663 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4664 dtd->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4665 dtd->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4666 } |
| 21930 | 4667 } |
| 4668 break; | |
| 4669 /* End element declaration stuff */ | |
| 4670 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4671 case XML_ROLE_PI: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4672 if (!reportProcessingInstruction(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4673 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4674 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4675 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4676 case XML_ROLE_COMMENT: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4677 if (!reportComment(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4678 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4679 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4680 break; |
| 21930 | 4681 case XML_ROLE_NONE: |
| 4682 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4683 case XML_TOK_BOM: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4684 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4685 break; |
| 21930 | 4686 } |
| 4687 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4688 case XML_ROLE_DOCTYPE_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4689 if (startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4690 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4691 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4692 case XML_ROLE_ENTITY_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4693 if (dtd->keepProcessing && entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4694 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4695 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4696 case XML_ROLE_NOTATION_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4697 if (notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4698 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4699 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4700 case XML_ROLE_ATTLIST_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4701 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4702 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4703 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4704 case XML_ROLE_ELEMENT_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4705 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4706 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4707 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4708 } /* end of big switch */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4709 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4710 if (handleDefault && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4711 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4712 |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4713 switch (ps_parsing) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4714 case XML_SUSPENDED: |
| 32911 | 4715 *nextPtr = next; |
| 4716 return XML_ERROR_NONE; | |
| 4717 case XML_FINISHED: | |
| 4718 return XML_ERROR_ABORTED; | |
| 4719 default: | |
| 4720 s = next; | |
| 4721 tok = XmlPrologTok(enc, s, end, &next); | |
| 4722 } | |
| 21930 | 4723 } |
| 4724 /* not reached */ | |
| 4725 } | |
| 4726 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4727 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4728 epilogProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4729 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4730 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4731 const char **nextPtr) |
| 21930 | 4732 { |
| 4733 processor = epilogProcessor; | |
| 4734 eventPtr = s; | |
| 4735 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4736 const char *next = NULL; |
| 21930 | 4737 int tok = XmlPrologTok(encoding, s, end, &next); |
| 4738 eventEndPtr = next; | |
| 4739 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4740 /* report partial linebreak - it might be the last token */ |
| 21930 | 4741 case -XML_TOK_PROLOG_S: |
| 4742 if (defaultHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4743 reportDefault(parser, encoding, s, next); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4744 if (ps_parsing == XML_FINISHED) |
| 32911 | 4745 return XML_ERROR_ABORTED; |
| 21930 | 4746 } |
| 32911 | 4747 *nextPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4748 return XML_ERROR_NONE; |
| 21930 | 4749 case XML_TOK_NONE: |
| 32911 | 4750 *nextPtr = s; |
| 21930 | 4751 return XML_ERROR_NONE; |
| 4752 case XML_TOK_PROLOG_S: | |
| 4753 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4754 reportDefault(parser, encoding, s, next); |
| 21930 | 4755 break; |
| 4756 case XML_TOK_PI: | |
| 4757 if (!reportProcessingInstruction(parser, encoding, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4758 return XML_ERROR_NO_MEMORY; |
| 21930 | 4759 break; |
| 4760 case XML_TOK_COMMENT: | |
| 4761 if (!reportComment(parser, encoding, s, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4762 return XML_ERROR_NO_MEMORY; |
| 21930 | 4763 break; |
| 4764 case XML_TOK_INVALID: | |
| 4765 eventPtr = next; | |
| 4766 return XML_ERROR_INVALID_TOKEN; | |
| 4767 case XML_TOK_PARTIAL: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4768 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4769 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4770 return XML_ERROR_NONE; |
| 21930 | 4771 } |
| 4772 return XML_ERROR_UNCLOSED_TOKEN; | |
| 4773 case XML_TOK_PARTIAL_CHAR: | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4774 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4775 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4776 return XML_ERROR_NONE; |
| 21930 | 4777 } |
| 4778 return XML_ERROR_PARTIAL_CHAR; | |
| 4779 default: | |
| 4780 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | |
| 4781 } | |
| 4782 eventPtr = s = next; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4783 switch (ps_parsing) { |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4784 case XML_SUSPENDED: |
| 32911 | 4785 *nextPtr = next; |
| 4786 return XML_ERROR_NONE; | |
| 4787 case XML_FINISHED: | |
| 4788 return XML_ERROR_ABORTED; | |
| 4789 default: ; | |
| 4790 } | |
| 21930 | 4791 } |
| 4792 } | |
| 4793 | |
| 4794 static enum XML_Error | |
| 32911 | 4795 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 4796 XML_Bool betweenDecl) | |
| 21930 | 4797 { |
| 32911 | 4798 const char *textStart, *textEnd; |
| 4799 const char *next; | |
| 21930 | 4800 enum XML_Error result; |
| 32911 | 4801 OPEN_INTERNAL_ENTITY *openEntity; |
| 4802 | |
| 4803 if (freeInternalEntities) { | |
| 4804 openEntity = freeInternalEntities; | |
| 4805 freeInternalEntities = openEntity->next; | |
| 4806 } | |
| 4807 else { | |
| 4808 openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); | |
| 4809 if (!openEntity) | |
| 4810 return XML_ERROR_NO_MEMORY; | |
| 4811 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4812 entity->open = XML_TRUE; |
| 32911 | 4813 entity->processed = 0; |
| 4814 openEntity->next = openInternalEntities; | |
| 4815 openInternalEntities = openEntity; | |
| 4816 openEntity->entity = entity; | |
| 4817 openEntity->startTagLevel = tagLevel; | |
| 4818 openEntity->betweenDecl = betweenDecl; | |
| 4819 openEntity->internalEventPtr = NULL; | |
| 4820 openEntity->internalEventEndPtr = NULL; | |
| 4821 textStart = (char *)entity->textPtr; | |
| 4822 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4823 | |
| 4824 #ifdef XML_DTD | |
| 4825 if (entity->is_param) { | |
| 4826 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4827 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, |
| 32911 | 4828 next, &next, XML_FALSE); |
| 4829 } | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4830 else |
| 32911 | 4831 #endif /* XML_DTD */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4832 result = doContent(parser, tagLevel, internalEncoding, textStart, |
| 32911 | 4833 textEnd, &next, XML_FALSE); |
| 4834 | |
| 4835 if (result == XML_ERROR_NONE) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4836 if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4837 entity->processed = (int)(next - textStart); |
| 32911 | 4838 processor = internalEntityProcessor; |
| 4839 } | |
| 4840 else { | |
| 4841 entity->open = XML_FALSE; | |
| 4842 openInternalEntities = openEntity->next; | |
| 4843 /* put openEntity back in list of free instances */ | |
| 4844 openEntity->next = freeInternalEntities; | |
| 4845 freeInternalEntities = openEntity; | |
| 4846 } | |
| 4847 } | |
| 21930 | 4848 return result; |
| 4849 } | |
| 4850 | |
| 32911 | 4851 static enum XML_Error PTRCALL |
| 4852 internalEntityProcessor(XML_Parser parser, | |
| 4853 const char *s, | |
| 4854 const char *end, | |
| 4855 const char **nextPtr) | |
| 4856 { | |
| 4857 ENTITY *entity; | |
| 4858 const char *textStart, *textEnd; | |
| 4859 const char *next; | |
| 4860 enum XML_Error result; | |
| 4861 OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; | |
| 4862 if (!openEntity) | |
| 4863 return XML_ERROR_UNEXPECTED_STATE; | |
| 4864 | |
| 4865 entity = openEntity->entity; | |
| 4866 textStart = ((char *)entity->textPtr) + entity->processed; | |
| 4867 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4868 | |
| 4869 #ifdef XML_DTD | |
| 4870 if (entity->is_param) { | |
| 4871 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4872 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, |
| 32911 | 4873 next, &next, XML_FALSE); |
| 4874 } | |
| 4875 else | |
| 21930 | 4876 #endif /* XML_DTD */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4877 result = doContent(parser, openEntity->startTagLevel, internalEncoding, |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4878 textStart, textEnd, &next, XML_FALSE); |
| 32911 | 4879 |
| 4880 if (result != XML_ERROR_NONE) | |
| 4881 return result; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4882 else if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4883 entity->processed = (int)(next - (char *)entity->textPtr); |
| 32911 | 4884 return result; |
| 4885 } | |
| 4886 else { | |
| 4887 entity->open = XML_FALSE; | |
| 4888 openInternalEntities = openEntity->next; | |
| 4889 /* put openEntity back in list of free instances */ | |
| 4890 openEntity->next = freeInternalEntities; | |
| 4891 freeInternalEntities = openEntity; | |
| 4892 } | |
| 4893 | |
| 4894 #ifdef XML_DTD | |
| 4895 if (entity->is_param) { | |
| 4896 int tok; | |
| 4897 processor = prologProcessor; | |
| 4898 tok = XmlPrologTok(encoding, s, end, &next); | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4899 return doProlog(parser, encoding, s, end, tok, next, nextPtr, |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
4900 (XML_Bool)!ps_finalBuffer); |
| 32911 | 4901 } |
| 4902 else | |
| 4903 #endif /* XML_DTD */ | |
| 4904 { | |
| 4905 processor = contentProcessor; | |
| 4906 /* see externalEntityContentProcessor vs contentProcessor */ | |
| 4907 return doContent(parser, parentParser ? 1 : 0, encoding, s, end, | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4908 nextPtr, (XML_Bool)!ps_finalBuffer); |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
4909 } |
| 32911 | 4910 } |
| 21930 | 4911 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4912 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4913 errorProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4914 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4915 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4916 const char **nextPtr) |
| 21930 | 4917 { |
| 4918 return errorCode; | |
| 4919 } | |
| 4920 | |
| 4921 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4922 storeAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4923 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4924 STRING_POOL *pool) |
| 21930 | 4925 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4926 enum XML_Error result = appendAttributeValue(parser, enc, isCdata, ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4927 end, pool); |
| 21930 | 4928 if (result) |
| 4929 return result; | |
| 4930 if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) | |
| 4931 poolChop(pool); | |
| 4932 if (!poolAppendChar(pool, XML_T('\0'))) | |
| 4933 return XML_ERROR_NO_MEMORY; | |
| 4934 return XML_ERROR_NONE; | |
| 4935 } | |
| 4936 | |
| 4937 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4938 appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4939 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4940 STRING_POOL *pool) |
| 21930 | 4941 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4942 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4943 for (;;) { |
| 4944 const char *next; | |
| 4945 int tok = XmlAttributeValueTok(enc, ptr, end, &next); | |
| 4946 switch (tok) { | |
| 4947 case XML_TOK_NONE: | |
| 4948 return XML_ERROR_NONE; | |
| 4949 case XML_TOK_INVALID: | |
| 4950 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4951 eventPtr = next; |
| 21930 | 4952 return XML_ERROR_INVALID_TOKEN; |
| 4953 case XML_TOK_PARTIAL: | |
| 4954 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4955 eventPtr = ptr; |
| 21930 | 4956 return XML_ERROR_INVALID_TOKEN; |
| 4957 case XML_TOK_CHAR_REF: | |
| 4958 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4959 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4960 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4961 int n = XmlCharRefNumber(enc, ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4962 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4963 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4964 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4965 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4966 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4967 if (!isCdata |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4968 && n == 0x20 /* space */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4969 && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4970 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4971 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4972 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4973 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4974 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4975 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4976 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4977 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4978 if (!poolAppendChar(pool, buf[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4979 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4980 } |
| 21930 | 4981 } |
| 4982 break; | |
| 4983 case XML_TOK_DATA_CHARS: | |
| 4984 if (!poolAppend(pool, enc, ptr, next)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4985 return XML_ERROR_NO_MEMORY; |
| 21930 | 4986 break; |
| 4987 case XML_TOK_TRAILING_CR: | |
| 4988 next = ptr + enc->minBytesPerChar; | |
| 4989 /* fall through */ | |
| 4990 case XML_TOK_ATTRIBUTE_VALUE_S: | |
| 4991 case XML_TOK_DATA_NEWLINE: | |
| 4992 if (!isCdata && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4993 break; |
| 21930 | 4994 if (!poolAppendChar(pool, 0x20)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4995 return XML_ERROR_NO_MEMORY; |
| 21930 | 4996 break; |
| 4997 case XML_TOK_ENTITY_REF: | |
| 4998 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4999 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5000 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5001 char checkEntityDecl; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5002 XML_Char ch = (XML_Char) XmlPredefinedEntityName(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5003 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5004 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5005 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5006 if (!poolAppendChar(pool, ch)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5007 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5008 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5009 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5010 name = poolStoreString(&temp2Pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5011 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5012 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5013 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5014 return XML_ERROR_NO_MEMORY; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5015 entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5016 poolDiscard(&temp2Pool); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5017 /* First, determine if a check for an existing declaration is needed; |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5018 if yes, check that the entity exists, and that it is internal. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5019 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5020 if (pool == &dtd->pool) /* are we called from prolog? */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5021 checkEntityDecl = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5022 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5023 prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5024 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5025 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5026 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5027 : !dtd->hasParamEntityRefs); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5028 else /* if (pool == &tempPool): we are called from content */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5029 checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5030 if (checkEntityDecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5031 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5032 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5033 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5034 return XML_ERROR_ENTITY_DECLARED_IN_PE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5035 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5036 else if (!entity) { |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5037 /* Cannot report skipped entity here - see comments on |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5038 skippedEntityHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5039 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5040 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5041 */ |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5042 /* Cannot call the default handler because this would be |
|
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5043 out of sync with the call to the startElementHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5044 if ((pool == &tempPool) && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5045 reportDefault(parser, enc, ptr, next); |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5046 */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5047 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5048 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5049 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5050 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5051 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5052 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5053 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5054 if (entity->notation) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5055 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5056 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5057 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5058 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5059 if (!entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5060 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5061 eventPtr = ptr; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5062 return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5063 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5064 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5065 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5066 const XML_Char *textEnd = entity->textPtr + entity->textLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5067 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5068 result = appendAttributeValue(parser, internalEncoding, isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5069 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5070 (char *)textEnd, pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5071 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5072 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5073 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5074 } |
| 21930 | 5075 } |
| 5076 break; | |
| 5077 default: | |
| 5078 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5079 eventPtr = ptr; |
| 21930 | 5080 return XML_ERROR_UNEXPECTED_STATE; |
| 5081 } | |
| 5082 ptr = next; | |
| 5083 } | |
| 5084 /* not reached */ | |
| 5085 } | |
| 5086 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5087 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5088 storeEntityValue(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5089 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5090 const char *entityTextPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5091 const char *entityTextEnd) |
| 21930 | 5092 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5093 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5094 STRING_POOL *pool = &(dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5095 enum XML_Error result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5096 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5097 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5098 prologState.inEntityValue = 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5099 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5100 /* never return Null for the value argument in EntityDeclHandler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5101 since this would indicate an external entity; therefore we |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5102 have to make sure that entityValuePool.start is not null */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5103 if (!pool->blocks) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5104 if (!poolGrow(pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5105 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5106 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5107 |
| 21930 | 5108 for (;;) { |
| 5109 const char *next; | |
| 5110 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); | |
| 5111 switch (tok) { | |
| 5112 case XML_TOK_PARAM_ENTITY_REF: | |
| 5113 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5114 if (isParamEntity || enc != encoding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5115 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5116 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5117 name = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5118 entityTextPtr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5119 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5120 if (!name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5121 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5122 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5123 } |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5124 entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5125 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5126 if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5127 /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5128 /* cannot report skipped entity here - see comments on |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5129 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5130 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5131 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5132 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5133 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5134 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5135 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5136 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5137 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5138 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5139 result = XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5140 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5141 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5142 if (entity->systemId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5143 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5144 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5145 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5146 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5147 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5148 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5149 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5150 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5151 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5152 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5153 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5154 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5155 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5156 if (!dtd->paramEntityRead) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5157 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5158 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5159 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5160 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5161 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5162 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5163 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5164 result = storeEntityValue(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5165 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5166 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5167 (char *)(entity->textPtr |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5168 + entity->textLen)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5169 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5170 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5171 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5172 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5173 break; |
| 21930 | 5174 } |
| 5175 #endif /* XML_DTD */ | |
| 32911 | 5176 /* In the internal subset, PE references are not legal |
| 5177 within markup declarations, e.g entity values in this case. */ | |
| 21930 | 5178 eventPtr = entityTextPtr; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5179 result = XML_ERROR_PARAM_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5180 goto endEntityValue; |
| 21930 | 5181 case XML_TOK_NONE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5182 result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5183 goto endEntityValue; |
| 21930 | 5184 case XML_TOK_ENTITY_REF: |
| 5185 case XML_TOK_DATA_CHARS: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5186 if (!poolAppend(pool, enc, entityTextPtr, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5187 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5188 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5189 } |
| 21930 | 5190 break; |
| 5191 case XML_TOK_TRAILING_CR: | |
| 5192 next = entityTextPtr + enc->minBytesPerChar; | |
| 5193 /* fall through */ | |
| 5194 case XML_TOK_DATA_NEWLINE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5195 if (pool->end == pool->ptr && !poolGrow(pool)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5196 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5197 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5198 } |
| 21930 | 5199 *(pool->ptr)++ = 0xA; |
| 5200 break; | |
| 5201 case XML_TOK_CHAR_REF: | |
| 5202 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5203 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5204 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5205 int n = XmlCharRefNumber(enc, entityTextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5206 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5207 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5208 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5209 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5210 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5211 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5212 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5213 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5214 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5215 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5216 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5217 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5218 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5219 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5220 if (pool->end == pool->ptr && !poolGrow(pool)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5221 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5222 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5223 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5224 *(pool->ptr)++ = buf[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5225 } |
| 21930 | 5226 } |
| 5227 break; | |
| 5228 case XML_TOK_PARTIAL: | |
| 5229 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5230 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5231 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5232 goto endEntityValue; |
| 21930 | 5233 case XML_TOK_INVALID: |
| 5234 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5235 eventPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5236 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5237 goto endEntityValue; |
| 21930 | 5238 default: |
| 5239 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5240 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5241 result = XML_ERROR_UNEXPECTED_STATE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5242 goto endEntityValue; |
| 21930 | 5243 } |
| 5244 entityTextPtr = next; | |
| 5245 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5246 endEntityValue: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5247 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5248 prologState.inEntityValue = oldInEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5249 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5250 return result; |
| 21930 | 5251 } |
| 5252 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5253 static void FASTCALL |
| 21930 | 5254 normalizeLines(XML_Char *s) |
| 5255 { | |
| 5256 XML_Char *p; | |
| 5257 for (;; s++) { | |
| 5258 if (*s == XML_T('\0')) | |
| 5259 return; | |
| 5260 if (*s == 0xD) | |
| 5261 break; | |
| 5262 } | |
| 5263 p = s; | |
| 5264 do { | |
| 5265 if (*s == 0xD) { | |
| 5266 *p++ = 0xA; | |
| 5267 if (*++s == 0xA) | |
| 5268 s++; | |
| 5269 } | |
| 5270 else | |
| 5271 *p++ = *s++; | |
| 5272 } while (*s); | |
| 5273 *p = XML_T('\0'); | |
| 5274 } | |
| 5275 | |
| 5276 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5277 reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5278 const char *start, const char *end) |
| 21930 | 5279 { |
| 5280 const XML_Char *target; | |
| 5281 XML_Char *data; | |
| 5282 const char *tem; | |
| 5283 if (!processingInstructionHandler) { | |
| 5284 if (defaultHandler) | |
| 5285 reportDefault(parser, enc, start, end); | |
| 5286 return 1; | |
| 5287 } | |
| 5288 start += enc->minBytesPerChar * 2; | |
| 5289 tem = start + XmlNameLength(enc, start); | |
| 5290 target = poolStoreString(&tempPool, enc, start, tem); | |
| 5291 if (!target) | |
| 5292 return 0; | |
| 5293 poolFinish(&tempPool); | |
| 5294 data = poolStoreString(&tempPool, enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5295 XmlSkipS(enc, tem), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5296 end - enc->minBytesPerChar*2); |
| 21930 | 5297 if (!data) |
| 5298 return 0; | |
| 5299 normalizeLines(data); | |
| 5300 processingInstructionHandler(handlerArg, target, data); | |
| 5301 poolClear(&tempPool); | |
| 5302 return 1; | |
| 5303 } | |
| 5304 | |
| 5305 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5306 reportComment(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5307 const char *start, const char *end) |
| 21930 | 5308 { |
| 5309 XML_Char *data; | |
| 5310 if (!commentHandler) { | |
| 5311 if (defaultHandler) | |
| 5312 reportDefault(parser, enc, start, end); | |
| 5313 return 1; | |
| 5314 } | |
| 5315 data = poolStoreString(&tempPool, | |
| 5316 enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5317 start + enc->minBytesPerChar * 4, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5318 end - enc->minBytesPerChar * 3); |
| 21930 | 5319 if (!data) |
| 5320 return 0; | |
| 5321 normalizeLines(data); | |
| 5322 commentHandler(handlerArg, data); | |
| 5323 poolClear(&tempPool); | |
| 5324 return 1; | |
| 5325 } | |
| 5326 | |
| 5327 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5328 reportDefault(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5329 const char *s, const char *end) |
| 21930 | 5330 { |
| 5331 if (MUST_CONVERT(enc, s)) { | |
| 5332 const char **eventPP; | |
| 5333 const char **eventEndPP; | |
| 5334 if (enc == encoding) { | |
| 5335 eventPP = &eventPtr; | |
| 5336 eventEndPP = &eventEndPtr; | |
| 5337 } | |
| 5338 else { | |
| 5339 eventPP = &(openInternalEntities->internalEventPtr); | |
| 5340 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 5341 } | |
| 5342 do { | |
| 5343 ICHAR *dataPtr = (ICHAR *)dataBuf; | |
| 5344 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | |
| 5345 *eventEndPP = s; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5346 defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); |
| 21930 | 5347 *eventPP = s; |
| 5348 } while (s != end); | |
| 5349 } | |
| 5350 else | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5351 defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 5352 } |
| 5353 | |
| 5354 | |
| 5355 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5356 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5357 XML_Bool isId, const XML_Char *value, XML_Parser parser) |
| 21930 | 5358 { |
| 5359 DEFAULT_ATTRIBUTE *att; | |
| 5360 if (value || isId) { | |
| 5361 /* The handling of default attributes gets messed up if we have | |
| 5362 a default which duplicates a non-default. */ | |
| 5363 int i; | |
| 5364 for (i = 0; i < type->nDefaultAtts; i++) | |
| 5365 if (attId == type->defaultAtts[i].id) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5366 return 1; |
| 21930 | 5367 if (isId && !type->idAtt && !attId->xmlns) |
| 5368 type->idAtt = attId; | |
| 5369 } | |
| 5370 if (type->nDefaultAtts == type->allocDefaultAtts) { | |
| 5371 if (type->allocDefaultAtts == 0) { | |
| 5372 type->allocDefaultAtts = 8; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5373 type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5374 * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5375 if (!type->defaultAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5376 return 0; |
| 21930 | 5377 } |
| 5378 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5379 DEFAULT_ATTRIBUTE *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5380 int count = type->allocDefaultAtts * 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5381 temp = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5382 REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5383 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5384 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5385 type->allocDefaultAtts = count; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5386 type->defaultAtts = temp; |
| 21930 | 5387 } |
| 5388 } | |
| 5389 att = type->defaultAtts + type->nDefaultAtts; | |
| 5390 att->id = attId; | |
| 5391 att->value = value; | |
| 5392 att->isCdata = isCdata; | |
| 5393 if (!isCdata) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5394 attId->maybeTokenized = XML_TRUE; |
| 21930 | 5395 type->nDefaultAtts += 1; |
| 5396 return 1; | |
| 5397 } | |
| 5398 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5399 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5400 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 21930 | 5401 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5402 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5403 const XML_Char *name; |
| 5404 for (name = elementType->name; *name; name++) { | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5405 if (*name == XML_T(ASCII_COLON)) { |
| 21930 | 5406 PREFIX *prefix; |
| 5407 const XML_Char *s; | |
| 5408 for (s = elementType->name; s != name; s++) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5409 if (!poolAppendChar(&dtd->pool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5410 return 0; |
| 21930 | 5411 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5412 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5413 return 0; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5414 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5415 sizeof(PREFIX)); |
| 21930 | 5416 if (!prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5417 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5418 if (prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5419 poolFinish(&dtd->pool); |
| 21930 | 5420 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5421 poolDiscard(&dtd->pool); |
| 21930 | 5422 elementType->prefix = prefix; |
| 5423 | |
| 5424 } | |
| 5425 } | |
| 5426 return 1; | |
| 5427 } | |
| 5428 | |
| 5429 static ATTRIBUTE_ID * | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5430 getAttributeId(XML_Parser parser, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5431 const char *start, const char *end) |
| 21930 | 5432 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5433 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5434 ATTRIBUTE_ID *id; |
| 5435 const XML_Char *name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5436 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5437 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5438 name = poolStoreString(&dtd->pool, enc, start, end); |
| 21930 | 5439 if (!name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5440 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5441 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ |
| 21930 | 5442 ++name; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5443 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); |
| 21930 | 5444 if (!id) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5445 return NULL; |
| 21930 | 5446 if (id->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5447 poolDiscard(&dtd->pool); |
| 21930 | 5448 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5449 poolFinish(&dtd->pool); |
| 21930 | 5450 if (!ns) |
| 5451 ; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5452 else if (name[0] == XML_T(ASCII_x) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5453 && name[1] == XML_T(ASCII_m) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5454 && name[2] == XML_T(ASCII_l) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5455 && name[3] == XML_T(ASCII_n) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5456 && name[4] == XML_T(ASCII_s) |
|
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5457 && (name[5] == XML_T('\0') || name[5] == XML_T(ASCII_COLON))) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5458 if (name[5] == XML_T('\0')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5459 id->prefix = &dtd->defaultPrefix; |
| 21930 | 5460 else |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5461 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, name + 6, sizeof(PREFIX)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5462 id->xmlns = XML_TRUE; |
| 21930 | 5463 } |
| 5464 else { | |
| 5465 int i; | |
| 5466 for (i = 0; name[i]; i++) { | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5467 /* attributes without prefix are *not* in the default namespace */ |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5468 if (name[i] == XML_T(ASCII_COLON)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5469 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5470 for (j = 0; j < i; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5471 if (!poolAppendChar(&dtd->pool, name[j])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5472 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5473 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5474 if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5475 return NULL; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5476 id->prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&dtd->pool), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5477 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5478 if (id->prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5479 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5480 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5481 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5482 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5483 } |
| 21930 | 5484 } |
| 5485 } | |
| 5486 } | |
| 5487 return id; | |
| 5488 } | |
| 5489 | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5490 #define CONTEXT_SEP XML_T(ASCII_FF) |
| 21930 | 5491 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5492 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5493 getContext(XML_Parser parser) |
| 21930 | 5494 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5495 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5496 HASH_TABLE_ITER iter; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5497 XML_Bool needSep = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5498 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5499 if (dtd->defaultPrefix.binding) { |
| 21930 | 5500 int i; |
| 5501 int len; | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5502 if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5503 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5504 len = dtd->defaultPrefix.binding->uriLen; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5505 if (namespaceSeparator) |
| 21930 | 5506 len--; |
| 5507 for (i = 0; i < len; i++) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5508 if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5509 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5510 needSep = XML_TRUE; |
| 21930 | 5511 } |
| 5512 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5513 hashTableIterInit(&iter, &(dtd->prefixes)); |
| 21930 | 5514 for (;;) { |
| 5515 int i; | |
| 5516 int len; | |
| 5517 const XML_Char *s; | |
| 5518 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | |
| 5519 if (!prefix) | |
| 5520 break; | |
| 5521 if (!prefix->binding) | |
| 5522 continue; | |
| 5523 if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5524 return NULL; |
| 21930 | 5525 for (s = prefix->name; *s; s++) |
| 5526 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5527 return NULL; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5528 if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5529 return NULL; |
| 21930 | 5530 len = prefix->binding->uriLen; |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
5531 if (namespaceSeparator) |
| 21930 | 5532 len--; |
| 5533 for (i = 0; i < len; i++) | |
| 5534 if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5535 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5536 needSep = XML_TRUE; |
| 21930 | 5537 } |
| 5538 | |
| 5539 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5540 hashTableIterInit(&iter, &(dtd->generalEntities)); |
| 21930 | 5541 for (;;) { |
| 5542 const XML_Char *s; | |
| 5543 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); | |
| 5544 if (!e) | |
| 5545 break; | |
| 5546 if (!e->open) | |
| 5547 continue; | |
| 5548 if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5549 return NULL; |
| 21930 | 5550 for (s = e->name; *s; s++) |
| 5551 if (!poolAppendChar(&tempPool, *s)) | |
| 5552 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5553 needSep = XML_TRUE; |
| 21930 | 5554 } |
| 5555 | |
| 5556 if (!poolAppendChar(&tempPool, XML_T('\0'))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5557 return NULL; |
| 21930 | 5558 return tempPool.start; |
| 5559 } | |
| 5560 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5561 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5562 setContext(XML_Parser parser, const XML_Char *context) |
| 21930 | 5563 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5564 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5565 const XML_Char *s = context; |
| 5566 | |
| 5567 while (*context != XML_T('\0')) { | |
| 5568 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | |
| 5569 ENTITY *e; | |
| 5570 if (!poolAppendChar(&tempPool, XML_T('\0'))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5571 return XML_FALSE; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5572 e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0); |
| 21930 | 5573 if (e) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5574 e->open = XML_TRUE; |
| 21930 | 5575 if (*s != XML_T('\0')) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5576 s++; |
| 21930 | 5577 context = s; |
| 5578 poolDiscard(&tempPool); | |
| 5579 } | |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
5580 else if (*s == XML_T(ASCII_EQUALS)) { |
| 21930 | 5581 PREFIX *prefix; |
| 5582 if (poolLength(&tempPool) == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5583 prefix = &dtd->defaultPrefix; |
| 21930 | 5584 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5585 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5586 return XML_FALSE; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5587 prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5588 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5589 if (!prefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5590 return XML_FALSE; |
| 21930 | 5591 if (prefix->name == poolStart(&tempPool)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5592 prefix->name = poolCopyString(&dtd->pool, prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5593 if (!prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5594 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5595 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5596 poolDiscard(&tempPool); |
| 21930 | 5597 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5598 for (context = s + 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5599 *context != CONTEXT_SEP && *context != XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5600 context++) |
| 21930 | 5601 if (!poolAppendChar(&tempPool, *context)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5602 return XML_FALSE; |
| 21930 | 5603 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5604 return XML_FALSE; |
| 32911 | 5605 if (addBinding(parser, prefix, NULL, poolStart(&tempPool), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5606 &inheritedBindings) != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5607 return XML_FALSE; |
| 21930 | 5608 poolDiscard(&tempPool); |
| 5609 if (*context != XML_T('\0')) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5610 ++context; |
| 21930 | 5611 s = context; |
| 5612 } | |
| 5613 else { | |
| 5614 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5615 return XML_FALSE; |
| 21930 | 5616 s++; |
| 5617 } | |
| 5618 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5619 return XML_TRUE; |
| 21930 | 5620 } |
| 5621 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5622 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5623 normalizePublicId(XML_Char *publicId) |
| 21930 | 5624 { |
| 5625 XML_Char *p = publicId; | |
| 5626 XML_Char *s; | |
| 5627 for (s = publicId; *s; s++) { | |
| 5628 switch (*s) { | |
| 5629 case 0x20: | |
| 5630 case 0xD: | |
| 5631 case 0xA: | |
| 5632 if (p != publicId && p[-1] != 0x20) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5633 *p++ = 0x20; |
| 21930 | 5634 break; |
| 5635 default: | |
| 5636 *p++ = *s; | |
| 5637 } | |
| 5638 } | |
| 5639 if (p != publicId && p[-1] == 0x20) | |
| 5640 --p; | |
| 5641 *p = XML_T('\0'); | |
| 5642 } | |
| 5643 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5644 static DTD * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5645 dtdCreate(const XML_Memory_Handling_Suite *ms) |
| 21930 | 5646 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5647 DTD *p = (DTD *)ms->malloc_fcn(sizeof(DTD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5648 if (p == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5649 return p; |
| 21930 | 5650 poolInit(&(p->pool), ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5651 poolInit(&(p->entityValuePool), ms); |
| 21930 | 5652 hashTableInit(&(p->generalEntities), ms); |
| 5653 hashTableInit(&(p->elementTypes), ms); | |
| 5654 hashTableInit(&(p->attributeIds), ms); | |
| 5655 hashTableInit(&(p->prefixes), ms); | |
| 5656 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5657 p->paramEntityRead = XML_FALSE; |
| 21930 | 5658 hashTableInit(&(p->paramEntities), ms); |
| 5659 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5660 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5661 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5662 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5663 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5664 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5665 p->scaffold = NULL; |
| 21930 | 5666 p->scaffLevel = 0; |
| 5667 p->scaffSize = 0; | |
| 5668 p->scaffCount = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5669 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5670 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5671 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5672 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5673 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5674 return p; |
| 21930 | 5675 } |
| 5676 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5677 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5678 dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5679 { |
| 5680 HASH_TABLE_ITER iter; | |
| 5681 hashTableIterInit(&iter, &(p->elementTypes)); | |
| 5682 for (;;) { | |
| 5683 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5684 if (!e) | |
| 5685 break; | |
| 5686 if (e->allocDefaultAtts != 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5687 ms->free_fcn(e->defaultAtts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5688 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5689 hashTableClear(&(p->generalEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5690 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5691 p->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5692 hashTableClear(&(p->paramEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5693 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5694 hashTableClear(&(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5695 hashTableClear(&(p->attributeIds)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5696 hashTableClear(&(p->prefixes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5697 poolClear(&(p->pool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5698 poolClear(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5699 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5700 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5701 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5702 p->in_eldecl = XML_FALSE; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5703 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5704 ms->free_fcn(p->scaffIndex); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5705 p->scaffIndex = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5706 ms->free_fcn(p->scaffold); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5707 p->scaffold = NULL; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5708 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5709 p->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5710 p->scaffSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5711 p->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5712 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5713 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5714 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5715 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5716 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5717 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5718 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5719 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5720 dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5721 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5722 HASH_TABLE_ITER iter; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5723 hashTableIterInit(&iter, &(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5724 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5725 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5726 if (!e) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5727 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5728 if (e->allocDefaultAtts != 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5729 ms->free_fcn(e->defaultAtts); |
| 21930 | 5730 } |
| 5731 hashTableDestroy(&(p->generalEntities)); | |
| 5732 #ifdef XML_DTD | |
| 5733 hashTableDestroy(&(p->paramEntities)); | |
| 5734 #endif /* XML_DTD */ | |
| 5735 hashTableDestroy(&(p->elementTypes)); | |
| 5736 hashTableDestroy(&(p->attributeIds)); | |
| 5737 hashTableDestroy(&(p->prefixes)); | |
| 5738 poolDestroy(&(p->pool)); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5739 poolDestroy(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5740 if (isDocEntity) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5741 ms->free_fcn(p->scaffIndex); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5742 ms->free_fcn(p->scaffold); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5743 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5744 ms->free_fcn(p); |
| 21930 | 5745 } |
| 5746 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5747 /* Do a deep copy of the DTD. Return 0 for out of memory, non-zero otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5748 The new DTD has already been initialized. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5749 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5750 static int |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5751 dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5752 { |
| 5753 HASH_TABLE_ITER iter; | |
| 5754 | |
| 5755 /* Copy the prefix table. */ | |
| 5756 | |
| 5757 hashTableIterInit(&iter, &(oldDtd->prefixes)); | |
| 5758 for (;;) { | |
| 5759 const XML_Char *name; | |
| 5760 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); | |
| 5761 if (!oldP) | |
| 5762 break; | |
| 5763 name = poolCopyString(&(newDtd->pool), oldP->name); | |
| 5764 if (!name) | |
| 5765 return 0; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5766 if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) |
| 21930 | 5767 return 0; |
| 5768 } | |
| 5769 | |
| 5770 hashTableIterInit(&iter, &(oldDtd->attributeIds)); | |
| 5771 | |
| 5772 /* Copy the attribute id table. */ | |
| 5773 | |
| 5774 for (;;) { | |
| 5775 ATTRIBUTE_ID *newA; | |
| 5776 const XML_Char *name; | |
| 5777 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); | |
| 5778 | |
| 5779 if (!oldA) | |
| 5780 break; | |
| 5781 /* Remember to allocate the scratch byte before the name. */ | |
| 5782 if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) | |
| 5783 return 0; | |
| 5784 name = poolCopyString(&(newDtd->pool), oldA->name); | |
| 5785 if (!name) | |
| 5786 return 0; | |
| 5787 ++name; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5788 newA = (ATTRIBUTE_ID *)lookup(oldParser, &(newDtd->attributeIds), name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5789 sizeof(ATTRIBUTE_ID)); |
| 21930 | 5790 if (!newA) |
| 5791 return 0; | |
| 5792 newA->maybeTokenized = oldA->maybeTokenized; | |
| 5793 if (oldA->prefix) { | |
| 5794 newA->xmlns = oldA->xmlns; | |
| 5795 if (oldA->prefix == &oldDtd->defaultPrefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5796 newA->prefix = &newDtd->defaultPrefix; |
| 21930 | 5797 else |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5798 newA->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5799 oldA->prefix->name, 0); |
| 21930 | 5800 } |
| 5801 } | |
| 5802 | |
| 5803 /* Copy the element type table. */ | |
| 5804 | |
| 5805 hashTableIterInit(&iter, &(oldDtd->elementTypes)); | |
| 5806 | |
| 5807 for (;;) { | |
| 5808 int i; | |
| 5809 ELEMENT_TYPE *newE; | |
| 5810 const XML_Char *name; | |
| 5811 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5812 if (!oldE) | |
| 5813 break; | |
| 5814 name = poolCopyString(&(newDtd->pool), oldE->name); | |
| 5815 if (!name) | |
| 5816 return 0; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5817 newE = (ELEMENT_TYPE *)lookup(oldParser, &(newDtd->elementTypes), name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5818 sizeof(ELEMENT_TYPE)); |
| 21930 | 5819 if (!newE) |
| 5820 return 0; | |
| 5821 if (oldE->nDefaultAtts) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5822 newE->defaultAtts = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5823 ms->malloc_fcn(oldE->nDefaultAtts * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5824 if (!newE->defaultAtts) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5825 ms->free_fcn(newE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5826 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5827 } |
| 21930 | 5828 } |
| 5829 if (oldE->idAtt) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5830 newE->idAtt = (ATTRIBUTE_ID *) |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5831 lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0); |
| 21930 | 5832 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; |
| 5833 if (oldE->prefix) | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5834 newE->prefix = (PREFIX *)lookup(oldParser, &(newDtd->prefixes), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5835 oldE->prefix->name, 0); |
| 21930 | 5836 for (i = 0; i < newE->nDefaultAtts; i++) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5837 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5838 lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); |
| 21930 | 5839 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; |
| 5840 if (oldE->defaultAtts[i].value) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5841 newE->defaultAtts[i].value |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5842 = poolCopyString(&(newDtd->pool), oldE->defaultAtts[i].value); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5843 if (!newE->defaultAtts[i].value) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5844 return 0; |
| 21930 | 5845 } |
| 5846 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5847 newE->defaultAtts[i].value = NULL; |
| 21930 | 5848 } |
| 5849 } | |
| 5850 | |
| 5851 /* Copy the entity tables. */ | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5852 if (!copyEntityTable(oldParser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5853 &(newDtd->generalEntities), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5854 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5855 &(oldDtd->generalEntities))) |
| 21930 | 5856 return 0; |
| 5857 | |
| 5858 #ifdef XML_DTD | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5859 if (!copyEntityTable(oldParser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5860 &(newDtd->paramEntities), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5861 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5862 &(oldDtd->paramEntities))) |
| 21930 | 5863 return 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5864 newDtd->paramEntityRead = oldDtd->paramEntityRead; |
| 21930 | 5865 #endif /* XML_DTD */ |
| 5866 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5867 newDtd->keepProcessing = oldDtd->keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5868 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; |
| 21930 | 5869 newDtd->standalone = oldDtd->standalone; |
| 5870 | |
| 5871 /* Don't want deep copying for scaffolding */ | |
| 5872 newDtd->in_eldecl = oldDtd->in_eldecl; | |
| 5873 newDtd->scaffold = oldDtd->scaffold; | |
| 5874 newDtd->contentStringLen = oldDtd->contentStringLen; | |
| 5875 newDtd->scaffSize = oldDtd->scaffSize; | |
| 5876 newDtd->scaffLevel = oldDtd->scaffLevel; | |
| 5877 newDtd->scaffIndex = oldDtd->scaffIndex; | |
| 5878 | |
| 5879 return 1; | |
| 5880 } /* End dtdCopy */ | |
| 5881 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5882 static int |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5883 copyEntityTable(XML_Parser oldParser, |
|
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5884 HASH_TABLE *newTable, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5885 STRING_POOL *newPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5886 const HASH_TABLE *oldTable) |
| 21930 | 5887 { |
| 5888 HASH_TABLE_ITER iter; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5889 const XML_Char *cachedOldBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5890 const XML_Char *cachedNewBase = NULL; |
| 21930 | 5891 |
| 5892 hashTableIterInit(&iter, oldTable); | |
| 5893 | |
| 5894 for (;;) { | |
| 5895 ENTITY *newE; | |
| 5896 const XML_Char *name; | |
| 5897 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); | |
| 5898 if (!oldE) | |
| 5899 break; | |
| 5900 name = poolCopyString(newPool, oldE->name); | |
| 5901 if (!name) | |
| 5902 return 0; | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5903 newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY)); |
| 21930 | 5904 if (!newE) |
| 5905 return 0; | |
| 5906 if (oldE->systemId) { | |
| 5907 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); | |
| 5908 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5909 return 0; |
| 21930 | 5910 newE->systemId = tem; |
| 5911 if (oldE->base) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5912 if (oldE->base == cachedOldBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5913 newE->base = cachedNewBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5914 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5915 cachedOldBase = oldE->base; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5916 tem = poolCopyString(newPool, cachedOldBase); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5917 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5918 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5919 cachedNewBase = newE->base = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5920 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5921 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5922 if (oldE->publicId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5923 tem = poolCopyString(newPool, oldE->publicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5924 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5925 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5926 newE->publicId = tem; |
| 21930 | 5927 } |
| 5928 } | |
| 5929 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5930 const XML_Char *tem = poolCopyStringN(newPool, oldE->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5931 oldE->textLen); |
| 21930 | 5932 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5933 return 0; |
| 21930 | 5934 newE->textPtr = tem; |
| 5935 newE->textLen = oldE->textLen; | |
| 5936 } | |
| 5937 if (oldE->notation) { | |
| 5938 const XML_Char *tem = poolCopyString(newPool, oldE->notation); | |
| 5939 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5940 return 0; |
| 21930 | 5941 newE->notation = tem; |
| 5942 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5943 newE->is_param = oldE->is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5944 newE->is_internal = oldE->is_internal; |
| 21930 | 5945 } |
| 5946 return 1; | |
| 5947 } | |
| 5948 | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5949 #define INIT_POWER 6 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5950 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5951 static XML_Bool FASTCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5952 keyeq(KEY s1, KEY s2) |
| 21930 | 5953 { |
| 5954 for (; *s1 == *s2; s1++, s2++) | |
| 5955 if (*s1 == 0) | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5956 return XML_TRUE; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5957 return XML_FALSE; |
| 21930 | 5958 } |
| 5959 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5960 static unsigned long FASTCALL |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5961 hash(XML_Parser parser, KEY s) |
| 21930 | 5962 { |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5963 unsigned long h = hash_secret_salt; |
| 21930 | 5964 while (*s) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5965 h = CHAR_HASH(h, *s++); |
| 21930 | 5966 return h; |
| 5967 } | |
| 5968 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5969 static NAMED * |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5970 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) |
| 21930 | 5971 { |
| 5972 size_t i; | |
| 5973 if (table->size == 0) { | |
| 5974 size_t tsize; | |
| 5975 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5976 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5977 table->power = INIT_POWER; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5978 /* table->size is a power of 2 */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5979 table->size = (size_t)1 << INIT_POWER; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5980 tsize = table->size * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5981 table->v = (NAMED **)table->mem->malloc_fcn(tsize); |
| 32911 | 5982 if (!table->v) { |
| 5983 table->size = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5984 return NULL; |
| 32911 | 5985 } |
| 21930 | 5986 memset(table->v, 0, tsize); |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5987 i = hash(parser, name) & ((unsigned long)table->size - 1); |
| 21930 | 5988 } |
| 5989 else { | |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
5990 unsigned long h = hash(parser, name); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5991 unsigned long mask = (unsigned long)table->size - 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5992 unsigned char step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5993 i = h & mask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5994 while (table->v[i]) { |
| 21930 | 5995 if (keyeq(name, table->v[i]->name)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5996 return table->v[i]; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5997 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5998 step = PROBE_STEP(h, mask, table->power); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5999 i < step ? (i += table->size - step) : (i -= step); |
| 21930 | 6000 } |
| 6001 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6002 return NULL; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6003 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6004 /* check for overflow (table is half full) */ |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6005 if (table->used >> (table->power - 1)) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6006 unsigned char newPower = table->power + 1; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6007 size_t newSize = (size_t)1 << newPower; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6008 unsigned long newMask = (unsigned long)newSize - 1; |
| 21930 | 6009 size_t tsize = newSize * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6010 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 6011 if (!newV) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6012 return NULL; |
| 21930 | 6013 memset(newV, 0, tsize); |
| 6014 for (i = 0; i < table->size; i++) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6015 if (table->v[i]) { |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
6016 unsigned long newHash = hash(parser, table->v[i]->name); |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6017 size_t j = newHash & newMask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6018 step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6019 while (newV[j]) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6020 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6021 step = PROBE_STEP(newHash, newMask, newPower); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6022 j < step ? (j += newSize - step) : (j -= step); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6023 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6024 newV[j] = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6025 } |
| 21930 | 6026 table->mem->free_fcn(table->v); |
| 6027 table->v = newV; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6028 table->power = newPower; |
| 21930 | 6029 table->size = newSize; |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6030 i = h & newMask; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6031 step = 0; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6032 while (table->v[i]) { |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6033 if (!step) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6034 step = PROBE_STEP(h, newMask, newPower); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6035 i < step ? (i += newSize - step) : (i -= step); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6036 } |
| 21930 | 6037 } |
| 6038 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6039 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); |
| 21930 | 6040 if (!table->v[i]) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6041 return NULL; |
| 21930 | 6042 memset(table->v[i], 0, createSize); |
| 6043 table->v[i]->name = name; | |
| 6044 (table->used)++; | |
| 6045 return table->v[i]; | |
| 6046 } | |
| 6047 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6048 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6049 hashTableClear(HASH_TABLE *table) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6050 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6051 size_t i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6052 for (i = 0; i < table->size; i++) { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6053 table->mem->free_fcn(table->v[i]); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6054 table->v[i] = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6055 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6056 table->used = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6057 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6058 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6059 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6060 hashTableDestroy(HASH_TABLE *table) |
| 21930 | 6061 { |
| 6062 size_t i; | |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6063 for (i = 0; i < table->size; i++) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6064 table->mem->free_fcn(table->v[i]); |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6065 table->mem->free_fcn(table->v); |
| 21930 | 6066 } |
| 6067 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6068 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6069 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 6070 { |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6071 p->power = 0; |
| 21930 | 6072 p->size = 0; |
| 6073 p->used = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6074 p->v = NULL; |
| 21930 | 6075 p->mem = ms; |
| 6076 } | |
| 6077 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6078 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6079 hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) |
| 21930 | 6080 { |
| 6081 iter->p = table->v; | |
| 6082 iter->end = iter->p + table->size; | |
| 6083 } | |
| 6084 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6085 static NAMED * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6086 hashTableIterNext(HASH_TABLE_ITER *iter) |
| 21930 | 6087 { |
| 6088 while (iter->p != iter->end) { | |
| 6089 NAMED *tem = *(iter->p)++; | |
| 6090 if (tem) | |
| 6091 return tem; | |
| 6092 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6093 return NULL; |
| 21930 | 6094 } |
| 6095 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6096 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6097 poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) |
| 21930 | 6098 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6099 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6100 pool->freeBlocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6101 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6102 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6103 pool->end = NULL; |
| 21930 | 6104 pool->mem = ms; |
| 6105 } | |
| 6106 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6107 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6108 poolClear(STRING_POOL *pool) |
| 21930 | 6109 { |
| 6110 if (!pool->freeBlocks) | |
| 6111 pool->freeBlocks = pool->blocks; | |
| 6112 else { | |
| 6113 BLOCK *p = pool->blocks; | |
| 6114 while (p) { | |
| 6115 BLOCK *tem = p->next; | |
| 6116 p->next = pool->freeBlocks; | |
| 6117 pool->freeBlocks = p; | |
| 6118 p = tem; | |
| 6119 } | |
| 6120 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6121 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6122 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6123 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6124 pool->end = NULL; |
| 21930 | 6125 } |
| 6126 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6127 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6128 poolDestroy(STRING_POOL *pool) |
| 21930 | 6129 { |
| 6130 BLOCK *p = pool->blocks; | |
| 6131 while (p) { | |
| 6132 BLOCK *tem = p->next; | |
| 6133 pool->mem->free_fcn(p); | |
| 6134 p = tem; | |
| 6135 } | |
| 6136 p = pool->freeBlocks; | |
| 6137 while (p) { | |
| 6138 BLOCK *tem = p->next; | |
| 6139 pool->mem->free_fcn(p); | |
| 6140 p = tem; | |
| 6141 } | |
| 6142 } | |
| 6143 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6144 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6145 poolAppend(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6146 const char *ptr, const char *end) |
| 21930 | 6147 { |
| 6148 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6149 return NULL; |
| 21930 | 6150 for (;;) { |
| 6151 XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); | |
| 6152 if (ptr == end) | |
| 6153 break; | |
| 6154 if (!poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6155 return NULL; |
| 21930 | 6156 } |
| 6157 return pool->start; | |
| 6158 } | |
| 6159 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6160 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6161 poolCopyString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6162 { |
| 6163 do { | |
| 6164 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6165 return NULL; |
| 21930 | 6166 } while (*s++); |
| 6167 s = pool->start; | |
| 6168 poolFinish(pool); | |
| 6169 return s; | |
| 6170 } | |
| 6171 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6172 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6173 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 21930 | 6174 { |
| 6175 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6176 return NULL; |
| 21930 | 6177 for (; n > 0; --n, s++) { |
| 6178 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6179 return NULL; |
| 21930 | 6180 } |
| 6181 s = pool->start; | |
| 6182 poolFinish(pool); | |
| 6183 return s; | |
| 6184 } | |
| 6185 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6186 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6187 poolAppendString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6188 { |
| 6189 while (*s) { | |
| 6190 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6191 return NULL; |
| 21930 | 6192 s++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6193 } |
| 21930 | 6194 return pool->start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6195 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6196 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6197 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6198 poolStoreString(STRING_POOL *pool, const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6199 const char *ptr, const char *end) |
| 21930 | 6200 { |
| 6201 if (!poolAppend(pool, enc, ptr, end)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6202 return NULL; |
| 21930 | 6203 if (pool->ptr == pool->end && !poolGrow(pool)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6204 return NULL; |
| 21930 | 6205 *(pool->ptr)++ = 0; |
| 6206 return pool->start; | |
| 6207 } | |
| 6208 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6209 static XML_Bool FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6210 poolGrow(STRING_POOL *pool) |
| 21930 | 6211 { |
| 6212 if (pool->freeBlocks) { | |
| 6213 if (pool->start == 0) { | |
| 6214 pool->blocks = pool->freeBlocks; | |
| 6215 pool->freeBlocks = pool->freeBlocks->next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6216 pool->blocks->next = NULL; |
| 21930 | 6217 pool->start = pool->blocks->s; |
| 6218 pool->end = pool->start + pool->blocks->size; | |
| 6219 pool->ptr = pool->start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6220 return XML_TRUE; |
| 21930 | 6221 } |
| 6222 if (pool->end - pool->start < pool->freeBlocks->size) { | |
| 6223 BLOCK *tem = pool->freeBlocks->next; | |
| 6224 pool->freeBlocks->next = pool->blocks; | |
| 6225 pool->blocks = pool->freeBlocks; | |
| 6226 pool->freeBlocks = tem; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6227 memcpy(pool->blocks->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6228 (pool->end - pool->start) * sizeof(XML_Char)); |
| 21930 | 6229 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); |
| 6230 pool->start = pool->blocks->s; | |
| 6231 pool->end = pool->start + pool->blocks->size; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6232 return XML_TRUE; |
| 21930 | 6233 } |
| 6234 } | |
| 6235 if (pool->blocks && pool->start == pool->blocks->s) { | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
6236 int blockSize = (int)(pool->end - pool->start)*2; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
6237 BLOCK *temp = (BLOCK *) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6238 pool->mem->realloc_fcn(pool->blocks, |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6239 (offsetof(BLOCK, s) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6240 + blockSize * sizeof(XML_Char))); |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
6241 if (temp == NULL) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6242 return XML_FALSE; |
|
78100
e4dc8be9a72f
Update the embedded copy of the expat XML parser to 2.1.0. It brings
Gregory P. Smith <greg@krypto.org>
parents:
75650
diff
changeset
|
6243 pool->blocks = temp; |
| 21930 | 6244 pool->blocks->size = blockSize; |
| 6245 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | |
| 6246 pool->start = pool->blocks->s; | |
| 6247 pool->end = pool->start + blockSize; | |
| 6248 } | |
| 6249 else { | |
| 6250 BLOCK *tem; | |
|
39442
654c380cf8b9
Merged revisions 46753-51188 via svnmerge from
Thomas Wouters <thomas@python.org>
parents:
38453
diff
changeset
|
6251 int blockSize = (int)(pool->end - pool->start); |
| 21930 | 6252 if (blockSize < INIT_BLOCK_SIZE) |
| 6253 blockSize = INIT_BLOCK_SIZE; | |
| 6254 else | |
| 6255 blockSize *= 2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6256 tem = (BLOCK *)pool->mem->malloc_fcn(offsetof(BLOCK, s) |
|
30748
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
6257 + blockSize * sizeof(XML_Char)); |
| 21930 | 6258 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6259 return XML_FALSE; |
| 21930 | 6260 tem->size = blockSize; |
| 6261 tem->next = pool->blocks; | |
| 6262 pool->blocks = tem; | |
| 6263 if (pool->ptr != pool->start) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6264 memcpy(tem->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6265 (pool->ptr - pool->start) * sizeof(XML_Char)); |
| 21930 | 6266 pool->ptr = tem->s + (pool->ptr - pool->start); |
| 6267 pool->start = tem->s; | |
| 6268 pool->end = tem->s + blockSize; | |
| 6269 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6270 return XML_TRUE; |
| 21930 | 6271 } |
| 6272 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6273 static int FASTCALL |
| 21930 | 6274 nextScaffoldPart(XML_Parser parser) |
| 6275 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6276 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6277 CONTENT_SCAFFOLD * me; |
| 6278 int next; | |
| 6279 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6280 if (!dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6281 dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6282 if (!dtd->scaffIndex) |
| 21930 | 6283 return -1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6284 dtd->scaffIndex[0] = 0; |
| 21930 | 6285 } |
| 6286 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6287 if (dtd->scaffCount >= dtd->scaffSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6288 CONTENT_SCAFFOLD *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6289 if (dtd->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6290 temp = (CONTENT_SCAFFOLD *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6291 REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6292 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6293 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6294 dtd->scaffSize *= 2; |
| 21930 | 6295 } |
| 6296 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6297 temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6298 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6299 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6300 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6301 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; |
| 21930 | 6302 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6303 dtd->scaffold = temp; |
| 21930 | 6304 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6305 next = dtd->scaffCount++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6306 me = &dtd->scaffold[next]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6307 if (dtd->scaffLevel) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6308 CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; |
| 21930 | 6309 if (parent->lastchild) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6310 dtd->scaffold[parent->lastchild].nextsib = next; |
| 21930 | 6311 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6312 if (!parent->childcnt) |
| 21930 | 6313 parent->firstchild = next; |
| 6314 parent->lastchild = next; | |
| 6315 parent->childcnt++; | |
| 6316 } | |
| 6317 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; | |
| 6318 return next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6319 } |
| 21930 | 6320 |
| 6321 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6322 build_node(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6323 int src_node, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6324 XML_Content *dest, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6325 XML_Content **contpos, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6326 XML_Char **strpos) |
| 21930 | 6327 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6328 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6329 dest->type = dtd->scaffold[src_node].type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6330 dest->quant = dtd->scaffold[src_node].quant; |
| 21930 | 6331 if (dest->type == XML_CTYPE_NAME) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6332 const XML_Char *src; |
| 21930 | 6333 dest->name = *strpos; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6334 src = dtd->scaffold[src_node].name; |
| 21930 | 6335 for (;;) { |
| 6336 *(*strpos)++ = *src; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6337 if (!*src) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6338 break; |
| 21930 | 6339 src++; |
| 6340 } | |
| 6341 dest->numchildren = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6342 dest->children = NULL; |
| 21930 | 6343 } |
| 6344 else { | |
| 6345 unsigned int i; | |
| 6346 int cn; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6347 dest->numchildren = dtd->scaffold[src_node].childcnt; |
| 21930 | 6348 dest->children = *contpos; |
| 6349 *contpos += dest->numchildren; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6350 for (i = 0, cn = dtd->scaffold[src_node].firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6351 i < dest->numchildren; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6352 i++, cn = dtd->scaffold[cn].nextsib) { |
| 21930 | 6353 build_node(parser, cn, &(dest->children[i]), contpos, strpos); |
| 6354 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6355 dest->name = NULL; |
| 21930 | 6356 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6357 } |
| 21930 | 6358 |
| 6359 static XML_Content * | |
| 6360 build_model (XML_Parser parser) | |
| 6361 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6362 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6363 XML_Content *ret; |
| 6364 XML_Content *cpos; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6365 XML_Char * str; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6366 int allocsize = (dtd->scaffCount * sizeof(XML_Content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6367 + (dtd->contentStringLen * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6368 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6369 ret = (XML_Content *)MALLOC(allocsize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6370 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6371 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6372 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6373 str = (XML_Char *) (&ret[dtd->scaffCount]); |
| 21930 | 6374 cpos = &ret[1]; |
| 6375 | |
| 6376 build_node(parser, 0, ret, &cpos, &str); | |
| 6377 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6378 } |
| 21930 | 6379 |
| 6380 static ELEMENT_TYPE * | |
| 6381 getElementType(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6382 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6383 const char *ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6384 const char *end) |
| 21930 | 6385 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6386 DTD * const dtd = _dtd; /* save one level of indirection */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6387 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 21930 | 6388 ELEMENT_TYPE *ret; |
| 6389 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6390 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6391 return NULL; |
|
75650
7b5bc1719477
Fixes issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58439
diff
changeset
|
6392 ret = (ELEMENT_TYPE *) lookup(parser, &dtd->elementTypes, name, sizeof(ELEMENT_TYPE)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6393 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6394 return NULL; |
| 21930 | 6395 if (ret->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6396 poolDiscard(&dtd->pool); |
| 21930 | 6397 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6398 poolFinish(&dtd->pool); |
| 21930 | 6399 if (!setElementTypePrefix(parser, ret)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6400 return NULL; |
| 21930 | 6401 } |
| 6402 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6403 } |
