Mercurial > cpython-lru_cache-weakref
annotate Modules/expat/xmlparse.c @ 80661:94de77bd0b4b 2.7
Issue #16194: document imp.load_dynamic problems
when read several extension modules from the same binary object file.
| author | Andrew Svetlov <andrew.svetlov@gmail.com> |
|---|---|
| date | Thu, 29 Nov 2012 19:51:28 +0200 |
| parents | b54f5849013c |
| children | c73a1f96dd9b |
| 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 | |
|
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
|
5 #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
|
6 |
| 21930 | 7 #ifdef COMPILED_FROM_DSP |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
8 #include "winconfig.h" |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
9 #elif defined(MACOS_CLASSIC) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
10 #include "macconfig.h" |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
11 #elif defined(__amigaos4__) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
12 #include "amigaconfig.h" |
| 32911 | 13 #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
|
14 #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
|
15 #endif /* ndef COMPILED_FROM_DSP */ |
| 21930 | 16 |
|
38080
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
17 #include <stddef.h> |
|
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
18 #include <string.h> /* memset(), memcpy() */ |
|
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
19 #include <assert.h> |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
20 #include <limits.h> /* UINT_MAX */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
21 #include <time.h> /* time() */ |
|
38080
b8ec689cb2fb
Fix breakage from patch 1471883 (r45800 & r45808) on OSF/1.
Neal Norwitz <nnorwitz@gmail.com>
parents:
36223
diff
changeset
|
22 |
| 21930 | 23 #include "expat.h" |
| 24 | |
| 25 #ifdef XML_UNICODE | |
| 26 #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX | |
| 27 #define XmlConvert XmlUtf16Convert | |
| 28 #define XmlGetInternalEncoding XmlGetUtf16InternalEncoding | |
| 29 #define XmlGetInternalEncodingNS XmlGetUtf16InternalEncodingNS | |
| 30 #define XmlEncode XmlUtf16Encode | |
| 31 #define MUST_CONVERT(enc, s) (!(enc)->isUtf16 || (((unsigned long)s) & 1)) | |
| 32 typedef unsigned short ICHAR; | |
| 33 #else | |
| 34 #define XML_ENCODE_MAX XML_UTF8_ENCODE_MAX | |
| 35 #define XmlConvert XmlUtf8Convert | |
| 36 #define XmlGetInternalEncoding XmlGetUtf8InternalEncoding | |
| 37 #define XmlGetInternalEncodingNS XmlGetUtf8InternalEncodingNS | |
| 38 #define XmlEncode XmlUtf8Encode | |
| 39 #define MUST_CONVERT(enc, s) (!(enc)->isUtf8) | |
| 40 typedef char ICHAR; | |
| 41 #endif | |
| 42 | |
| 43 | |
| 44 #ifndef XML_NS | |
| 45 | |
| 46 #define XmlInitEncodingNS XmlInitEncoding | |
| 47 #define XmlInitUnknownEncodingNS XmlInitUnknownEncoding | |
| 48 #undef XmlGetInternalEncodingNS | |
| 49 #define XmlGetInternalEncodingNS XmlGetInternalEncoding | |
| 50 #define XmlParseXmlDeclNS XmlParseXmlDecl | |
| 51 | |
| 52 #endif | |
| 53 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
54 #ifdef XML_UNICODE |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
55 |
| 21930 | 56 #ifdef XML_UNICODE_WCHAR_T |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
57 #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
|
58 #define XML_L(x) L ## x |
| 21930 | 59 #else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
60 #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
|
61 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
62 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
63 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
64 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
65 |
| 21930 | 66 #define XML_T(x) x |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
67 #define XML_L(x) x |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
68 |
| 21930 | 69 #endif |
| 70 | |
| 71 /* Round up n to be a multiple of sz, where sz is a power of 2. */ | |
| 72 #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | |
| 73 | |
|
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
|
74 /* 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
|
75 #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
|
76 #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
|
77 #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
|
78 #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
|
79 #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
|
80 #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
|
81 #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
|
82 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
83 #include "internal.h" |
| 21930 | 84 #include "xmltok.h" |
| 85 #include "xmlrole.h" | |
| 86 | |
| 87 typedef const XML_Char *KEY; | |
| 88 | |
| 89 typedef struct { | |
| 90 KEY name; | |
| 91 } NAMED; | |
| 92 | |
| 93 typedef struct { | |
| 94 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
|
95 unsigned char power; |
| 21930 | 96 size_t size; |
| 97 size_t used; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
98 const XML_Memory_Handling_Suite *mem; |
| 21930 | 99 } HASH_TABLE; |
| 100 | |
|
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
|
101 /* 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
|
102 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
|
103 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
104 */ |
|
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 #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
|
106 #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
|
107 (((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
|
108 #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
|
109 #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
|
110 (((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
|
111 #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
|
112 |
|
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 /* 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
|
114 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
|
115 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
|
116 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
|
117 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
|
118 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
|
119 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
|
120 */ |
|
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 #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
|
122 ((((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
|
123 #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
|
124 ((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
|
125 |
| 21930 | 126 typedef struct { |
| 127 NAMED **p; | |
| 128 NAMED **end; | |
| 129 } HASH_TABLE_ITER; | |
| 130 | |
| 131 #define INIT_TAG_BUF_SIZE 32 /* must be a multiple of sizeof(XML_Char) */ | |
| 132 #define INIT_DATA_BUF_SIZE 1024 | |
| 133 #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
|
134 #define INIT_ATTS_VERSION 0xFFFFFFFF |
| 21930 | 135 #define INIT_BLOCK_SIZE 1024 |
| 136 #define INIT_BUFFER_SIZE 1024 | |
| 137 | |
| 138 #define EXPAND_SPARE 24 | |
| 139 | |
| 140 typedef struct binding { | |
| 141 struct prefix *prefix; | |
| 142 struct binding *nextTagBinding; | |
| 143 struct binding *prevPrefixBinding; | |
| 144 const struct attribute_id *attId; | |
| 145 XML_Char *uri; | |
| 146 int uriLen; | |
| 147 int uriAlloc; | |
| 148 } BINDING; | |
| 149 | |
| 150 typedef struct prefix { | |
| 151 const XML_Char *name; | |
| 152 BINDING *binding; | |
| 153 } PREFIX; | |
| 154 | |
| 155 typedef struct { | |
| 156 const XML_Char *str; | |
| 157 const XML_Char *localPart; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
158 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
159 int strLen; |
| 21930 | 160 int uriLen; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
161 int prefixLen; |
| 21930 | 162 } TAG_NAME; |
| 163 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
164 /* TAG represents an open element. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
165 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
|
166 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
|
167 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
|
168 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
|
169 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
|
170 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
|
171 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
|
172 contain the 'raw' name as well. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
173 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
174 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
|
175 TAG objects in a free list. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
176 */ |
| 21930 | 177 typedef struct tag { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
178 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
|
179 const char *rawName; /* tagName in the original encoding */ |
| 21930 | 180 int rawNameLength; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
181 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
|
182 char *buf; /* buffer for name components */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
183 char *bufEnd; /* end of the buffer */ |
| 21930 | 184 BINDING *bindings; |
| 185 } TAG; | |
| 186 | |
| 187 typedef struct { | |
| 188 const XML_Char *name; | |
| 189 const XML_Char *textPtr; | |
| 32911 | 190 int textLen; /* length in XML_Chars */ |
| 191 int processed; /* # of processed bytes - when suspended */ | |
| 21930 | 192 const XML_Char *systemId; |
| 193 const XML_Char *base; | |
| 194 const XML_Char *publicId; | |
| 195 const XML_Char *notation; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
196 XML_Bool open; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
197 XML_Bool is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
198 XML_Bool is_internal; /* true if declared in internal subset outside PE */ |
| 21930 | 199 } ENTITY; |
| 200 | |
| 201 typedef struct { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
202 enum XML_Content_Type type; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
203 enum XML_Content_Quant quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
204 const XML_Char * name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
205 int firstchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
206 int lastchild; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
207 int childcnt; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
208 int nextsib; |
| 21930 | 209 } CONTENT_SCAFFOLD; |
| 210 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
211 #define INIT_SCAFFOLD_ELEMENTS 32 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
212 |
| 21930 | 213 typedef struct block { |
| 214 struct block *next; | |
| 215 int size; | |
| 216 XML_Char s[1]; | |
| 217 } BLOCK; | |
| 218 | |
| 219 typedef struct { | |
| 220 BLOCK *blocks; | |
| 221 BLOCK *freeBlocks; | |
| 222 const XML_Char *end; | |
| 223 XML_Char *ptr; | |
| 224 XML_Char *start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
225 const XML_Memory_Handling_Suite *mem; |
| 21930 | 226 } STRING_POOL; |
| 227 | |
| 228 /* 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
|
229 an attribute has been specified. */ |
| 21930 | 230 typedef struct attribute_id { |
| 231 XML_Char *name; | |
| 232 PREFIX *prefix; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
233 XML_Bool maybeTokenized; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
234 XML_Bool xmlns; |
| 21930 | 235 } ATTRIBUTE_ID; |
| 236 | |
| 237 typedef struct { | |
| 238 const ATTRIBUTE_ID *id; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
239 XML_Bool isCdata; |
| 21930 | 240 const XML_Char *value; |
| 241 } DEFAULT_ATTRIBUTE; | |
| 242 | |
| 243 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
|
244 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
|
245 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
|
246 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
|
247 } 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
|
248 |
|
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 typedef struct { |
| 21930 | 250 const XML_Char *name; |
| 251 PREFIX *prefix; | |
| 252 const ATTRIBUTE_ID *idAtt; | |
| 253 int nDefaultAtts; | |
| 254 int allocDefaultAtts; | |
| 255 DEFAULT_ATTRIBUTE *defaultAtts; | |
| 256 } ELEMENT_TYPE; | |
| 257 | |
| 258 typedef struct { | |
| 259 HASH_TABLE generalEntities; | |
| 260 HASH_TABLE elementTypes; | |
| 261 HASH_TABLE attributeIds; | |
| 262 HASH_TABLE prefixes; | |
| 263 STRING_POOL pool; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
264 STRING_POOL entityValuePool; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
265 /* 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
|
266 XML_Bool keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
267 /* 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
|
268 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
|
269 XML_Bool hasParamEntityRefs; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
270 XML_Bool standalone; |
| 21930 | 271 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
272 /* 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
|
273 XML_Bool paramEntityRead; |
| 21930 | 274 HASH_TABLE paramEntities; |
| 275 #endif /* XML_DTD */ | |
| 276 PREFIX defaultPrefix; | |
| 277 /* === scaffolding for building content model === */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
278 XML_Bool in_eldecl; |
| 21930 | 279 CONTENT_SCAFFOLD *scaffold; |
| 280 unsigned contentStringLen; | |
| 281 unsigned scaffSize; | |
| 282 unsigned scaffCount; | |
| 283 int scaffLevel; | |
| 284 int *scaffIndex; | |
| 285 } DTD; | |
| 286 | |
| 287 typedef struct open_internal_entity { | |
| 288 const char *internalEventPtr; | |
| 289 const char *internalEventEndPtr; | |
| 290 struct open_internal_entity *next; | |
| 291 ENTITY *entity; | |
| 32911 | 292 int startTagLevel; |
| 293 XML_Bool betweenDecl; /* WFC: PE Between Declarations */ | |
| 21930 | 294 } OPEN_INTERNAL_ENTITY; |
| 295 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
296 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
|
297 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
298 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
299 const char **endPtr); |
| 21930 | 300 |
| 301 static Processor prologProcessor; | |
| 302 static Processor prologInitProcessor; | |
| 303 static Processor contentProcessor; | |
| 304 static Processor cdataSectionProcessor; | |
| 305 #ifdef XML_DTD | |
| 306 static Processor ignoreSectionProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
307 static Processor externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
308 static Processor externalParEntInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
309 static Processor entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
310 static Processor entityValueInitProcessor; |
| 21930 | 311 #endif /* XML_DTD */ |
| 312 static Processor epilogProcessor; | |
| 313 static Processor errorProcessor; | |
| 314 static Processor externalEntityInitProcessor; | |
| 315 static Processor externalEntityInitProcessor2; | |
| 316 static Processor externalEntityInitProcessor3; | |
| 317 static Processor externalEntityContentProcessor; | |
| 32911 | 318 static Processor internalEntityProcessor; |
| 21930 | 319 |
| 320 static enum XML_Error | |
| 321 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName); | |
| 322 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
323 processXmlDecl(XML_Parser parser, int isGeneralTextEntity, |
| 32911 | 324 const char *s, const char *next); |
| 21930 | 325 static enum XML_Error |
| 326 initializeEncoding(XML_Parser parser); | |
| 327 static enum XML_Error | |
| 32911 | 328 doProlog(XML_Parser parser, const ENCODING *enc, const char *s, |
| 329 const char *end, int tok, const char *next, const char **nextPtr, | |
| 330 XML_Bool haveMore); | |
| 21930 | 331 static enum XML_Error |
| 32911 | 332 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 333 XML_Bool betweenDecl); | |
| 21930 | 334 static enum XML_Error |
| 335 doContent(XML_Parser parser, int startTagLevel, const ENCODING *enc, | |
| 32911 | 336 const char *start, const char *end, const char **endPtr, |
| 337 XML_Bool haveMore); | |
| 21930 | 338 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
339 doCdataSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 340 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 341 #ifdef XML_DTD |
| 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 doIgnoreSection(XML_Parser parser, const ENCODING *, const char **startPtr, |
| 32911 | 344 const char *end, const char **nextPtr, XML_Bool haveMore); |
| 21930 | 345 #endif /* XML_DTD */ |
| 346 | |
| 347 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
|
348 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
|
349 TAG_NAME *tagNamePtr, BINDING **bindingsPtr); |
| 21930 | 350 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
351 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
|
352 const XML_Char *uri, BINDING **bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
353 static int |
| 32911 | 354 defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *, XML_Bool isCdata, |
| 355 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
|
356 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
357 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
|
358 const char *, const char *, STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
359 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
360 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
|
361 const char *, const char *, STRING_POOL *); |
| 21930 | 362 static ATTRIBUTE_ID * |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
363 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
|
364 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
365 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
366 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *); |
| 21930 | 367 static enum XML_Error |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
368 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
|
369 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
370 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
371 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
|
372 const char *start, const char *end); |
| 21930 | 373 static int |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
374 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
|
375 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
376 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
377 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
|
378 const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
379 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
380 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
|
381 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
382 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
|
383 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
384 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
|
385 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
386 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
|
387 /* do not call if parentParser != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
388 static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); |
| 21930 | 389 static void |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
390 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
|
391 static int |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
392 dtdCopy(XML_Parser oldParser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
393 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
|
394 static int |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
395 copyEntityTable(XML_Parser oldParser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
396 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
|
397 static NAMED * |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
398 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
|
399 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
400 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
|
401 static void FASTCALL hashTableClear(HASH_TABLE *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
402 static void FASTCALL hashTableDestroy(HASH_TABLE *); |
|
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 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
|
405 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
|
406 |
|
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 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
|
409 static void FASTCALL poolClear(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
410 static void FASTCALL poolDestroy(STRING_POOL *); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
411 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
412 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
|
413 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
414 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
415 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
|
416 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
417 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
|
418 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
419 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
|
420 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
421 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
|
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 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
|
424 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
425 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
|
426 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
|
427 static ELEMENT_TYPE * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
428 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
|
429 const char *ptr, const char *end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
430 |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
431 static unsigned long generate_hash_secret_salt(void); |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
432 static XML_Bool startParsing(XML_Parser parser); |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
433 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
434 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
435 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
436 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
437 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
438 DTD *dtd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
439 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
440 parserInit(XML_Parser parser, const XML_Char *encodingName); |
| 21930 | 441 |
| 442 #define poolStart(pool) ((pool)->start) | |
| 443 #define poolEnd(pool) ((pool)->ptr) | |
| 444 #define poolLength(pool) ((pool)->ptr - (pool)->start) | |
| 445 #define poolChop(pool) ((void)--(pool->ptr)) | |
| 446 #define poolLastChar(pool) (((pool)->ptr)[-1]) | |
| 447 #define poolDiscard(pool) ((pool)->ptr = (pool)->start) | |
| 448 #define poolFinish(pool) ((pool)->start = (pool)->ptr) | |
| 449 #define poolAppendChar(pool, c) \ | |
| 450 (((pool)->ptr == (pool)->end && !poolGrow(pool)) \ | |
| 451 ? 0 \ | |
| 452 : ((*((pool)->ptr)++ = c), 1)) | |
| 453 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
454 struct XML_ParserStruct { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
455 /* 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
|
456 macro works. */ |
| 21930 | 457 void *m_userData; |
| 458 void *m_handlerArg; | |
| 459 char *m_buffer; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
460 const XML_Memory_Handling_Suite m_mem; |
| 21930 | 461 /* first character to be parsed */ |
| 462 const char *m_bufferPtr; | |
| 463 /* past last character to be parsed */ | |
| 464 char *m_bufferEnd; | |
| 465 /* allocated end of buffer */ | |
| 466 const char *m_bufferLim; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
467 XML_Index m_parseEndByteIndex; |
| 21930 | 468 const char *m_parseEndPtr; |
| 469 XML_Char *m_dataBuf; | |
| 470 XML_Char *m_dataBufEnd; | |
| 471 XML_StartElementHandler m_startElementHandler; | |
| 472 XML_EndElementHandler m_endElementHandler; | |
| 473 XML_CharacterDataHandler m_characterDataHandler; | |
| 474 XML_ProcessingInstructionHandler m_processingInstructionHandler; | |
| 475 XML_CommentHandler m_commentHandler; | |
| 476 XML_StartCdataSectionHandler m_startCdataSectionHandler; | |
| 477 XML_EndCdataSectionHandler m_endCdataSectionHandler; | |
| 478 XML_DefaultHandler m_defaultHandler; | |
| 479 XML_StartDoctypeDeclHandler m_startDoctypeDeclHandler; | |
| 480 XML_EndDoctypeDeclHandler m_endDoctypeDeclHandler; | |
| 481 XML_UnparsedEntityDeclHandler m_unparsedEntityDeclHandler; | |
| 482 XML_NotationDeclHandler m_notationDeclHandler; | |
| 483 XML_StartNamespaceDeclHandler m_startNamespaceDeclHandler; | |
| 484 XML_EndNamespaceDeclHandler m_endNamespaceDeclHandler; | |
| 485 XML_NotStandaloneHandler m_notStandaloneHandler; | |
| 486 XML_ExternalEntityRefHandler m_externalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
487 XML_Parser m_externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
488 XML_SkippedEntityHandler m_skippedEntityHandler; |
| 21930 | 489 XML_UnknownEncodingHandler m_unknownEncodingHandler; |
| 490 XML_ElementDeclHandler m_elementDeclHandler; | |
| 491 XML_AttlistDeclHandler m_attlistDeclHandler; | |
| 492 XML_EntityDeclHandler m_entityDeclHandler; | |
| 493 XML_XmlDeclHandler m_xmlDeclHandler; | |
| 494 const ENCODING *m_encoding; | |
| 495 INIT_ENCODING m_initEncoding; | |
| 496 const ENCODING *m_internalEncoding; | |
| 497 const XML_Char *m_protocolEncodingName; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
498 XML_Bool m_ns; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
499 XML_Bool m_ns_triplets; |
| 21930 | 500 void *m_unknownEncodingMem; |
| 501 void *m_unknownEncodingData; | |
| 502 void *m_unknownEncodingHandlerData; | |
| 32911 | 503 void (XMLCALL *m_unknownEncodingRelease)(void *); |
| 21930 | 504 PROLOG_STATE m_prologState; |
| 505 Processor *m_processor; | |
| 506 enum XML_Error m_errorCode; | |
| 507 const char *m_eventPtr; | |
| 508 const char *m_eventEndPtr; | |
| 509 const char *m_positionPtr; | |
| 510 OPEN_INTERNAL_ENTITY *m_openInternalEntities; | |
| 32911 | 511 OPEN_INTERNAL_ENTITY *m_freeInternalEntities; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
512 XML_Bool m_defaultExpandInternalEntities; |
| 21930 | 513 int m_tagLevel; |
| 514 ENTITY *m_declEntity; | |
| 515 const XML_Char *m_doctypeName; | |
| 516 const XML_Char *m_doctypeSysid; | |
| 517 const XML_Char *m_doctypePubid; | |
| 518 const XML_Char *m_declAttributeType; | |
| 519 const XML_Char *m_declNotationName; | |
| 520 const XML_Char *m_declNotationPublicId; | |
| 521 ELEMENT_TYPE *m_declElementType; | |
| 522 ATTRIBUTE_ID *m_declAttributeId; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
523 XML_Bool m_declAttributeIsCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
524 XML_Bool m_declAttributeIsId; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
525 DTD *m_dtd; |
| 21930 | 526 const XML_Char *m_curBase; |
| 527 TAG *m_tagStack; | |
| 528 TAG *m_freeTagList; | |
| 529 BINDING *m_inheritedBindings; | |
| 530 BINDING *m_freeBindingList; | |
| 531 int m_attsSize; | |
| 532 int m_nSpecifiedAtts; | |
| 533 int m_idAttIndex; | |
| 534 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
|
535 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
|
536 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
|
537 unsigned char m_nsAttsPower; |
| 21930 | 538 POSITION m_position; |
| 539 STRING_POOL m_tempPool; | |
| 540 STRING_POOL m_temp2Pool; | |
| 541 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
|
542 unsigned int m_groupSize; |
| 21930 | 543 XML_Char m_namespaceSeparator; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
544 XML_Parser m_parentParser; |
| 32911 | 545 XML_ParsingStatus m_parsingStatus; |
| 21930 | 546 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
547 XML_Bool m_isParamEntity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
548 XML_Bool m_useForeignDTD; |
| 21930 | 549 enum XML_ParamEntityParsing m_paramEntityParsing; |
| 550 #endif | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
551 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
|
552 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
553 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
554 #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
|
555 #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
|
556 #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
|
557 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
558 #define userData (parser->m_userData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
559 #define handlerArg (parser->m_handlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
560 #define startElementHandler (parser->m_startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
561 #define endElementHandler (parser->m_endElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
562 #define characterDataHandler (parser->m_characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
563 #define processingInstructionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
564 (parser->m_processingInstructionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
565 #define commentHandler (parser->m_commentHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
566 #define startCdataSectionHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
567 (parser->m_startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
568 #define endCdataSectionHandler (parser->m_endCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
569 #define defaultHandler (parser->m_defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
570 #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
571 #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
572 #define unparsedEntityDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
573 (parser->m_unparsedEntityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
574 #define notationDeclHandler (parser->m_notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
575 #define startNamespaceDeclHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
576 (parser->m_startNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
577 #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
578 #define notStandaloneHandler (parser->m_notStandaloneHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
579 #define externalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
580 (parser->m_externalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
581 #define externalEntityRefHandlerArg \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
582 (parser->m_externalEntityRefHandlerArg) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
583 #define internalEntityRefHandler \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
584 (parser->m_internalEntityRefHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
585 #define skippedEntityHandler (parser->m_skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
586 #define unknownEncodingHandler (parser->m_unknownEncodingHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
587 #define elementDeclHandler (parser->m_elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
588 #define attlistDeclHandler (parser->m_attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
589 #define entityDeclHandler (parser->m_entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
590 #define xmlDeclHandler (parser->m_xmlDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
591 #define encoding (parser->m_encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
592 #define initEncoding (parser->m_initEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
593 #define internalEncoding (parser->m_internalEncoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
594 #define unknownEncodingMem (parser->m_unknownEncodingMem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
595 #define unknownEncodingData (parser->m_unknownEncodingData) |
| 21930 | 596 #define unknownEncodingHandlerData \ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
597 (parser->m_unknownEncodingHandlerData) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
598 #define unknownEncodingRelease (parser->m_unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
599 #define protocolEncodingName (parser->m_protocolEncodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
600 #define ns (parser->m_ns) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
601 #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
|
602 #define prologState (parser->m_prologState) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
603 #define processor (parser->m_processor) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
604 #define errorCode (parser->m_errorCode) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
605 #define eventPtr (parser->m_eventPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
606 #define eventEndPtr (parser->m_eventEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
607 #define positionPtr (parser->m_positionPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
608 #define position (parser->m_position) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
609 #define openInternalEntities (parser->m_openInternalEntities) |
| 32911 | 610 #define freeInternalEntities (parser->m_freeInternalEntities) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
611 #define defaultExpandInternalEntities \ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
612 (parser->m_defaultExpandInternalEntities) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
613 #define tagLevel (parser->m_tagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
614 #define buffer (parser->m_buffer) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
615 #define bufferPtr (parser->m_bufferPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
616 #define bufferEnd (parser->m_bufferEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
617 #define parseEndByteIndex (parser->m_parseEndByteIndex) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
618 #define parseEndPtr (parser->m_parseEndPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
619 #define bufferLim (parser->m_bufferLim) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
620 #define dataBuf (parser->m_dataBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
621 #define dataBufEnd (parser->m_dataBufEnd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
622 #define _dtd (parser->m_dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
623 #define curBase (parser->m_curBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
624 #define declEntity (parser->m_declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
625 #define doctypeName (parser->m_doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
626 #define doctypeSysid (parser->m_doctypeSysid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
627 #define doctypePubid (parser->m_doctypePubid) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
628 #define declAttributeType (parser->m_declAttributeType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
629 #define declNotationName (parser->m_declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
630 #define declNotationPublicId (parser->m_declNotationPublicId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
631 #define declElementType (parser->m_declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
632 #define declAttributeId (parser->m_declAttributeId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
633 #define declAttributeIsCdata (parser->m_declAttributeIsCdata) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
634 #define declAttributeIsId (parser->m_declAttributeIsId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
635 #define freeTagList (parser->m_freeTagList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
636 #define freeBindingList (parser->m_freeBindingList) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
637 #define inheritedBindings (parser->m_inheritedBindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
638 #define tagStack (parser->m_tagStack) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
639 #define atts (parser->m_atts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
640 #define attsSize (parser->m_attsSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
641 #define nSpecifiedAtts (parser->m_nSpecifiedAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
642 #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
|
643 #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
|
644 #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
|
645 #define nsAttsPower (parser->m_nsAttsPower) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
646 #define tempPool (parser->m_tempPool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
647 #define temp2Pool (parser->m_temp2Pool) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
648 #define groupConnector (parser->m_groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
649 #define groupSize (parser->m_groupSize) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
650 #define namespaceSeparator (parser->m_namespaceSeparator) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
651 #define parentParser (parser->m_parentParser) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
652 #define ps_parsing (parser->m_parsingStatus.parsing) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
653 #define ps_finalBuffer (parser->m_parsingStatus.finalBuffer) |
| 21930 | 654 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
655 #define isParamEntity (parser->m_isParamEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
656 #define useForeignDTD (parser->m_useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
657 #define paramEntityParsing (parser->m_paramEntityParsing) |
| 21930 | 658 #endif /* XML_DTD */ |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
659 #define hash_secret_salt (parser->m_hash_secret_salt) |
| 21930 | 660 |
|
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
|
661 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
662 XML_ParserCreate(const XML_Char *encodingName) |
| 21930 | 663 { |
| 664 return XML_ParserCreate_MM(encodingName, NULL, NULL); | |
| 665 } | |
| 666 | |
|
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
|
667 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
668 XML_ParserCreateNS(const XML_Char *encodingName, XML_Char nsSep) |
| 21930 | 669 { |
| 670 XML_Char tmp[2]; | |
| 671 *tmp = nsSep; | |
| 672 return XML_ParserCreate_MM(encodingName, NULL, tmp); | |
| 673 } | |
| 674 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
675 static const XML_Char implicitContext[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
676 'x', 'm', 'l', '=', 'h', 't', 't', 'p', ':', '/', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
677 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
678 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
679 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
680 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
681 |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
682 static unsigned long |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
683 generate_hash_secret_salt(void) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
684 { |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
685 unsigned int seed = time(NULL) % UINT_MAX; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
686 srand(seed); |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
687 return rand(); |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
688 } |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
689 |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
690 static XML_Bool /* only valid for root parser */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
691 startParsing(XML_Parser parser) |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
692 { |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
693 /* hash functions must be initialized before setContext() is called */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
694 |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
695 if (hash_secret_salt == 0) |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
696 hash_secret_salt = generate_hash_secret_salt(); |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
697 if (ns) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
698 /* implicit context only set for root parser, since child |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
699 parsers (i.e. external entity parsers) will inherit it |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
700 */ |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
701 return setContext(parser, implicitContext); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
702 } |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
703 return XML_TRUE; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
704 } |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
705 |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
706 XML_Parser XMLCALL |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
707 XML_ParserCreate_MM(const XML_Char *encodingName, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
708 const XML_Memory_Handling_Suite *memsuite, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
709 const XML_Char *nameSep) |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
710 { |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
711 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
|
712 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
713 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
714 static XML_Parser |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
715 parserCreate(const XML_Char *encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
716 const XML_Memory_Handling_Suite *memsuite, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
717 const XML_Char *nameSep, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
718 DTD *dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
719 { |
| 21930 | 720 XML_Parser parser; |
| 721 | |
| 722 if (memsuite) { | |
| 723 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
724 parser = (XML_Parser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
725 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
|
726 if (parser != NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
727 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
|
728 mtemp->malloc_fcn = memsuite->malloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
729 mtemp->realloc_fcn = memsuite->realloc_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
730 mtemp->free_fcn = memsuite->free_fcn; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
731 } |
| 21930 | 732 } |
| 733 else { | |
| 734 XML_Memory_Handling_Suite *mtemp; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
735 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
|
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 = malloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
739 mtemp->realloc_fcn = realloc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
740 mtemp->free_fcn = free; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
741 } |
| 21930 | 742 } |
| 743 | |
| 744 if (!parser) | |
| 745 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
746 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
747 buffer = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
748 bufferLim = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
749 |
| 21930 | 750 attsSize = INIT_ATTS_SIZE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
751 atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
752 if (atts == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
753 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
754 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
755 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
756 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
|
757 if (dataBuf == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
758 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
759 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
760 return NULL; |
| 21930 | 761 } |
| 762 dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; | |
| 763 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
764 if (dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
765 _dtd = dtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
766 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
767 _dtd = dtdCreate(&parser->m_mem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
768 if (_dtd == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
769 FREE(dataBuf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
770 FREE(atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
771 FREE(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
772 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
773 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
774 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
775 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
776 freeBindingList = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
777 freeTagList = NULL; |
| 32911 | 778 freeInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
779 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
780 groupSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
781 groupConnector = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
782 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
783 unknownEncodingHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
784 unknownEncodingHandlerData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
785 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
786 namespaceSeparator = '!'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
787 ns = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
788 ns_triplets = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
789 |
|
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
|
790 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
|
791 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
|
792 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
|
793 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
794 poolInit(&tempPool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
795 poolInit(&temp2Pool, &(parser->m_mem)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
796 parserInit(parser, encodingName); |
|
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 if (encodingName && !protocolEncodingName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
799 XML_ParserFree(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
800 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
801 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
802 |
| 21930 | 803 if (nameSep) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
804 ns = XML_TRUE; |
| 21930 | 805 internalEncoding = XmlGetInternalEncodingNS(); |
| 806 namespaceSeparator = *nameSep; | |
| 807 } | |
| 808 else { | |
| 809 internalEncoding = XmlGetInternalEncoding(); | |
| 810 } | |
| 811 | |
| 812 return parser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
813 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
814 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
815 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
816 parserInit(XML_Parser parser, const XML_Char *encodingName) |
| 21930 | 817 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
818 processor = prologInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
819 XmlPrologStateInit(&prologState); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
820 protocolEncodingName = (encodingName != NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
821 ? poolCopyString(&tempPool, encodingName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
822 : NULL); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
823 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
824 XmlInitEncoding(&initEncoding, &encoding, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
825 userData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
826 handlerArg = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
827 startElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
828 endElementHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
829 characterDataHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
830 processingInstructionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
831 commentHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
832 startCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
833 endCdataSectionHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
834 defaultHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
835 startDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
836 endDoctypeDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
837 unparsedEntityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
838 notationDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
839 startNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
840 endNamespaceDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
841 notStandaloneHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
842 externalEntityRefHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
843 externalEntityRefHandlerArg = parser; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
844 skippedEntityHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
845 elementDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
846 attlistDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
847 entityDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
848 xmlDeclHandler = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
849 bufferPtr = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
850 bufferEnd = buffer; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
851 parseEndByteIndex = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
852 parseEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
853 declElementType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
854 declAttributeId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
855 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
856 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
857 doctypeSysid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
858 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
859 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
860 declNotationName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
861 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
862 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
863 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
864 memset(&position, 0, sizeof(POSITION)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
865 errorCode = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
866 eventPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
867 eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
868 positionPtr = NULL; |
| 32911 | 869 openInternalEntities = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
870 defaultExpandInternalEntities = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
871 tagLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
872 tagStack = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
873 inheritedBindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
874 nSpecifiedAtts = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
875 unknownEncodingMem = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
876 unknownEncodingRelease = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
877 unknownEncodingData = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
878 parentParser = NULL; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
879 ps_parsing = XML_INITIALIZED; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
880 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
881 isParamEntity = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
882 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
883 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
884 #endif |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
885 hash_secret_salt = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
886 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
887 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
888 /* moves list of bindings to freeBindingList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
889 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
890 moveToFreeBindingList(XML_Parser parser, BINDING *bindings) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
891 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
892 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
893 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
894 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
895 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
896 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
897 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
898 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
899 |
|
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
|
900 XML_Bool XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
901 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
|
902 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
903 TAG *tStk; |
| 32911 | 904 OPEN_INTERNAL_ENTITY *openEntityList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
905 if (parentParser) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
906 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
907 /* move tagStack to freeTagList */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
908 tStk = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
909 while (tStk) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
910 TAG *tag = tStk; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
911 tStk = tStk->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
912 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
913 moveToFreeBindingList(parser, tag->bindings); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
914 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
915 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
916 } |
| 32911 | 917 /* move openInternalEntities to freeInternalEntities */ |
| 918 openEntityList = openInternalEntities; | |
| 919 while (openEntityList) { | |
| 920 OPEN_INTERNAL_ENTITY *openEntity = openEntityList; | |
| 921 openEntityList = openEntity->next; | |
| 922 openEntity->next = freeInternalEntities; | |
| 923 freeInternalEntities = openEntity; | |
| 924 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
925 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
|
926 FREE(unknownEncodingMem); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
927 if (unknownEncodingRelease) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
928 unknownEncodingRelease(unknownEncodingData); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
929 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
930 poolClear(&temp2Pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
931 parserInit(parser, encodingName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
932 dtdReset(_dtd, &parser->m_mem); |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
933 return XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
934 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
935 |
|
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
|
936 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
937 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
|
938 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
939 /* 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
|
940 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
|
941 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
|
942 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
943 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
|
944 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
945 if (encodingName == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
946 protocolEncodingName = NULL; |
| 21930 | 947 else { |
| 948 protocolEncodingName = poolCopyString(&tempPool, encodingName); | |
| 949 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
950 return XML_STATUS_ERROR; |
| 21930 | 951 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
952 return XML_STATUS_OK; |
| 21930 | 953 } |
| 954 | |
|
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
|
955 XML_Parser XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
956 XML_ExternalEntityParserCreate(XML_Parser oldParser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
957 const XML_Char *context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
958 const XML_Char *encodingName) |
| 21930 | 959 { |
| 960 XML_Parser parser = oldParser; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
961 DTD *newDtd = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
962 DTD *oldDtd = _dtd; |
| 21930 | 963 XML_StartElementHandler oldStartElementHandler = startElementHandler; |
| 964 XML_EndElementHandler oldEndElementHandler = endElementHandler; | |
| 965 XML_CharacterDataHandler oldCharacterDataHandler = characterDataHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
966 XML_ProcessingInstructionHandler oldProcessingInstructionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
967 = processingInstructionHandler; |
| 21930 | 968 XML_CommentHandler oldCommentHandler = commentHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
969 XML_StartCdataSectionHandler oldStartCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
970 = startCdataSectionHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
971 XML_EndCdataSectionHandler oldEndCdataSectionHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
972 = endCdataSectionHandler; |
| 21930 | 973 XML_DefaultHandler oldDefaultHandler = defaultHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
974 XML_UnparsedEntityDeclHandler oldUnparsedEntityDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
975 = unparsedEntityDeclHandler; |
| 21930 | 976 XML_NotationDeclHandler oldNotationDeclHandler = notationDeclHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
977 XML_StartNamespaceDeclHandler oldStartNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
978 = startNamespaceDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
979 XML_EndNamespaceDeclHandler oldEndNamespaceDeclHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
980 = endNamespaceDeclHandler; |
| 21930 | 981 XML_NotStandaloneHandler oldNotStandaloneHandler = notStandaloneHandler; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
982 XML_ExternalEntityRefHandler oldExternalEntityRefHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
983 = externalEntityRefHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
984 XML_SkippedEntityHandler oldSkippedEntityHandler = skippedEntityHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
985 XML_UnknownEncodingHandler oldUnknownEncodingHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
986 = unknownEncodingHandler; |
| 21930 | 987 XML_ElementDeclHandler oldElementDeclHandler = elementDeclHandler; |
| 988 XML_AttlistDeclHandler oldAttlistDeclHandler = attlistDeclHandler; | |
| 989 XML_EntityDeclHandler oldEntityDeclHandler = entityDeclHandler; | |
| 990 XML_XmlDeclHandler oldXmlDeclHandler = xmlDeclHandler; | |
| 991 ELEMENT_TYPE * oldDeclElementType = declElementType; | |
| 992 | |
| 993 void *oldUserData = userData; | |
| 994 void *oldHandlerArg = handlerArg; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
995 XML_Bool oldDefaultExpandInternalEntities = defaultExpandInternalEntities; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
996 XML_Parser oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
997 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
998 enum XML_ParamEntityParsing oldParamEntityParsing = paramEntityParsing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
999 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1000 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1001 XML_Bool oldns_triplets = ns_triplets; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1002 /* Note that the new parser shares the same hash secret as the old |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1003 parser, so that dtdCopy and copyEntityTable can lookup values |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1004 from hash tables associated with either parser without us having |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1005 to worry which hash secrets each table has. |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1006 */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1007 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
|
1008 |
| 21930 | 1009 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1010 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1011 newDtd = oldDtd; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1012 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1013 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1014 /* 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
|
1015 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
|
1016 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
|
1017 would be otherwise. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1018 */ |
| 21930 | 1019 if (ns) { |
| 1020 XML_Char tmp[2]; | |
| 1021 *tmp = namespaceSeparator; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1022 parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); |
| 21930 | 1023 } |
| 1024 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1025 parser = parserCreate(encodingName, &parser->m_mem, NULL, newDtd); |
| 21930 | 1026 } |
| 1027 | |
| 1028 if (!parser) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1029 return NULL; |
| 21930 | 1030 |
| 1031 startElementHandler = oldStartElementHandler; | |
| 1032 endElementHandler = oldEndElementHandler; | |
| 1033 characterDataHandler = oldCharacterDataHandler; | |
| 1034 processingInstructionHandler = oldProcessingInstructionHandler; | |
| 1035 commentHandler = oldCommentHandler; | |
| 1036 startCdataSectionHandler = oldStartCdataSectionHandler; | |
| 1037 endCdataSectionHandler = oldEndCdataSectionHandler; | |
| 1038 defaultHandler = oldDefaultHandler; | |
| 1039 unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; | |
| 1040 notationDeclHandler = oldNotationDeclHandler; | |
| 1041 startNamespaceDeclHandler = oldStartNamespaceDeclHandler; | |
| 1042 endNamespaceDeclHandler = oldEndNamespaceDeclHandler; | |
| 1043 notStandaloneHandler = oldNotStandaloneHandler; | |
| 1044 externalEntityRefHandler = oldExternalEntityRefHandler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1045 skippedEntityHandler = oldSkippedEntityHandler; |
| 21930 | 1046 unknownEncodingHandler = oldUnknownEncodingHandler; |
| 1047 elementDeclHandler = oldElementDeclHandler; | |
| 1048 attlistDeclHandler = oldAttlistDeclHandler; | |
| 1049 entityDeclHandler = oldEntityDeclHandler; | |
| 1050 xmlDeclHandler = oldXmlDeclHandler; | |
| 1051 declElementType = oldDeclElementType; | |
| 1052 userData = oldUserData; | |
| 1053 if (oldUserData == oldHandlerArg) | |
| 1054 handlerArg = userData; | |
| 1055 else | |
| 1056 handlerArg = parser; | |
| 1057 if (oldExternalEntityRefHandlerArg != oldParser) | |
| 1058 externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; | |
| 1059 defaultExpandInternalEntities = oldDefaultExpandInternalEntities; | |
| 1060 ns_triplets = oldns_triplets; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1061 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
|
1062 parentParser = oldParser; |
| 21930 | 1063 #ifdef XML_DTD |
| 1064 paramEntityParsing = oldParamEntityParsing; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1065 prologState.inEntityValue = oldInEntityValue; |
| 21930 | 1066 if (context) { |
| 1067 #endif /* XML_DTD */ | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1068 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
|
1069 || !setContext(parser, context)) { |
| 21930 | 1070 XML_ParserFree(parser); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1071 return NULL; |
| 21930 | 1072 } |
| 1073 processor = externalEntityInitProcessor; | |
| 1074 #ifdef XML_DTD | |
| 1075 } | |
| 1076 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1077 /* 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
|
1078 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
|
1079 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
|
1080 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
|
1081 _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
|
1082 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
|
1083 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1084 isParamEntity = XML_TRUE; |
| 21930 | 1085 XmlPrologStateInitExternalEntity(&prologState); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1086 processor = externalParEntInitProcessor; |
| 21930 | 1087 } |
| 1088 #endif /* XML_DTD */ | |
| 1089 return parser; | |
| 1090 } | |
| 1091 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1092 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1093 destroyBindings(BINDING *bindings, XML_Parser parser) |
| 21930 | 1094 { |
| 1095 for (;;) { | |
| 1096 BINDING *b = bindings; | |
| 1097 if (!b) | |
| 1098 break; | |
| 1099 bindings = b->nextTagBinding; | |
| 1100 FREE(b->uri); | |
| 1101 FREE(b); | |
| 1102 } | |
| 1103 } | |
| 1104 | |
|
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
|
1105 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1106 XML_ParserFree(XML_Parser parser) |
| 21930 | 1107 { |
| 32911 | 1108 TAG *tagList; |
| 1109 OPEN_INTERNAL_ENTITY *entityList; | |
| 1110 if (parser == NULL) | |
| 1111 return; | |
| 1112 /* free tagStack and freeTagList */ | |
| 1113 tagList = tagStack; | |
| 21930 | 1114 for (;;) { |
| 1115 TAG *p; | |
| 32911 | 1116 if (tagList == NULL) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1117 if (freeTagList == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1118 break; |
| 32911 | 1119 tagList = freeTagList; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1120 freeTagList = NULL; |
| 21930 | 1121 } |
| 32911 | 1122 p = tagList; |
| 1123 tagList = tagList->parent; | |
| 21930 | 1124 FREE(p->buf); |
| 1125 destroyBindings(p->bindings, parser); | |
| 1126 FREE(p); | |
| 1127 } | |
| 32911 | 1128 /* free openInternalEntities and freeInternalEntities */ |
| 1129 entityList = openInternalEntities; | |
| 1130 for (;;) { | |
| 1131 OPEN_INTERNAL_ENTITY *openEntity; | |
| 1132 if (entityList == NULL) { | |
| 1133 if (freeInternalEntities == NULL) | |
| 1134 break; | |
| 1135 entityList = freeInternalEntities; | |
| 1136 freeInternalEntities = NULL; | |
| 1137 } | |
| 1138 openEntity = entityList; | |
| 1139 entityList = entityList->next; | |
| 1140 FREE(openEntity); | |
| 1141 } | |
| 1142 | |
| 21930 | 1143 destroyBindings(freeBindingList, parser); |
| 1144 destroyBindings(inheritedBindings, parser); | |
| 1145 poolDestroy(&tempPool); | |
| 1146 poolDestroy(&temp2Pool); | |
| 1147 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1148 /* 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
|
1149 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
|
1150 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1151 if (!isParamEntity && _dtd) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1152 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1153 if (_dtd) |
| 21930 | 1154 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1155 dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); |
| 21930 | 1156 FREE((void *)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
|
1157 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
|
1158 FREE(buffer); |
| 21930 | 1159 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
|
1160 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
|
1161 FREE(unknownEncodingMem); |
| 21930 | 1162 if (unknownEncodingRelease) |
| 1163 unknownEncodingRelease(unknownEncodingData); | |
| 1164 FREE(parser); | |
| 1165 } | |
| 1166 | |
|
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
|
1167 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1168 XML_UseParserAsHandlerArg(XML_Parser parser) |
| 21930 | 1169 { |
| 1170 handlerArg = parser; | |
| 1171 } | |
| 1172 | |
|
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
|
1173 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1174 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
|
1175 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1176 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1177 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1178 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
|
1179 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
|
1180 useForeignDTD = useDTD; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1181 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1182 #else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1183 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
|
1184 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1185 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1186 |
|
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 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1188 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
|
1189 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1190 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1191 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
|
1192 return; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1193 ns_triplets = do_nst ? XML_TRUE : XML_FALSE; |
| 21930 | 1194 } |
| 1195 | |
|
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
|
1196 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1197 XML_SetUserData(XML_Parser parser, void *p) |
| 21930 | 1198 { |
| 1199 if (handlerArg == userData) | |
| 1200 handlerArg = userData = p; | |
| 1201 else | |
| 1202 userData = p; | |
| 1203 } | |
| 1204 | |
|
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
|
1205 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1206 XML_SetBase(XML_Parser parser, const XML_Char *p) |
| 21930 | 1207 { |
| 1208 if (p) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1209 p = poolCopyString(&_dtd->pool, p); |
| 21930 | 1210 if (!p) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1211 return XML_STATUS_ERROR; |
| 21930 | 1212 curBase = p; |
| 1213 } | |
| 1214 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1215 curBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1216 return XML_STATUS_OK; |
| 21930 | 1217 } |
| 1218 | |
|
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
|
1219 const XML_Char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1220 XML_GetBase(XML_Parser parser) |
| 21930 | 1221 { |
| 1222 return curBase; | |
| 1223 } | |
| 1224 | |
|
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
|
1225 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1226 XML_GetSpecifiedAttributeCount(XML_Parser parser) |
| 21930 | 1227 { |
| 1228 return nSpecifiedAtts; | |
| 1229 } | |
| 1230 | |
|
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
|
1231 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1232 XML_GetIdAttributeIndex(XML_Parser parser) |
| 21930 | 1233 { |
| 1234 return idAttIndex; | |
| 1235 } | |
| 1236 | |
|
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
|
1237 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1238 XML_SetElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1239 XML_StartElementHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1240 XML_EndElementHandler end) |
| 21930 | 1241 { |
| 1242 startElementHandler = start; | |
| 1243 endElementHandler = end; | |
| 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 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1247 XML_SetStartElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1248 XML_StartElementHandler start) { |
| 21930 | 1249 startElementHandler = start; |
| 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 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1253 XML_SetEndElementHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1254 XML_EndElementHandler end) { |
| 21930 | 1255 endElementHandler = end; |
| 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 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1259 XML_SetCharacterDataHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1260 XML_CharacterDataHandler handler) |
| 21930 | 1261 { |
| 1262 characterDataHandler = handler; | |
| 1263 } | |
| 1264 | |
|
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
|
1265 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1266 XML_SetProcessingInstructionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1267 XML_ProcessingInstructionHandler handler) |
| 21930 | 1268 { |
| 1269 processingInstructionHandler = handler; | |
| 1270 } | |
| 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_SetCommentHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1274 XML_CommentHandler handler) |
| 21930 | 1275 { |
| 1276 commentHandler = handler; | |
| 1277 } | |
| 1278 | |
|
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
|
1279 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1280 XML_SetCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1281 XML_StartCdataSectionHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1282 XML_EndCdataSectionHandler end) |
| 21930 | 1283 { |
| 1284 startCdataSectionHandler = start; | |
| 1285 endCdataSectionHandler = end; | |
| 1286 } | |
| 1287 | |
|
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
|
1288 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1289 XML_SetStartCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1290 XML_StartCdataSectionHandler start) { |
| 21930 | 1291 startCdataSectionHandler = start; |
| 1292 } | |
| 1293 | |
|
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
|
1294 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1295 XML_SetEndCdataSectionHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1296 XML_EndCdataSectionHandler end) { |
| 21930 | 1297 endCdataSectionHandler = end; |
| 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_SetDefaultHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1302 XML_DefaultHandler handler) |
| 21930 | 1303 { |
| 1304 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1305 defaultExpandInternalEntities = XML_FALSE; |
| 21930 | 1306 } |
| 1307 | |
|
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
|
1308 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1309 XML_SetDefaultHandlerExpand(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1310 XML_DefaultHandler handler) |
| 21930 | 1311 { |
| 1312 defaultHandler = handler; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1313 defaultExpandInternalEntities = XML_TRUE; |
| 21930 | 1314 } |
| 1315 | |
|
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
|
1316 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1317 XML_SetDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1318 XML_StartDoctypeDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1319 XML_EndDoctypeDeclHandler end) |
| 21930 | 1320 { |
| 1321 startDoctypeDeclHandler = start; | |
| 1322 endDoctypeDeclHandler = end; | |
| 1323 } | |
| 1324 | |
|
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
|
1325 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1326 XML_SetStartDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1327 XML_StartDoctypeDeclHandler start) { |
| 21930 | 1328 startDoctypeDeclHandler = start; |
| 1329 } | |
| 1330 | |
|
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
|
1331 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1332 XML_SetEndDoctypeDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1333 XML_EndDoctypeDeclHandler end) { |
| 21930 | 1334 endDoctypeDeclHandler = end; |
| 1335 } | |
| 1336 | |
|
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
|
1337 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1338 XML_SetUnparsedEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1339 XML_UnparsedEntityDeclHandler handler) |
| 21930 | 1340 { |
| 1341 unparsedEntityDeclHandler = handler; | |
| 1342 } | |
| 1343 | |
|
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
|
1344 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1345 XML_SetNotationDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1346 XML_NotationDeclHandler handler) |
| 21930 | 1347 { |
| 1348 notationDeclHandler = handler; | |
| 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_SetNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1353 XML_StartNamespaceDeclHandler start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1354 XML_EndNamespaceDeclHandler end) |
| 21930 | 1355 { |
| 1356 startNamespaceDeclHandler = start; | |
| 1357 endNamespaceDeclHandler = 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_SetStartNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1362 XML_StartNamespaceDeclHandler start) { |
| 21930 | 1363 startNamespaceDeclHandler = 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_SetEndNamespaceDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1368 XML_EndNamespaceDeclHandler end) { |
| 21930 | 1369 endNamespaceDeclHandler = 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_SetNotStandaloneHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1374 XML_NotStandaloneHandler handler) |
| 21930 | 1375 { |
| 1376 notStandaloneHandler = 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_SetExternalEntityRefHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1381 XML_ExternalEntityRefHandler handler) |
| 21930 | 1382 { |
| 1383 externalEntityRefHandler = 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_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) |
| 21930 | 1388 { |
| 1389 if (arg) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1390 externalEntityRefHandlerArg = (XML_Parser)arg; |
| 21930 | 1391 else |
| 1392 externalEntityRefHandlerArg = parser; | |
| 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_SetSkippedEntityHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1397 XML_SkippedEntityHandler handler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1398 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1399 skippedEntityHandler = handler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1400 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1401 |
|
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
|
1402 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1403 XML_SetUnknownEncodingHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1404 XML_UnknownEncodingHandler handler, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1405 void *data) |
| 21930 | 1406 { |
| 1407 unknownEncodingHandler = handler; | |
| 1408 unknownEncodingHandlerData = data; | |
| 1409 } | |
| 1410 | |
|
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
|
1411 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1412 XML_SetElementDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1413 XML_ElementDeclHandler eldecl) |
| 21930 | 1414 { |
| 1415 elementDeclHandler = eldecl; | |
| 1416 } | |
| 1417 | |
|
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
|
1418 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1419 XML_SetAttlistDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1420 XML_AttlistDeclHandler attdecl) |
| 21930 | 1421 { |
| 1422 attlistDeclHandler = attdecl; | |
| 1423 } | |
| 1424 | |
|
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
|
1425 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1426 XML_SetEntityDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1427 XML_EntityDeclHandler handler) |
| 21930 | 1428 { |
| 1429 entityDeclHandler = handler; | |
| 1430 } | |
| 1431 | |
|
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
|
1432 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1433 XML_SetXmlDeclHandler(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1434 XML_XmlDeclHandler handler) { |
| 21930 | 1435 xmlDeclHandler = handler; |
| 1436 } | |
| 1437 | |
|
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
|
1438 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1439 XML_SetParamEntityParsing(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1440 enum XML_ParamEntityParsing peParsing) |
| 21930 | 1441 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1442 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1443 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
|
1444 return 0; |
| 21930 | 1445 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1446 paramEntityParsing = peParsing; |
| 21930 | 1447 return 1; |
| 1448 #else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1449 return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; |
| 21930 | 1450 #endif |
| 1451 } | |
| 1452 | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1453 int XMLCALL |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1454 XML_SetHashSalt(XML_Parser parser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1455 unsigned long hash_salt) |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1456 { |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1457 /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1458 if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1459 return 0; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1460 hash_secret_salt = hash_salt; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1461 return 1; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1462 } |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1463 |
|
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
|
1464 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1465 XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) |
| 21930 | 1466 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1467 switch (ps_parsing) { |
| 32911 | 1468 case XML_SUSPENDED: |
| 1469 errorCode = XML_ERROR_SUSPENDED; | |
| 1470 return XML_STATUS_ERROR; | |
| 1471 case XML_FINISHED: | |
| 1472 errorCode = XML_ERROR_FINISHED; | |
| 1473 return XML_STATUS_ERROR; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1474 case XML_INITIALIZED: |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1475 if (parentParser == NULL && !startParsing(parser)) { |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1476 errorCode = XML_ERROR_NO_MEMORY; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1477 return XML_STATUS_ERROR; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1478 } |
| 32911 | 1479 default: |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1480 ps_parsing = XML_PARSING; |
| 32911 | 1481 } |
| 1482 | |
| 21930 | 1483 if (len == 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1484 ps_finalBuffer = (XML_Bool)isFinal; |
| 21930 | 1485 if (!isFinal) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1486 return XML_STATUS_OK; |
| 21930 | 1487 positionPtr = bufferPtr; |
| 32911 | 1488 parseEndPtr = bufferEnd; |
| 1489 | |
| 1490 /* If data are left over from last buffer, and we now know that these | |
| 1491 data are the final chunk of input, then we have to check them again | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1492 to detect errors based on that fact. |
| 32911 | 1493 */ |
| 1494 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1495 | |
| 1496 if (errorCode == XML_ERROR_NONE) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1497 switch (ps_parsing) { |
| 32911 | 1498 case XML_SUSPENDED: |
| 1499 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1500 positionPtr = bufferPtr; | |
| 1501 return XML_STATUS_SUSPENDED; | |
| 1502 case XML_INITIALIZED: | |
| 1503 case XML_PARSING: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1504 ps_parsing = XML_FINISHED; |
| 32911 | 1505 /* fall through */ |
| 1506 default: | |
| 1507 return XML_STATUS_OK; | |
| 1508 } | |
| 1509 } | |
| 21930 | 1510 eventEndPtr = eventPtr; |
| 1511 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1512 return XML_STATUS_ERROR; |
| 21930 | 1513 } |
| 1514 #ifndef XML_CONTEXT_BYTES | |
| 1515 else if (bufferPtr == bufferEnd) { | |
| 1516 const char *end; | |
| 1517 int nLeftOver; | |
| 32911 | 1518 enum XML_Error result; |
| 21930 | 1519 parseEndByteIndex += len; |
| 1520 positionPtr = s; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1521 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1522 |
| 21930 | 1523 errorCode = processor(parser, s, parseEndPtr = s + len, &end); |
| 32911 | 1524 |
| 21930 | 1525 if (errorCode != XML_ERROR_NONE) { |
| 1526 eventEndPtr = eventPtr; | |
| 1527 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1528 return XML_STATUS_ERROR; |
| 21930 | 1529 } |
| 32911 | 1530 else { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1531 switch (ps_parsing) { |
| 32911 | 1532 case XML_SUSPENDED: |
| 1533 result = XML_STATUS_SUSPENDED; | |
| 1534 break; | |
| 1535 case XML_INITIALIZED: | |
| 1536 case XML_PARSING: | |
| 1537 if (isFinal) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1538 ps_parsing = XML_FINISHED; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1539 return XML_STATUS_OK; |
| 32911 | 1540 } |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1541 /* fall through */ |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1542 default: |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1543 result = XML_STATUS_OK; |
| 32911 | 1544 } |
| 1545 } | |
| 1546 | |
| 21930 | 1547 XmlUpdatePosition(encoding, positionPtr, end, &position); |
| 1548 nLeftOver = s + len - end; | |
| 1549 if (nLeftOver) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1550 if (buffer == NULL || nLeftOver > bufferLim - buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1551 /* FIXME avoid integer overflow */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1552 char *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1553 temp = (buffer == NULL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1554 ? (char *)MALLOC(len * 2) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1555 : (char *)REALLOC(buffer, len * 2)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1556 if (temp == NULL) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1557 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1558 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1559 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1560 buffer = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1561 if (!buffer) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1562 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1563 eventPtr = eventEndPtr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1564 processor = errorProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1565 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1566 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1567 bufferLim = buffer + len * 2; |
| 21930 | 1568 } |
| 1569 memcpy(buffer, end, nLeftOver); | |
| 1570 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1571 bufferPtr = buffer; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1572 bufferEnd = buffer + nLeftOver; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1573 positionPtr = bufferPtr; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1574 parseEndPtr = bufferEnd; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1575 eventPtr = bufferPtr; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1576 eventEndPtr = bufferPtr; |
| 32911 | 1577 return result; |
| 21930 | 1578 } |
| 1579 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1580 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1581 void *buff = XML_GetBuffer(parser, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1582 if (buff == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1583 return XML_STATUS_ERROR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1584 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1585 memcpy(buff, s, len); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1586 return XML_ParseBuffer(parser, len, isFinal); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1587 } |
| 21930 | 1588 } |
| 1589 } | |
| 1590 | |
|
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
|
1591 enum XML_Status XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1592 XML_ParseBuffer(XML_Parser parser, int len, int isFinal) |
| 21930 | 1593 { |
| 32911 | 1594 const char *start; |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1595 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1596 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1597 switch (ps_parsing) { |
| 32911 | 1598 case XML_SUSPENDED: |
| 1599 errorCode = XML_ERROR_SUSPENDED; | |
| 1600 return XML_STATUS_ERROR; | |
| 1601 case XML_FINISHED: | |
| 1602 errorCode = XML_ERROR_FINISHED; | |
| 1603 return XML_STATUS_ERROR; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1604 case XML_INITIALIZED: |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1605 if (parentParser == NULL && !startParsing(parser)) { |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1606 errorCode = XML_ERROR_NO_MEMORY; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1607 return XML_STATUS_ERROR; |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
1608 } |
| 32911 | 1609 default: |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1610 ps_parsing = XML_PARSING; |
| 32911 | 1611 } |
| 1612 | |
| 1613 start = bufferPtr; | |
| 21930 | 1614 positionPtr = start; |
| 1615 bufferEnd += len; | |
| 32911 | 1616 parseEndPtr = bufferEnd; |
| 21930 | 1617 parseEndByteIndex += len; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1618 ps_finalBuffer = (XML_Bool)isFinal; |
| 32911 | 1619 |
| 1620 errorCode = processor(parser, start, parseEndPtr, &bufferPtr); | |
| 1621 | |
| 1622 if (errorCode != XML_ERROR_NONE) { | |
| 21930 | 1623 eventEndPtr = eventPtr; |
| 1624 processor = errorProcessor; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1625 return XML_STATUS_ERROR; |
| 21930 | 1626 } |
| 32911 | 1627 else { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1628 switch (ps_parsing) { |
| 32911 | 1629 case XML_SUSPENDED: |
| 1630 result = XML_STATUS_SUSPENDED; | |
| 1631 break; | |
| 1632 case XML_INITIALIZED: | |
| 1633 case XML_PARSING: | |
| 1634 if (isFinal) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1635 ps_parsing = XML_FINISHED; |
| 32911 | 1636 return result; |
| 1637 } | |
| 1638 default: ; /* should not happen */ | |
| 1639 } | |
| 1640 } | |
| 1641 | |
| 1642 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1643 positionPtr = bufferPtr; | |
| 1644 return result; | |
| 21930 | 1645 } |
| 1646 | |
|
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
|
1647 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1648 XML_GetBuffer(XML_Parser parser, int len) |
| 21930 | 1649 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1650 switch (ps_parsing) { |
| 32911 | 1651 case XML_SUSPENDED: |
| 1652 errorCode = XML_ERROR_SUSPENDED; | |
| 1653 return NULL; | |
| 1654 case XML_FINISHED: | |
| 1655 errorCode = XML_ERROR_FINISHED; | |
| 1656 return NULL; | |
| 1657 default: ; | |
| 1658 } | |
| 1659 | |
| 21930 | 1660 if (len > bufferLim - bufferEnd) { |
| 1661 /* FIXME avoid integer overflow */ | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1662 int neededSize = len + (int)(bufferEnd - bufferPtr); |
| 21930 | 1663 #ifdef XML_CONTEXT_BYTES |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1664 int keep = (int)(bufferPtr - buffer); |
| 21930 | 1665 |
| 1666 if (keep > XML_CONTEXT_BYTES) | |
| 1667 keep = XML_CONTEXT_BYTES; | |
| 1668 neededSize += keep; | |
| 1669 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1670 if (neededSize <= bufferLim - buffer) { | |
| 1671 #ifdef XML_CONTEXT_BYTES | |
| 1672 if (keep < bufferPtr - buffer) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1673 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
|
1674 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
|
1675 bufferEnd -= offset; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1676 bufferPtr -= offset; |
| 21930 | 1677 } |
| 1678 #else | |
| 1679 memmove(buffer, bufferPtr, bufferEnd - bufferPtr); | |
| 1680 bufferEnd = buffer + (bufferEnd - bufferPtr); | |
| 1681 bufferPtr = buffer; | |
| 1682 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1683 } | |
| 1684 else { | |
| 1685 char *newBuf; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1686 int bufferSize = (int)(bufferLim - bufferPtr); |
| 21930 | 1687 if (bufferSize == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1688 bufferSize = INIT_BUFFER_SIZE; |
| 21930 | 1689 do { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1690 bufferSize *= 2; |
| 21930 | 1691 } while (bufferSize < neededSize); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1692 newBuf = (char *)MALLOC(bufferSize); |
| 21930 | 1693 if (newBuf == 0) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1694 errorCode = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1695 return NULL; |
| 21930 | 1696 } |
| 1697 bufferLim = newBuf + bufferSize; | |
| 1698 #ifdef XML_CONTEXT_BYTES | |
| 1699 if (bufferPtr) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1700 int keep = (int)(bufferPtr - buffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1701 if (keep > XML_CONTEXT_BYTES) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1702 keep = XML_CONTEXT_BYTES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1703 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
|
1704 FREE(buffer); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1705 buffer = newBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1706 bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1707 bufferPtr = buffer + keep; |
| 21930 | 1708 } |
| 1709 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1710 bufferEnd = newBuf + (bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1711 bufferPtr = buffer = newBuf; |
| 21930 | 1712 } |
| 1713 #else | |
| 1714 if (bufferPtr) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1715 memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1716 FREE(buffer); |
| 21930 | 1717 } |
| 1718 bufferEnd = newBuf + (bufferEnd - bufferPtr); | |
| 1719 bufferPtr = buffer = newBuf; | |
| 1720 #endif /* not defined XML_CONTEXT_BYTES */ | |
| 1721 } | |
| 1722 } | |
| 1723 return bufferEnd; | |
| 1724 } | |
| 1725 | |
| 32911 | 1726 enum XML_Status XMLCALL |
| 1727 XML_StopParser(XML_Parser parser, XML_Bool resumable) | |
| 1728 { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1729 switch (ps_parsing) { |
| 32911 | 1730 case XML_SUSPENDED: |
| 1731 if (resumable) { | |
| 1732 errorCode = XML_ERROR_SUSPENDED; | |
| 1733 return XML_STATUS_ERROR; | |
| 1734 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1735 ps_parsing = XML_FINISHED; |
| 32911 | 1736 break; |
| 1737 case XML_FINISHED: | |
| 1738 errorCode = XML_ERROR_FINISHED; | |
| 1739 return XML_STATUS_ERROR; | |
| 1740 default: | |
| 1741 if (resumable) { | |
| 1742 #ifdef XML_DTD | |
| 1743 if (isParamEntity) { | |
| 1744 errorCode = XML_ERROR_SUSPEND_PE; | |
| 1745 return XML_STATUS_ERROR; | |
| 1746 } | |
| 1747 #endif | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1748 ps_parsing = XML_SUSPENDED; |
| 32911 | 1749 } |
| 1750 else | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1751 ps_parsing = XML_FINISHED; |
| 32911 | 1752 } |
| 1753 return XML_STATUS_OK; | |
| 1754 } | |
| 1755 | |
| 1756 enum XML_Status XMLCALL | |
| 1757 XML_ResumeParser(XML_Parser parser) | |
| 1758 { | |
|
36223
cf69e3191218
Fix icc warnings: using wrong enum type
Neal Norwitz <nnorwitz@gmail.com>
parents:
32911
diff
changeset
|
1759 enum XML_Status result = XML_STATUS_OK; |
| 32911 | 1760 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1761 if (ps_parsing != XML_SUSPENDED) { |
| 32911 | 1762 errorCode = XML_ERROR_NOT_SUSPENDED; |
| 1763 return XML_STATUS_ERROR; | |
| 1764 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1765 ps_parsing = XML_PARSING; |
| 32911 | 1766 |
| 1767 errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | |
| 1768 | |
| 1769 if (errorCode != XML_ERROR_NONE) { | |
| 1770 eventEndPtr = eventPtr; | |
| 1771 processor = errorProcessor; | |
| 1772 return XML_STATUS_ERROR; | |
| 1773 } | |
| 1774 else { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1775 switch (ps_parsing) { |
| 32911 | 1776 case XML_SUSPENDED: |
| 1777 result = XML_STATUS_SUSPENDED; | |
| 1778 break; | |
| 1779 case XML_INITIALIZED: | |
| 1780 case XML_PARSING: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1781 if (ps_finalBuffer) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1782 ps_parsing = XML_FINISHED; |
| 32911 | 1783 return result; |
| 1784 } | |
| 1785 default: ; | |
| 1786 } | |
| 1787 } | |
| 1788 | |
| 1789 XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | |
| 1790 positionPtr = bufferPtr; | |
| 1791 return result; | |
| 1792 } | |
| 1793 | |
| 1794 void XMLCALL | |
| 1795 XML_GetParsingStatus(XML_Parser parser, XML_ParsingStatus *status) | |
| 1796 { | |
| 1797 assert(status != NULL); | |
| 1798 *status = parser->m_parsingStatus; | |
| 1799 } | |
| 1800 | |
|
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
|
1801 enum XML_Error XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1802 XML_GetErrorCode(XML_Parser parser) |
| 21930 | 1803 { |
| 1804 return errorCode; | |
| 1805 } | |
| 1806 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1807 XML_Index XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1808 XML_GetCurrentByteIndex(XML_Parser parser) |
| 21930 | 1809 { |
| 1810 if (eventPtr) | |
| 1811 return parseEndByteIndex - (parseEndPtr - eventPtr); | |
| 1812 return -1; | |
| 1813 } | |
| 1814 | |
|
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
|
1815 int XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1816 XML_GetCurrentByteCount(XML_Parser parser) |
| 21930 | 1817 { |
| 1818 if (eventEndPtr && eventPtr) | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1819 return (int)(eventEndPtr - eventPtr); |
| 21930 | 1820 return 0; |
| 1821 } | |
| 1822 | |
|
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
|
1823 const char * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1824 XML_GetInputContext(XML_Parser parser, int *offset, int *size) |
| 21930 | 1825 { |
| 1826 #ifdef XML_CONTEXT_BYTES | |
| 1827 if (eventPtr && buffer) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1828 *offset = (int)(eventPtr - buffer); |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1829 *size = (int)(bufferEnd - buffer); |
| 21930 | 1830 return buffer; |
| 1831 } | |
| 1832 #endif /* defined XML_CONTEXT_BYTES */ | |
| 1833 return (char *) 0; | |
| 1834 } | |
| 1835 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1836 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1837 XML_GetCurrentLineNumber(XML_Parser parser) |
| 21930 | 1838 { |
| 32911 | 1839 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1840 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1841 positionPtr = eventPtr; | |
| 1842 } | |
| 1843 return position.lineNumber + 1; | |
| 1844 } | |
| 1845 | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1846 XML_Size XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1847 XML_GetCurrentColumnNumber(XML_Parser parser) |
| 21930 | 1848 { |
| 32911 | 1849 if (eventPtr && eventPtr >= positionPtr) { |
| 21930 | 1850 XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); |
| 1851 positionPtr = eventPtr; | |
| 1852 } | |
| 1853 return position.columnNumber; | |
| 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 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1857 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
|
1858 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1859 FREE(model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1860 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1861 |
|
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
|
1862 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1863 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
|
1864 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1865 return MALLOC(size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1866 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1867 |
|
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
|
1868 void * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1869 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
|
1870 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1871 return REALLOC(ptr, size); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1872 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1873 |
|
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
|
1874 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1875 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
|
1876 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1877 FREE(ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1878 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1879 |
|
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
|
1880 void XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1881 XML_DefaultCurrent(XML_Parser parser) |
| 21930 | 1882 { |
| 1883 if (defaultHandler) { | |
| 1884 if (openInternalEntities) | |
| 1885 reportDefault(parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1886 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1887 openInternalEntities->internalEventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1888 openInternalEntities->internalEventEndPtr); |
| 21930 | 1889 else |
| 1890 reportDefault(parser, encoding, eventPtr, eventEndPtr); | |
| 1891 } | |
| 1892 } | |
| 1893 | |
|
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
|
1894 const XML_LChar * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1895 XML_ErrorString(enum XML_Error code) |
| 21930 | 1896 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1897 static const XML_LChar* const message[] = { |
| 21930 | 1898 0, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1899 XML_L("out of memory"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1900 XML_L("syntax error"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1901 XML_L("no element found"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1902 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
|
1903 XML_L("unclosed token"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1904 XML_L("partial character"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1905 XML_L("mismatched tag"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1906 XML_L("duplicate attribute"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1907 XML_L("junk after document element"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1908 XML_L("illegal parameter entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1909 XML_L("undefined entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1910 XML_L("recursive entity reference"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1911 XML_L("asynchronous entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1912 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
|
1913 XML_L("reference to binary entity"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1914 XML_L("reference to external entity in attribute"), |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1915 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
|
1916 XML_L("unknown encoding"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1917 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
|
1918 XML_L("unclosed CDATA section"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1919 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
|
1920 XML_L("document is not standalone"), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1921 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
|
1922 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
|
1923 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
|
1924 XML_L("cannot change setting once parsing has begun"), |
| 32911 | 1925 XML_L("unbound prefix"), |
| 1926 XML_L("must not undeclare prefix"), | |
| 1927 XML_L("incomplete markup in parameter entity"), | |
| 1928 XML_L("XML declaration not well-formed"), | |
| 1929 XML_L("text declaration not well-formed"), | |
| 1930 XML_L("illegal character(s) in public id"), | |
| 1931 XML_L("parser suspended"), | |
| 1932 XML_L("parser not suspended"), | |
| 1933 XML_L("parsing aborted"), | |
| 1934 XML_L("parsing finished"), | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1935 XML_L("cannot suspend in external parameter entity"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1936 XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1937 XML_L("reserved prefix (xmlns) must not be declared or undeclared"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1938 XML_L("prefix must not be bound to one of the reserved namespace names") |
| 21930 | 1939 }; |
| 1940 if (code > 0 && code < sizeof(message)/sizeof(message[0])) | |
| 1941 return message[code]; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1942 return NULL; |
| 21930 | 1943 } |
| 1944 | |
|
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
|
1945 const XML_LChar * XMLCALL |
| 21930 | 1946 XML_ExpatVersion(void) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1947 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1948 /* 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
|
1949 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
|
1950 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
|
1951 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
|
1952 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
|
1953 with the correct numerals. */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1954 /* ### 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
|
1955 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1956 #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
|
1957 #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
|
1958 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1959 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
|
1960 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1961 #undef V1 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1962 #undef V2 |
| 21930 | 1963 } |
| 1964 | |
|
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
|
1965 XML_Expat_Version XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1966 XML_ExpatVersionInfo(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1967 { |
| 21930 | 1968 XML_Expat_Version version; |
| 1969 | |
| 1970 version.major = XML_MAJOR_VERSION; | |
| 1971 version.minor = XML_MINOR_VERSION; | |
| 1972 version.micro = XML_MICRO_VERSION; | |
| 1973 | |
| 1974 return version; | |
| 1975 } | |
| 1976 | |
|
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
|
1977 const XML_Feature * XMLCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1978 XML_GetFeatureList(void) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1979 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1980 static const XML_Feature features[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1981 {XML_FEATURE_SIZEOF_XML_CHAR, XML_L("sizeof(XML_Char)"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1982 sizeof(XML_Char)}, |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1983 {XML_FEATURE_SIZEOF_XML_LCHAR, XML_L("sizeof(XML_LChar)"), |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
1984 sizeof(XML_LChar)}, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1985 #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
|
1986 {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
|
1987 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1988 #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
|
1989 {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
|
1990 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1991 #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
|
1992 {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
|
1993 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1994 #ifdef XML_CONTEXT_BYTES |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1995 {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
|
1996 XML_CONTEXT_BYTES}, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1997 #endif |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
1998 #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
|
1999 {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
|
2000 #endif |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2001 #ifdef XML_NS |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2002 {XML_FEATURE_NS, XML_L("XML_NS"), 0}, |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2003 #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
|
2004 {XML_FEATURE_END, NULL, 0} |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2005 }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2006 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2007 return features; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2008 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2009 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2010 /* 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
|
2011 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
|
2012 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
|
2013 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
|
2014 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2015 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2016 storeRawNames(XML_Parser parser) |
| 21930 | 2017 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2018 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2019 while (tag) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2020 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2021 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
|
2022 char *rawNameBuf = tag->buf + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2023 /* 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
|
2024 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
|
2025 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
|
2026 previous call to this function. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2027 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2028 if (tag->rawName == rawNameBuf) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2029 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2030 /* 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
|
2031 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
|
2032 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2033 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
|
2034 if (bufSize > tag->bufEnd - tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2035 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
|
2036 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2037 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2038 /* 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
|
2039 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
|
2040 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2041 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
|
2042 tag->name.str = (XML_Char *)temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2043 /* 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
|
2044 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
|
2045 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2046 if (tag->name.localPart) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2047 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
|
2048 (XML_Char *)tag->buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2049 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2050 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2051 rawNameBuf = temp + nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2052 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2053 memcpy(rawNameBuf, tag->rawName, tag->rawNameLength); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2054 tag->rawName = rawNameBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2055 tag = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2056 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2057 return XML_TRUE; |
| 21930 | 2058 } |
| 2059 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2060 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2061 contentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2062 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2063 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2064 const char **endPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2065 { |
| 32911 | 2066 enum XML_Error result = doContent(parser, 0, encoding, start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2067 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2068 if (result == XML_ERROR_NONE) { |
| 2069 if (!storeRawNames(parser)) | |
| 2070 return XML_ERROR_NO_MEMORY; | |
| 2071 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2072 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2073 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2074 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2075 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2076 externalEntityInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2077 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2078 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2079 const char **endPtr) |
| 21930 | 2080 { |
| 2081 enum XML_Error result = initializeEncoding(parser); | |
| 2082 if (result != XML_ERROR_NONE) | |
| 2083 return result; | |
| 2084 processor = externalEntityInitProcessor2; | |
| 2085 return externalEntityInitProcessor2(parser, start, end, endPtr); | |
| 2086 } | |
| 2087 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2088 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2089 externalEntityInitProcessor2(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2090 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2091 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2092 const char **endPtr) |
| 21930 | 2093 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2094 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 21930 | 2095 int tok = XmlContentTok(encoding, start, end, &next); |
| 2096 switch (tok) { | |
| 2097 case XML_TOK_BOM: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2098 /* 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
|
2099 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
|
2100 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
|
2101 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
|
2102 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2103 if (next == end && !ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2104 *endPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2105 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2106 } |
| 21930 | 2107 start = next; |
| 2108 break; | |
| 2109 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2110 if (!ps_finalBuffer) { |
| 21930 | 2111 *endPtr = start; |
| 2112 return XML_ERROR_NONE; | |
| 2113 } | |
| 2114 eventPtr = start; | |
| 2115 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2116 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2117 if (!ps_finalBuffer) { |
| 21930 | 2118 *endPtr = start; |
| 2119 return XML_ERROR_NONE; | |
| 2120 } | |
| 2121 eventPtr = start; | |
| 2122 return XML_ERROR_PARTIAL_CHAR; | |
| 2123 } | |
| 2124 processor = externalEntityInitProcessor3; | |
| 2125 return externalEntityInitProcessor3(parser, start, end, endPtr); | |
| 2126 } | |
| 2127 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2128 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2129 externalEntityInitProcessor3(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2130 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2131 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2132 const char **endPtr) |
| 21930 | 2133 { |
| 32911 | 2134 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2135 const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 32911 | 2136 eventPtr = start; |
| 2137 tok = XmlContentTok(encoding, start, end, &next); | |
| 2138 eventEndPtr = next; | |
| 2139 | |
| 21930 | 2140 switch (tok) { |
| 2141 case XML_TOK_XML_DECL: | |
| 2142 { | |
| 32911 | 2143 enum XML_Error result; |
| 2144 result = processXmlDecl(parser, 1, start, next); | |
| 21930 | 2145 if (result != XML_ERROR_NONE) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2146 return result; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2147 switch (ps_parsing) { |
| 32911 | 2148 case XML_SUSPENDED: |
| 2149 *endPtr = next; | |
| 2150 return XML_ERROR_NONE; | |
| 2151 case XML_FINISHED: | |
| 2152 return XML_ERROR_ABORTED; | |
| 2153 default: | |
| 2154 start = next; | |
| 2155 } | |
| 21930 | 2156 } |
| 2157 break; | |
| 2158 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2159 if (!ps_finalBuffer) { |
| 21930 | 2160 *endPtr = start; |
| 2161 return XML_ERROR_NONE; | |
| 2162 } | |
| 2163 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2164 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2165 if (!ps_finalBuffer) { |
| 21930 | 2166 *endPtr = start; |
| 2167 return XML_ERROR_NONE; | |
| 2168 } | |
| 2169 return XML_ERROR_PARTIAL_CHAR; | |
| 2170 } | |
| 2171 processor = externalEntityContentProcessor; | |
| 2172 tagLevel = 1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2173 return externalEntityContentProcessor(parser, start, end, endPtr); |
| 21930 | 2174 } |
| 2175 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2176 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2177 externalEntityContentProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2178 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2179 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2180 const char **endPtr) |
| 21930 | 2181 { |
| 32911 | 2182 enum XML_Error result = doContent(parser, 1, encoding, start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2183 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 2184 if (result == XML_ERROR_NONE) { |
| 2185 if (!storeRawNames(parser)) | |
| 2186 return XML_ERROR_NO_MEMORY; | |
| 2187 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2188 return result; |
| 21930 | 2189 } |
| 2190 | |
| 2191 static enum XML_Error | |
| 2192 doContent(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2193 int startTagLevel, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2194 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2195 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2196 const char *end, |
| 32911 | 2197 const char **nextPtr, |
| 2198 XML_Bool haveMore) | |
| 21930 | 2199 { |
| 32911 | 2200 /* save one level of indirection */ |
| 2201 DTD * const dtd = _dtd; | |
| 2202 | |
| 21930 | 2203 const char **eventPP; |
| 2204 const char **eventEndPP; | |
| 2205 if (enc == encoding) { | |
| 2206 eventPP = &eventPtr; | |
| 2207 eventEndPP = &eventEndPtr; | |
| 2208 } | |
| 2209 else { | |
| 2210 eventPP = &(openInternalEntities->internalEventPtr); | |
| 2211 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 2212 } | |
| 2213 *eventPP = s; | |
| 32911 | 2214 |
| 21930 | 2215 for (;;) { |
| 2216 const char *next = s; /* XmlContentTok doesn't always set the last arg */ | |
| 2217 int tok = XmlContentTok(enc, s, end, &next); | |
| 2218 *eventEndPP = next; | |
| 2219 switch (tok) { | |
| 2220 case XML_TOK_TRAILING_CR: | |
| 32911 | 2221 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2222 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2223 return XML_ERROR_NONE; |
| 21930 | 2224 } |
| 2225 *eventEndPP = end; | |
| 2226 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2227 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2228 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2229 } |
| 2230 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2231 reportDefault(parser, enc, s, end); |
| 32911 | 2232 /* We are at the end of the final buffer, should we check for |
| 2233 XML_SUSPENDED, XML_FINISHED? | |
| 2234 */ | |
| 21930 | 2235 if (startTagLevel == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2236 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2237 if (tagLevel != startTagLevel) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2238 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2239 *nextPtr = end; |
| 21930 | 2240 return XML_ERROR_NONE; |
| 2241 case XML_TOK_NONE: | |
| 32911 | 2242 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2243 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2244 return XML_ERROR_NONE; |
| 21930 | 2245 } |
| 2246 if (startTagLevel > 0) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2247 if (tagLevel != startTagLevel) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2248 return XML_ERROR_ASYNC_ENTITY; |
| 32911 | 2249 *nextPtr = s; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2250 return XML_ERROR_NONE; |
| 21930 | 2251 } |
| 2252 return XML_ERROR_NO_ELEMENTS; | |
| 2253 case XML_TOK_INVALID: | |
| 2254 *eventPP = next; | |
| 2255 return XML_ERROR_INVALID_TOKEN; | |
| 2256 case XML_TOK_PARTIAL: | |
| 32911 | 2257 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2258 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2259 return XML_ERROR_NONE; |
| 21930 | 2260 } |
| 2261 return XML_ERROR_UNCLOSED_TOKEN; | |
| 2262 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 2263 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2264 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2265 return XML_ERROR_NONE; |
| 21930 | 2266 } |
| 2267 return XML_ERROR_PARTIAL_CHAR; | |
| 2268 case XML_TOK_ENTITY_REF: | |
| 2269 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2270 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2271 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2272 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
|
2273 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2274 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2275 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2276 if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2277 characterDataHandler(handlerArg, &ch, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2278 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2279 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2280 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2281 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2282 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2283 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2284 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2285 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2286 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2287 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
|
2288 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2289 /* 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
|
2290 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
|
2291 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
|
2292 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2293 if (!dtd->hasParamEntityRefs || dtd->standalone) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2294 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2295 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2296 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2297 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
|
2298 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2299 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2300 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2301 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2302 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2303 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2304 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2305 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2306 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2307 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2308 if (entity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2309 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2310 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2311 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2312 if (!defaultExpandInternalEntities) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2313 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2314 skippedEntityHandler(handlerArg, entity->name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2315 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2316 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2317 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2318 } |
| 32911 | 2319 result = processInternalEntity(parser, entity, XML_FALSE); |
| 2320 if (result != XML_ERROR_NONE) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2321 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2322 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2323 else if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2324 const XML_Char *context; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2325 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2326 context = getContext(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2327 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2328 if (!context) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2329 return XML_ERROR_NO_MEMORY; |
| 32911 | 2330 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2331 context, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2332 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2333 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2334 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2335 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2336 poolDiscard(&tempPool); |
|
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 (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2339 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2340 break; |
| 21930 | 2341 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2342 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
|
2343 /* fall through */ |
| 21930 | 2344 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
|
2345 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2346 TAG *tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2347 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2348 XML_Char *toPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2349 if (freeTagList) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2350 tag = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2351 freeTagList = freeTagList->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2352 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2353 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2354 tag = (TAG *)MALLOC(sizeof(TAG)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2355 if (!tag) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2356 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2357 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
|
2358 if (!tag->buf) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2359 FREE(tag); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2360 return XML_ERROR_NO_MEMORY; |
|
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 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
|
2363 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2364 tag->bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2365 tag->parent = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2366 tagStack = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2367 tag->name.localPart = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2368 tag->name.prefix = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2369 tag->rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2370 tag->rawNameLength = XmlNameLength(enc, tag->rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2371 ++tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2372 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2373 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
|
2374 const char *fromPtr = tag->rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2375 toPtr = (XML_Char *)tag->buf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2376 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2377 int bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2378 int convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2379 XmlConvert(enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2380 &fromPtr, rawNameEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2381 (ICHAR **)&toPtr, (ICHAR *)tag->bufEnd - 1); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2382 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
|
2383 if (fromPtr == rawNameEnd) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2384 tag->name.strLen = convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2385 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2386 } |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2387 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
|
2388 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2389 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
|
2390 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2391 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2392 tag->buf = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2393 tag->bufEnd = temp + bufSize; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2394 toPtr = (XML_Char *)temp + convLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2395 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2396 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2397 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2398 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
|
2399 *toPtr = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2400 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
|
2401 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2402 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2403 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2404 startElementHandler(handlerArg, tag->name.str, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2405 (const XML_Char **)atts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2406 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2407 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2408 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2409 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2410 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2411 case XML_TOK_EMPTY_ELEMENT_NO_ATTS: |
| 21930 | 2412 /* fall through */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2413 case XML_TOK_EMPTY_ELEMENT_WITH_ATTS: |
| 21930 | 2414 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2415 const char *rawName = s + enc->minBytesPerChar; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2416 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2417 BINDING *bindings = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2418 XML_Bool noElmHandlers = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2419 TAG_NAME name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2420 name.str = poolStoreString(&tempPool, enc, rawName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2421 rawName + XmlNameLength(enc, rawName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2422 if (!name.str) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2423 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2424 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
|
2425 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
|
2426 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2427 return result; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2428 poolFinish(&tempPool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2429 if (startElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2430 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
|
2431 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2432 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2433 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2434 if (startElementHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2435 *eventPP = *eventEndPP; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2436 endElementHandler(handlerArg, name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2437 noElmHandlers = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2438 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2439 if (noElmHandlers && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2440 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2441 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2442 while (bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2443 BINDING *b = bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2444 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2445 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2446 bindings = bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2447 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2448 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2449 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2450 } |
| 21930 | 2451 } |
| 2452 if (tagLevel == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2453 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2454 break; |
| 2455 case XML_TOK_END_TAG: | |
| 2456 if (tagLevel == startTagLevel) | |
| 2457 return XML_ERROR_ASYNC_ENTITY; | |
| 2458 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2459 int len; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2460 const char *rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2461 TAG *tag = tagStack; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2462 tagStack = tag->parent; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2463 tag->parent = freeTagList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2464 freeTagList = tag; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2465 rawName = s + enc->minBytesPerChar*2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2466 len = XmlNameLength(enc, rawName); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2467 if (len != tag->rawNameLength |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2468 || memcmp(tag->rawName, rawName, len) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2469 *eventPP = rawName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2470 return XML_ERROR_TAG_MISMATCH; |
|
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 --tagLevel; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2473 if (endElementHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2474 const XML_Char *localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2475 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2476 XML_Char *uri; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2477 localPart = tag->name.localPart; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2478 if (ns && localPart) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2479 /* 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
|
2480 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
|
2481 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
|
2482 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2483 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
|
2484 /* 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
|
2485 while (*localPart) *uri++ = *localPart++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2486 prefix = (XML_Char *)tag->name.prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2487 if (ns_triplets && prefix) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2488 *uri++ = namespaceSeparator; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2489 while (*prefix) *uri++ = *prefix++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2490 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2491 *uri = XML_T('\0'); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2492 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2493 endElementHandler(handlerArg, tag->name.str); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2494 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2495 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2496 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2497 while (tag->bindings) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2498 BINDING *b = tag->bindings; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2499 if (endNamespaceDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2500 endNamespaceDeclHandler(handlerArg, b->prefix->name); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2501 tag->bindings = tag->bindings->nextTagBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2502 b->nextTagBinding = freeBindingList; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2503 freeBindingList = b; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2504 b->prefix->binding = b->prevPrefixBinding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2505 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2506 if (tagLevel == 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2507 return epilogProcessor(parser, next, end, nextPtr); |
| 21930 | 2508 } |
| 2509 break; | |
| 2510 case XML_TOK_CHAR_REF: | |
| 2511 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2512 int n = XmlCharRefNumber(enc, s); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2513 if (n < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2514 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2515 if (characterDataHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2516 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2517 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
|
2518 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2519 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2520 reportDefault(parser, enc, s, next); |
| 21930 | 2521 } |
| 2522 break; | |
| 2523 case XML_TOK_XML_DECL: | |
| 2524 return XML_ERROR_MISPLACED_XML_PI; | |
| 2525 case XML_TOK_DATA_NEWLINE: | |
| 2526 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2527 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2528 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 2529 } |
| 2530 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2531 reportDefault(parser, enc, s, next); |
| 21930 | 2532 break; |
| 2533 case XML_TOK_CDATA_SECT_OPEN: | |
| 2534 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2535 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2536 if (startCdataSectionHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2537 startCdataSectionHandler(handlerArg); |
| 21930 | 2538 #if 0 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2539 /* 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
|
2540 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
|
2541 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
|
2542 characters through. The characterDataHandler does the |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2543 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
|
2544 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
|
2545 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
|
2546 be incorrectly escaped). |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2547 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2548 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
|
2549 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
|
2550 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2551 else if (characterDataHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2552 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 2553 #endif |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2554 else if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2555 reportDefault(parser, enc, s, next); |
| 32911 | 2556 result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); |
| 2557 if (result != XML_ERROR_NONE) | |
| 2558 return result; | |
| 2559 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2560 processor = cdataSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2561 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2562 } |
| 21930 | 2563 } |
| 2564 break; | |
| 2565 case XML_TOK_TRAILING_RSQB: | |
| 32911 | 2566 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2567 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2568 return XML_ERROR_NONE; |
| 21930 | 2569 } |
| 2570 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2571 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2572 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2573 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
|
2574 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2575 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2576 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2577 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2578 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2579 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2580 (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 2581 } |
| 2582 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2583 reportDefault(parser, enc, s, end); |
| 32911 | 2584 /* We are at the end of the final buffer, should we check for |
| 2585 XML_SUSPENDED, XML_FINISHED? | |
| 2586 */ | |
| 21930 | 2587 if (startTagLevel == 0) { |
| 2588 *eventPP = end; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2589 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 2590 } |
| 2591 if (tagLevel != startTagLevel) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2592 *eventPP = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2593 return XML_ERROR_ASYNC_ENTITY; |
| 21930 | 2594 } |
| 32911 | 2595 *nextPtr = end; |
| 21930 | 2596 return XML_ERROR_NONE; |
| 2597 case XML_TOK_DATA_CHARS: | |
| 2598 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2599 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2600 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2601 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2602 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2603 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2604 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2605 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2606 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2607 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2608 *eventPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2609 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2610 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2611 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2612 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2613 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2614 (int)((XML_Char *)next - (XML_Char *)s)); |
| 21930 | 2615 } |
| 2616 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2617 reportDefault(parser, enc, s, next); |
| 21930 | 2618 break; |
| 2619 case XML_TOK_PI: | |
| 2620 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
|
2621 return XML_ERROR_NO_MEMORY; |
| 21930 | 2622 break; |
| 2623 case XML_TOK_COMMENT: | |
| 2624 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
|
2625 return XML_ERROR_NO_MEMORY; |
| 21930 | 2626 break; |
| 2627 default: | |
| 2628 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2629 reportDefault(parser, enc, s, next); |
| 21930 | 2630 break; |
| 2631 } | |
| 2632 *eventPP = s = next; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2633 switch (ps_parsing) { |
| 32911 | 2634 case XML_SUSPENDED: |
| 2635 *nextPtr = next; | |
| 2636 return XML_ERROR_NONE; | |
| 2637 case XML_FINISHED: | |
| 2638 return XML_ERROR_ABORTED; | |
| 2639 default: ; | |
| 2640 } | |
| 21930 | 2641 } |
| 2642 /* not reached */ | |
| 2643 } | |
| 2644 | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2645 /* 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
|
2646 Purpose: |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2647 - normalize attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2648 - 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
|
2649 - 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
|
2650 - 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
|
2651 - default attributes |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2652 - 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
|
2653 - 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
|
2654 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2655 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2656 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
|
2657 const char *attStr, TAG_NAME *tagNamePtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2658 BINDING **bindingsPtr) |
| 21930 | 2659 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2660 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
|
2661 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
|
2662 int nDefaultAtts; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2663 const XML_Char **appAtts; /* the attribute list for the application */ |
| 21930 | 2664 int attIndex = 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2665 int prefixLen; |
| 21930 | 2666 int i; |
| 2667 int n; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2668 XML_Char *uri; |
| 21930 | 2669 int nPrefixes = 0; |
| 2670 BINDING *binding; | |
| 2671 const XML_Char *localPart; | |
| 2672 | |
| 2673 /* lookup the element type name */ | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2674 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
|
2675 if (!elementType) { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2676 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
|
2677 if (!name) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2678 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2679 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
|
2680 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
|
2681 if (!elementType) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2682 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
|
2683 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
|
2684 return XML_ERROR_NO_MEMORY; |
| 21930 | 2685 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2686 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
|
2687 |
| 21930 | 2688 /* get the attributes from the tokenizer */ |
| 2689 n = XmlGetAttributes(enc, attStr, attsSize, atts); | |
| 2690 if (n + nDefaultAtts > attsSize) { | |
| 2691 int oldAttsSize = attsSize; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2692 ATTRIBUTE *temp; |
| 21930 | 2693 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
|
2694 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
|
2695 if (temp == NULL) |
| 21930 | 2696 return XML_ERROR_NO_MEMORY; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2697 atts = temp; |
| 21930 | 2698 if (n > oldAttsSize) |
| 2699 XmlGetAttributes(enc, attStr, n, atts); | |
| 2700 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2701 |
| 21930 | 2702 appAtts = (const XML_Char **)atts; |
| 2703 for (i = 0; i < n; i++) { | |
| 2704 /* add the name and value to the attribute list */ | |
| 2705 ATTRIBUTE_ID *attId = getAttributeId(parser, enc, atts[i].name, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2706 atts[i].name |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2707 + XmlNameLength(enc, atts[i].name)); |
| 21930 | 2708 if (!attId) |
| 2709 return XML_ERROR_NO_MEMORY; | |
|
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
|
2710 /* 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
|
2711 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
|
2712 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
|
2713 */ |
| 21930 | 2714 if ((attId->name)[-1]) { |
| 2715 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2716 eventPtr = atts[i].name; |
| 21930 | 2717 return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 2718 } | |
| 2719 (attId->name)[-1] = 1; | |
| 2720 appAtts[attIndex++] = attId->name; | |
| 2721 if (!atts[i].normalized) { | |
| 2722 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2723 XML_Bool isCdata = XML_TRUE; |
| 21930 | 2724 |
| 2725 /* figure out whether declared as other than CDATA */ | |
| 2726 if (attId->maybeTokenized) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2727 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2728 for (j = 0; j < nDefaultAtts; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2729 if (attId == elementType->defaultAtts[j].id) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2730 isCdata = elementType->defaultAtts[j].isCdata; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2731 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2732 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2733 } |
| 21930 | 2734 } |
| 2735 | |
| 2736 /* normalize the attribute value */ | |
| 2737 result = storeAttributeValue(parser, enc, isCdata, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2738 atts[i].valuePtr, atts[i].valueEnd, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2739 &tempPool); |
| 21930 | 2740 if (result) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2741 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
|
2742 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
|
2743 poolFinish(&tempPool); |
| 21930 | 2744 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2745 else { |
| 21930 | 2746 /* 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
|
2747 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
|
2748 atts[i].valueEnd); |
| 21930 | 2749 if (appAtts[attIndex] == 0) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2750 return XML_ERROR_NO_MEMORY; |
| 21930 | 2751 poolFinish(&tempPool); |
| 2752 } | |
| 2753 /* 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
|
2754 if (attId->prefix) { |
| 21930 | 2755 if (attId->xmlns) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2756 /* deal with namespace declarations here */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2757 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
|
2758 appAtts[attIndex], bindingsPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2759 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2760 return result; |
| 21930 | 2761 --attIndex; |
| 2762 } | |
| 2763 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2764 /* deal with other prefixed names later */ |
| 21930 | 2765 attIndex++; |
| 2766 nPrefixes++; | |
| 2767 (attId->name)[-1] = 2; | |
| 2768 } | |
| 2769 } | |
| 2770 else | |
| 2771 attIndex++; | |
| 2772 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2773 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2774 /* 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
|
2775 nSpecifiedAtts = attIndex; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2776 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
|
2777 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
|
2778 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
|
2779 idAttIndex = i; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2780 break; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2781 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2782 } |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2783 else |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2784 idAttIndex = -1; |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2785 |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2786 /* 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
|
2787 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
|
2788 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
|
2789 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
|
2790 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
|
2791 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
|
2792 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
|
2793 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
|
2794 if (result) |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2795 return result; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2796 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2797 else { |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2798 (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
|
2799 nPrefixes++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2800 appAtts[attIndex++] = da->id->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2801 appAtts[attIndex++] = da->value; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2802 } |
| 21930 | 2803 } |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2804 else { |
|
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2805 (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
|
2806 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
|
2807 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
|
2808 } |
| 21930 | 2809 } |
| 2810 } | |
|
27466
764df2fdc9c6
Update to the final version released as Expat 1.95.6 (maintaining
Fred Drake <fdrake@acm.org>
parents:
27391
diff
changeset
|
2811 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
|
2812 |
|
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
|
2813 /* 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
|
2814 and clear flags that say whether attributes were specified */ |
| 21930 | 2815 i = 0; |
| 2816 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
|
2817 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
|
2818 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
|
2819 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
|
2820 /* 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
|
2821 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
|
2822 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
|
2823 /* 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
|
2824 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
|
2825 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
|
2826 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
|
2827 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
|
2828 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
|
2829 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
|
2830 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
|
2831 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
|
2832 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
|
2833 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2834 /* 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
|
2835 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
|
2836 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
|
2837 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
|
2838 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
|
2839 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2840 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
|
2841 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2842 /* expand prefixed names and check for duplicates */ |
| 21930 | 2843 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
|
2844 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
|
2845 if (s[-1] == 2) { /* prefixed */ |
| 21930 | 2846 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
|
2847 const BINDING *b; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2848 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
|
2849 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2850 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); |
|
39473
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
2851 if (!id) |
|
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
2852 return XML_ERROR_NO_MEMORY; |
|
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
|
2853 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
|
2854 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
|
2855 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
|
2856 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2857 /* 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
|
2858 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
|
2859 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
|
2860 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
|
2861 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
|
2862 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
|
2863 } |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2864 while (*s++ != XML_T(':')) |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2865 ; |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2866 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
|
2867 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
|
2868 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
|
2869 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
|
2870 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
|
2871 } 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
|
2872 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2873 { /* Check hash table for duplicate of expanded name (uriName). |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
2874 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
|
2875 */ |
|
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 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
|
2877 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
|
2878 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
|
2879 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
|
2880 /* 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
|
2881 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
|
2882 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
|
2883 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
|
2884 /* 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
|
2885 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
|
2886 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
|
2887 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
|
2888 } |
|
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 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
|
2890 step = PROBE_STEP(uriHash, mask, nsAttsPower); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2891 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
|
2892 } |
|
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
|
2893 } |
|
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 |
|
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 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
|
2896 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
|
2897 s = b->prefix->name; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2898 do { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2899 if (!poolAppendChar(&tempPool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2900 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2901 } while (*s++); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2902 } |
|
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
|
2903 |
|
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 /* 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
|
2905 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
|
2906 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
|
2907 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
|
2908 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
2909 /* 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
|
2910 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
|
2911 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
|
2912 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
|
2913 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2914 if (!--nPrefixes) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2915 i += 2; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2916 break; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2917 } |
| 21930 | 2918 } |
|
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
|
2919 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
|
2920 ((XML_Char *)s)[-1] = 0; /* clear flag */ |
| 21930 | 2921 } |
| 2922 } | |
|
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
|
2923 /* clear flags for the remaining attributes */ |
| 21930 | 2924 for (; i < attIndex; i += 2) |
| 2925 ((XML_Char *)(appAtts[i]))[-1] = 0; | |
| 2926 for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) | |
| 2927 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
|
2928 |
|
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
|
2929 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
|
2930 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
|
2931 |
| 21930 | 2932 /* expand the element type name */ |
| 2933 if (elementType->prefix) { | |
| 2934 binding = elementType->prefix->binding; | |
| 2935 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
|
2936 return XML_ERROR_UNBOUND_PREFIX; |
| 21930 | 2937 localPart = tagNamePtr->str; |
| 2938 while (*localPart++ != XML_T(':')) | |
| 2939 ; | |
| 2940 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2941 else if (dtd->defaultPrefix.binding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2942 binding = dtd->defaultPrefix.binding; |
| 21930 | 2943 localPart = tagNamePtr->str; |
| 2944 } | |
| 2945 else | |
| 2946 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2947 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
|
2948 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
|
2949 for (; binding->prefix->name[prefixLen++];) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2950 ; /* prefixLen includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2951 } |
| 21930 | 2952 tagNamePtr->localPart = localPart; |
| 2953 tagNamePtr->uriLen = binding->uriLen; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2954 tagNamePtr->prefix = binding->prefix->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2955 tagNamePtr->prefixLen = prefixLen; |
| 21930 | 2956 for (i = 0; localPart[i++];) |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2957 ; /* i includes null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2958 n = i + binding->uriLen + prefixLen; |
| 21930 | 2959 if (n > binding->uriAlloc) { |
| 2960 TAG *p; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2961 uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); |
| 21930 | 2962 if (!uri) |
| 2963 return XML_ERROR_NO_MEMORY; | |
| 2964 binding->uriAlloc = n + EXPAND_SPARE; | |
| 2965 memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); | |
| 2966 for (p = tagStack; p; p = p->parent) | |
| 2967 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
|
2968 p->name.str = uri; |
| 21930 | 2969 FREE(binding->uri); |
| 2970 binding->uri = uri; | |
| 2971 } | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2972 /* 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
|
2973 uri = binding->uri + binding->uriLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2974 memcpy(uri, localPart, i * sizeof(XML_Char)); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2975 /* 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
|
2976 if (prefixLen) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2977 uri += i - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2978 *uri = namespaceSeparator; /* replace null terminator */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2979 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
|
2980 } |
| 21930 | 2981 tagNamePtr->str = binding->uri; |
| 2982 return XML_ERROR_NONE; | |
| 2983 } | |
| 2984 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2985 /* 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
|
2986 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
|
2987 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2988 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
2989 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
|
2990 const XML_Char *uri, BINDING **bindingsPtr) |
| 21930 | 2991 { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2992 static const XML_Char xmlNamespace[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2993 'h', 't', 't', 'p', ':', '/', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2994 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2995 'X', 'M', 'L', '/', '1', '9', '9', '8', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2996 'n', 'a', 'm', 'e', 's', 'p', 'a', 'c', 'e', '\0' |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2997 }; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2998 static const int xmlLen = |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
2999 (int)sizeof(xmlNamespace)/sizeof(XML_Char) - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3000 static const XML_Char xmlnsNamespace[] = { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3001 'h', 't', 't', 'p', ':', '/', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3002 'w', 'w', 'w', '.', 'w', '3', '.', 'o', 'r', 'g', '/', |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3003 '2', '0', '0', '0', '/', 'x', 'm', 'l', 'n', 's', '/', '\0' |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3004 }; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3005 static const int xmlnsLen = |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3006 (int)sizeof(xmlnsNamespace)/sizeof(XML_Char) - 1; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3007 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3008 XML_Bool mustBeXML = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3009 XML_Bool isXML = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3010 XML_Bool isXMLNS = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3011 |
| 21930 | 3012 BINDING *b; |
| 3013 int len; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3014 |
| 32911 | 3015 /* 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
|
3016 if (*uri == XML_T('\0') && prefix->name) |
| 32911 | 3017 return XML_ERROR_UNDECLARING_PREFIX; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3018 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3019 if (prefix->name |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3020 && prefix->name[0] == XML_T('x') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3021 && prefix->name[1] == XML_T('m') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3022 && prefix->name[2] == XML_T('l')) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3023 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3024 /* Not allowed to bind xmlns */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3025 if (prefix->name[3] == XML_T('n') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3026 && prefix->name[4] == XML_T('s') |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3027 && prefix->name[5] == XML_T('\0')) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3028 return XML_ERROR_RESERVED_PREFIX_XMLNS; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3029 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3030 if (prefix->name[3] == XML_T('\0')) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3031 mustBeXML = XML_TRUE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3032 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3033 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3034 for (len = 0; uri[len]; len++) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3035 if (isXML && (len > xmlLen || uri[len] != xmlNamespace[len])) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3036 isXML = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3037 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3038 if (!mustBeXML && isXMLNS |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3039 && (len > xmlnsLen || uri[len] != xmlnsNamespace[len])) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3040 isXMLNS = XML_FALSE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3041 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3042 isXML = isXML && len == xmlLen; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3043 isXMLNS = isXMLNS && len == xmlnsLen; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3044 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3045 if (mustBeXML != isXML) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3046 return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3047 : XML_ERROR_RESERVED_NAMESPACE_URI; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3048 |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3049 if (isXMLNS) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3050 return XML_ERROR_RESERVED_NAMESPACE_URI; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3051 |
| 21930 | 3052 if (namespaceSeparator) |
| 3053 len++; | |
| 3054 if (freeBindingList) { | |
| 3055 b = freeBindingList; | |
| 3056 if (len > b->uriAlloc) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3057 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
|
3058 sizeof(XML_Char) * (len + EXPAND_SPARE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3059 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3060 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3061 b->uri = temp; |
| 21930 | 3062 b->uriAlloc = len + EXPAND_SPARE; |
| 3063 } | |
| 3064 freeBindingList = b->nextTagBinding; | |
| 3065 } | |
| 3066 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3067 b = (BINDING *)MALLOC(sizeof(BINDING)); |
| 21930 | 3068 if (!b) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3069 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3070 b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 21930 | 3071 if (!b->uri) { |
| 3072 FREE(b); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3073 return XML_ERROR_NO_MEMORY; |
| 21930 | 3074 } |
| 3075 b->uriAlloc = len + EXPAND_SPARE; | |
| 3076 } | |
| 3077 b->uriLen = len; | |
| 3078 memcpy(b->uri, uri, len * sizeof(XML_Char)); | |
| 3079 if (namespaceSeparator) | |
| 3080 b->uri[len - 1] = namespaceSeparator; | |
| 3081 b->prefix = prefix; | |
| 3082 b->attId = attId; | |
| 3083 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
|
3084 /* 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
|
3085 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
|
3086 prefix->binding = NULL; |
| 21930 | 3087 else |
| 3088 prefix->binding = b; | |
| 3089 b->nextTagBinding = *bindingsPtr; | |
| 3090 *bindingsPtr = b; | |
| 32911 | 3091 /* if attId == NULL then we are not starting a namespace scope */ |
| 3092 if (attId && startNamespaceDeclHandler) | |
| 21930 | 3093 startNamespaceDeclHandler(handlerArg, prefix->name, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3094 prefix->binding ? uri : 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3095 return XML_ERROR_NONE; |
| 21930 | 3096 } |
| 3097 | |
| 3098 /* 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
|
3099 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
|
3100 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3101 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3102 cdataSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3103 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3104 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3105 const char **endPtr) |
| 21930 | 3106 { |
| 32911 | 3107 enum XML_Error result = doCdataSection(parser, encoding, &start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3108 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3109 if (result != XML_ERROR_NONE) |
| 3110 return result; | |
| 21930 | 3111 if (start) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3112 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
|
3113 processor = externalEntityContentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3114 return externalEntityContentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3115 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3116 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3117 processor = contentProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3118 return contentProcessor(parser, start, end, endPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3119 } |
| 21930 | 3120 } |
| 3121 return result; | |
| 3122 } | |
| 3123 | |
| 32911 | 3124 /* 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
|
3125 the section is not yet closed. |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3126 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3127 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3128 doCdataSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3129 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3130 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3131 const char *end, |
| 32911 | 3132 const char **nextPtr, |
| 3133 XML_Bool haveMore) | |
| 21930 | 3134 { |
| 3135 const char *s = *startPtr; | |
| 3136 const char **eventPP; | |
| 3137 const char **eventEndPP; | |
| 3138 if (enc == encoding) { | |
| 3139 eventPP = &eventPtr; | |
| 3140 *eventPP = s; | |
| 3141 eventEndPP = &eventEndPtr; | |
| 3142 } | |
| 3143 else { | |
| 3144 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3145 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3146 } | |
| 3147 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3148 *startPtr = NULL; |
| 32911 | 3149 |
| 21930 | 3150 for (;;) { |
| 3151 const char *next; | |
| 3152 int tok = XmlCdataSectionTok(enc, s, end, &next); | |
| 3153 *eventEndPP = next; | |
| 3154 switch (tok) { | |
| 3155 case XML_TOK_CDATA_SECT_CLOSE: | |
| 3156 if (endCdataSectionHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3157 endCdataSectionHandler(handlerArg); |
| 21930 | 3158 #if 0 |
| 3159 /* see comment under XML_TOK_CDATA_SECT_OPEN */ | |
| 3160 else if (characterDataHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3161 characterDataHandler(handlerArg, dataBuf, 0); |
| 21930 | 3162 #endif |
| 3163 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3164 reportDefault(parser, enc, s, next); |
| 21930 | 3165 *startPtr = next; |
| 32911 | 3166 *nextPtr = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3167 if (ps_parsing == XML_FINISHED) |
| 32911 | 3168 return XML_ERROR_ABORTED; |
| 3169 else | |
| 3170 return XML_ERROR_NONE; | |
| 21930 | 3171 case XML_TOK_DATA_NEWLINE: |
| 3172 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3173 XML_Char c = 0xA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3174 characterDataHandler(handlerArg, &c, 1); |
| 21930 | 3175 } |
| 3176 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3177 reportDefault(parser, enc, s, next); |
| 21930 | 3178 break; |
| 3179 case XML_TOK_DATA_CHARS: | |
| 3180 if (characterDataHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3181 if (MUST_CONVERT(enc, s)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3182 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3183 ICHAR *dataPtr = (ICHAR *)dataBuf; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3184 XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3185 *eventEndPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3186 characterDataHandler(handlerArg, dataBuf, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3187 (int)(dataPtr - (ICHAR *)dataBuf)); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3188 if (s == next) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3189 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3190 *eventPP = s; |
|
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 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3193 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3194 characterDataHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3195 (XML_Char *)s, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3196 (int)((XML_Char *)next - (XML_Char *)s)); |
| 21930 | 3197 } |
| 3198 else if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3199 reportDefault(parser, enc, s, next); |
| 21930 | 3200 break; |
| 3201 case XML_TOK_INVALID: | |
| 3202 *eventPP = next; | |
| 3203 return XML_ERROR_INVALID_TOKEN; | |
| 3204 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3205 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3206 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3207 return XML_ERROR_NONE; |
| 21930 | 3208 } |
| 3209 return XML_ERROR_PARTIAL_CHAR; | |
| 3210 case XML_TOK_PARTIAL: | |
| 3211 case XML_TOK_NONE: | |
| 32911 | 3212 if (haveMore) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3213 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3214 return XML_ERROR_NONE; |
| 21930 | 3215 } |
| 3216 return XML_ERROR_UNCLOSED_CDATA_SECTION; | |
| 3217 default: | |
| 3218 *eventPP = next; | |
| 3219 return XML_ERROR_UNEXPECTED_STATE; | |
| 3220 } | |
| 32911 | 3221 |
| 21930 | 3222 *eventPP = s = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3223 switch (ps_parsing) { |
| 32911 | 3224 case XML_SUSPENDED: |
| 3225 *nextPtr = next; | |
| 3226 return XML_ERROR_NONE; | |
| 3227 case XML_FINISHED: | |
| 3228 return XML_ERROR_ABORTED; | |
| 3229 default: ; | |
| 3230 } | |
| 21930 | 3231 } |
| 3232 /* not reached */ | |
| 3233 } | |
| 3234 | |
| 3235 #ifdef XML_DTD | |
| 3236 | |
| 3237 /* 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
|
3238 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
|
3239 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3240 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3241 ignoreSectionProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3242 const char *start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3243 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3244 const char **endPtr) |
| 21930 | 3245 { |
| 32911 | 3246 enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3247 endPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 3248 if (result != XML_ERROR_NONE) |
| 3249 return result; | |
| 21930 | 3250 if (start) { |
| 3251 processor = prologProcessor; | |
| 3252 return prologProcessor(parser, start, end, endPtr); | |
| 3253 } | |
| 3254 return result; | |
| 3255 } | |
| 3256 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3257 /* 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
|
3258 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
|
3259 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3260 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3261 doIgnoreSection(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3262 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3263 const char **startPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3264 const char *end, |
| 32911 | 3265 const char **nextPtr, |
| 3266 XML_Bool haveMore) | |
| 21930 | 3267 { |
| 3268 const char *next; | |
| 3269 int tok; | |
| 3270 const char *s = *startPtr; | |
| 3271 const char **eventPP; | |
| 3272 const char **eventEndPP; | |
| 3273 if (enc == encoding) { | |
| 3274 eventPP = &eventPtr; | |
| 3275 *eventPP = s; | |
| 3276 eventEndPP = &eventEndPtr; | |
| 3277 } | |
| 3278 else { | |
| 3279 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3280 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3281 } | |
| 3282 *eventPP = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3283 *startPtr = NULL; |
| 21930 | 3284 tok = XmlIgnoreSectionTok(enc, s, end, &next); |
| 3285 *eventEndPP = next; | |
| 3286 switch (tok) { | |
| 3287 case XML_TOK_IGNORE_SECT: | |
| 3288 if (defaultHandler) | |
| 3289 reportDefault(parser, enc, s, next); | |
| 3290 *startPtr = next; | |
| 32911 | 3291 *nextPtr = next; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3292 if (ps_parsing == XML_FINISHED) |
| 32911 | 3293 return XML_ERROR_ABORTED; |
| 3294 else | |
| 3295 return XML_ERROR_NONE; | |
| 21930 | 3296 case XML_TOK_INVALID: |
| 3297 *eventPP = next; | |
| 3298 return XML_ERROR_INVALID_TOKEN; | |
| 3299 case XML_TOK_PARTIAL_CHAR: | |
| 32911 | 3300 if (haveMore) { |
| 21930 | 3301 *nextPtr = s; |
| 3302 return XML_ERROR_NONE; | |
| 3303 } | |
| 3304 return XML_ERROR_PARTIAL_CHAR; | |
| 3305 case XML_TOK_PARTIAL: | |
| 3306 case XML_TOK_NONE: | |
| 32911 | 3307 if (haveMore) { |
| 21930 | 3308 *nextPtr = s; |
| 3309 return XML_ERROR_NONE; | |
| 3310 } | |
| 3311 return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ | |
| 3312 default: | |
| 3313 *eventPP = next; | |
| 3314 return XML_ERROR_UNEXPECTED_STATE; | |
| 3315 } | |
| 3316 /* not reached */ | |
| 3317 } | |
| 3318 | |
| 3319 #endif /* XML_DTD */ | |
| 3320 | |
| 3321 static enum XML_Error | |
| 3322 initializeEncoding(XML_Parser parser) | |
| 3323 { | |
| 3324 const char *s; | |
| 3325 #ifdef XML_UNICODE | |
| 3326 char encodingBuf[128]; | |
| 3327 if (!protocolEncodingName) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3328 s = NULL; |
| 21930 | 3329 else { |
| 3330 int i; | |
| 3331 for (i = 0; protocolEncodingName[i]; i++) { | |
| 3332 if (i == sizeof(encodingBuf) - 1 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3333 || (protocolEncodingName[i] & ~0x7f) != 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3334 encodingBuf[0] = '\0'; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3335 break; |
| 21930 | 3336 } |
| 3337 encodingBuf[i] = (char)protocolEncodingName[i]; | |
| 3338 } | |
| 3339 encodingBuf[i] = '\0'; | |
| 3340 s = encodingBuf; | |
| 3341 } | |
| 3342 #else | |
| 3343 s = protocolEncodingName; | |
| 3344 #endif | |
| 3345 if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) | |
| 3346 return XML_ERROR_NONE; | |
| 3347 return handleUnknownEncoding(parser, protocolEncodingName); | |
| 3348 } | |
| 3349 | |
| 3350 static enum XML_Error | |
| 3351 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
|
3352 const char *s, const char *next) |
| 21930 | 3353 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3354 const char *encodingName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3355 const XML_Char *storedEncName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3356 const ENCODING *newEncoding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3357 const char *version = NULL; |
| 21930 | 3358 const char *versionend; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3359 const XML_Char *storedversion = NULL; |
| 21930 | 3360 int standalone = -1; |
| 3361 if (!(ns | |
| 3362 ? XmlParseXmlDeclNS | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3363 : XmlParseXmlDecl)(isGeneralTextEntity, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3364 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3365 s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3366 next, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3367 &eventPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3368 &version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3369 &versionend, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3370 &encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3371 &newEncoding, |
| 32911 | 3372 &standalone)) { |
| 3373 if (isGeneralTextEntity) | |
| 3374 return XML_ERROR_TEXT_DECL; | |
| 3375 else | |
| 3376 return XML_ERROR_XML_DECL; | |
| 3377 } | |
| 21930 | 3378 if (!isGeneralTextEntity && standalone == 1) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3379 _dtd->standalone = XML_TRUE; |
| 21930 | 3380 #ifdef XML_DTD |
| 3381 if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) | |
| 3382 paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | |
| 3383 #endif /* XML_DTD */ | |
| 3384 } | |
| 3385 if (xmlDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3386 if (encodingName != NULL) { |
| 21930 | 3387 storedEncName = poolStoreString(&temp2Pool, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3388 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3389 encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3390 encodingName |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3391 + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3392 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3393 return XML_ERROR_NO_MEMORY; |
| 21930 | 3394 poolFinish(&temp2Pool); |
| 3395 } | |
| 3396 if (version) { | |
| 3397 storedversion = poolStoreString(&temp2Pool, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3398 encoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3399 version, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3400 versionend - encoding->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3401 if (!storedversion) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3402 return XML_ERROR_NO_MEMORY; |
| 21930 | 3403 } |
| 3404 xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); | |
| 3405 } | |
| 3406 else if (defaultHandler) | |
| 3407 reportDefault(parser, encoding, s, next); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3408 if (protocolEncodingName == NULL) { |
| 21930 | 3409 if (newEncoding) { |
| 3410 if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3411 eventPtr = encodingName; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3412 return XML_ERROR_INCORRECT_ENCODING; |
| 21930 | 3413 } |
| 3414 encoding = newEncoding; | |
| 3415 } | |
| 3416 else if (encodingName) { | |
| 3417 enum XML_Error result; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3418 if (!storedEncName) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3419 storedEncName = poolStoreString( |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3420 &temp2Pool, encoding, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3421 encodingName + XmlNameLength(encoding, encodingName)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3422 if (!storedEncName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3423 return XML_ERROR_NO_MEMORY; |
| 21930 | 3424 } |
| 3425 result = handleUnknownEncoding(parser, storedEncName); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3426 poolClear(&temp2Pool); |
| 21930 | 3427 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
|
3428 eventPtr = encodingName; |
| 21930 | 3429 return result; |
| 3430 } | |
| 3431 } | |
| 3432 | |
| 3433 if (storedEncName || storedversion) | |
| 3434 poolClear(&temp2Pool); | |
| 3435 | |
| 3436 return XML_ERROR_NONE; | |
| 3437 } | |
| 3438 | |
| 3439 static enum XML_Error | |
| 3440 handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | |
| 3441 { | |
| 3442 if (unknownEncodingHandler) { | |
| 3443 XML_Encoding info; | |
| 3444 int i; | |
| 3445 for (i = 0; i < 256; i++) | |
| 3446 info.map[i] = -1; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3447 info.convert = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3448 info.data = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3449 info.release = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3450 if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3451 &info)) { |
| 21930 | 3452 ENCODING *enc; |
| 3453 unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); | |
| 3454 if (!unknownEncodingMem) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3455 if (info.release) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3456 info.release(info.data); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3457 return XML_ERROR_NO_MEMORY; |
| 21930 | 3458 } |
| 3459 enc = (ns | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3460 ? XmlInitUnknownEncodingNS |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3461 : XmlInitUnknownEncoding)(unknownEncodingMem, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3462 info.map, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3463 info.convert, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3464 info.data); |
| 21930 | 3465 if (enc) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3466 unknownEncodingData = info.data; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3467 unknownEncodingRelease = info.release; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3468 encoding = enc; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3469 return XML_ERROR_NONE; |
| 21930 | 3470 } |
| 3471 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3472 if (info.release != NULL) |
| 21930 | 3473 info.release(info.data); |
| 3474 } | |
| 3475 return XML_ERROR_UNKNOWN_ENCODING; | |
| 3476 } | |
| 3477 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3478 static enum XML_Error PTRCALL |
| 21930 | 3479 prologInitProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3480 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3481 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3482 const char **nextPtr) |
| 21930 | 3483 { |
| 3484 enum XML_Error result = initializeEncoding(parser); | |
| 3485 if (result != XML_ERROR_NONE) | |
| 3486 return result; | |
| 3487 processor = prologProcessor; | |
| 3488 return prologProcessor(parser, s, end, nextPtr); | |
| 3489 } | |
| 3490 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3491 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3492 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3493 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3494 externalParEntInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3495 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3496 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3497 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3498 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3499 enum XML_Error result = initializeEncoding(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3500 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3501 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3502 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3503 /* 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
|
3504 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
|
3505 _dtd->paramEntityRead = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3506 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3507 if (prologState.inEntityValue) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3508 processor = entityValueInitProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3509 return entityValueInitProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3510 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3511 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3512 processor = externalParEntProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3513 return externalParEntProcessor(parser, s, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3514 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3515 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3516 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3517 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3518 entityValueInitProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3519 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3520 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3521 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3522 { |
| 32911 | 3523 int tok; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3524 const char *start = s; |
| 32911 | 3525 const char *next = start; |
| 3526 eventPtr = start; | |
| 3527 | |
| 3528 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3529 tok = XmlPrologTok(encoding, start, end, &next); |
| 32911 | 3530 eventEndPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3531 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3532 if (!ps_finalBuffer && tok != XML_TOK_INVALID) { |
| 32911 | 3533 *nextPtr = s; |
| 3534 return XML_ERROR_NONE; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3535 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3536 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3537 case XML_TOK_INVALID: |
| 32911 | 3538 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3539 case XML_TOK_PARTIAL: |
| 32911 | 3540 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3541 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3542 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3543 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3544 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3545 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3546 } |
| 32911 | 3547 /* 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
|
3548 return storeEntityValue(parser, encoding, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3549 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3550 else if (tok == XML_TOK_XML_DECL) { |
| 32911 | 3551 enum XML_Error result; |
| 3552 result = processXmlDecl(parser, 0, start, next); | |
| 3553 if (result != XML_ERROR_NONE) | |
| 3554 return result; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3555 switch (ps_parsing) { |
| 32911 | 3556 case XML_SUSPENDED: |
| 3557 *nextPtr = next; | |
| 3558 return XML_ERROR_NONE; | |
| 3559 case XML_FINISHED: | |
| 3560 return XML_ERROR_ABORTED; | |
| 3561 default: | |
| 3562 *nextPtr = next; | |
| 3563 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3564 /* 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
|
3565 processor = entityValueProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3566 return entityValueProcessor(parser, next, end, nextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3567 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3568 /* 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
|
3569 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
|
3570 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
|
3571 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
|
3572 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
|
3573 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
|
3574 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3575 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
|
3576 *nextPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3577 return XML_ERROR_NONE; |
|
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 start = next; |
| 32911 | 3580 eventPtr = start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3581 } |
|
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 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3585 externalParEntProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3586 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3587 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3588 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3589 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3590 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3591 int tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3592 |
| 32911 | 3593 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
|
3594 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3595 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
|
3596 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3597 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3598 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3599 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3600 case XML_TOK_INVALID: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3601 return XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3602 case XML_TOK_PARTIAL: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3603 return XML_ERROR_UNCLOSED_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3604 case XML_TOK_PARTIAL_CHAR: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3605 return XML_ERROR_PARTIAL_CHAR; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3606 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3607 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3608 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3609 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3610 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3611 /* 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
|
3612 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
|
3613 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
|
3614 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3615 else if (tok == XML_TOK_BOM) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3616 s = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3617 tok = XmlPrologTok(encoding, s, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3618 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3619 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3620 processor = prologProcessor; |
| 32911 | 3621 return doProlog(parser, encoding, s, end, tok, next, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3622 nextPtr, (XML_Bool)!ps_finalBuffer); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3623 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3624 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3625 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3626 entityValueProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3627 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3628 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3629 const char **nextPtr) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3630 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3631 const char *start = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3632 const char *next = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3633 const ENCODING *enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3634 int tok; |
|
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 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3637 tok = XmlPrologTok(enc, start, end, &next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3638 if (tok <= 0) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3639 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
|
3640 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3641 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3642 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3643 switch (tok) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3644 case XML_TOK_INVALID: |
| 32911 | 3645 return XML_ERROR_INVALID_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3646 case XML_TOK_PARTIAL: |
| 32911 | 3647 return XML_ERROR_UNCLOSED_TOKEN; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3648 case XML_TOK_PARTIAL_CHAR: |
| 32911 | 3649 return XML_ERROR_PARTIAL_CHAR; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3650 case XML_TOK_NONE: /* start == end */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3651 default: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3652 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3653 } |
| 32911 | 3654 /* 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
|
3655 return storeEntityValue(parser, enc, s, end); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3656 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3657 start = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3658 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3659 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3660 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3661 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3662 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3663 static enum XML_Error PTRCALL |
| 21930 | 3664 prologProcessor(XML_Parser parser, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3665 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3666 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3667 const char **nextPtr) |
| 21930 | 3668 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3669 const char *next = s; |
| 21930 | 3670 int tok = XmlPrologTok(encoding, s, end, &next); |
| 32911 | 3671 return doProlog(parser, encoding, s, end, tok, next, |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3672 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 21930 | 3673 } |
| 3674 | |
| 3675 static enum XML_Error | |
| 3676 doProlog(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3677 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3678 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3679 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3680 int tok, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3681 const char *next, |
| 32911 | 3682 const char **nextPtr, |
| 3683 XML_Bool haveMore) | |
| 21930 | 3684 { |
| 3685 #ifdef XML_DTD | |
| 3686 static const XML_Char externalSubsetName[] = { '#' , '\0' }; | |
| 3687 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3688 static const XML_Char atypeCDATA[] = { 'C', 'D', 'A', 'T', 'A', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3689 static const XML_Char atypeID[] = { 'I', 'D', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3690 static const XML_Char atypeIDREF[] = { 'I', 'D', 'R', 'E', 'F', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3691 static const XML_Char atypeIDREFS[] = { 'I', 'D', 'R', 'E', 'F', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3692 static const XML_Char atypeENTITY[] = { 'E', 'N', 'T', 'I', 'T', 'Y', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3693 static const XML_Char atypeENTITIES[] = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3694 { 'E', 'N', 'T', 'I', 'T', 'I', 'E', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3695 static const XML_Char atypeNMTOKEN[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3696 'N', 'M', 'T', 'O', 'K', 'E', 'N', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3697 static const XML_Char atypeNMTOKENS[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3698 'N', 'M', 'T', 'O', 'K', 'E', 'N', 'S', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3699 static const XML_Char notationPrefix[] = { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3700 'N', 'O', 'T', 'A', 'T', 'I', 'O', 'N', '(', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3701 static const XML_Char enumValueSep[] = { '|', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3702 static const XML_Char enumValueStart[] = { '(', '\0' }; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3703 |
| 32911 | 3704 /* save one level of indirection */ |
| 3705 DTD * const dtd = _dtd; | |
| 21930 | 3706 |
| 3707 const char **eventPP; | |
| 3708 const char **eventEndPP; | |
| 3709 enum XML_Content_Quant quant; | |
| 3710 | |
| 3711 if (enc == encoding) { | |
| 3712 eventPP = &eventPtr; | |
| 3713 eventEndPP = &eventEndPtr; | |
| 3714 } | |
| 3715 else { | |
| 3716 eventPP = &(openInternalEntities->internalEventPtr); | |
| 3717 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 3718 } | |
| 32911 | 3719 |
| 21930 | 3720 for (;;) { |
| 3721 int role; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3722 XML_Bool handleDefault = XML_TRUE; |
| 21930 | 3723 *eventPP = s; |
| 3724 *eventEndPP = next; | |
| 3725 if (tok <= 0) { | |
| 32911 | 3726 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
|
3727 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3728 return XML_ERROR_NONE; |
| 21930 | 3729 } |
| 3730 switch (tok) { | |
| 3731 case XML_TOK_INVALID: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3732 *eventPP = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3733 return XML_ERROR_INVALID_TOKEN; |
| 21930 | 3734 case XML_TOK_PARTIAL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3735 return XML_ERROR_UNCLOSED_TOKEN; |
| 21930 | 3736 case XML_TOK_PARTIAL_CHAR: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3737 return XML_ERROR_PARTIAL_CHAR; |
|
58437
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3738 case -XML_TOK_PROLOG_S: |
|
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3739 tok = -tok; |
|
9e124e6402bc
- Expat: Fix DoS via XML document with malformed UTF-8 sequences
Matthias Klose <doko@ubuntu.com>
parents:
39473
diff
changeset
|
3740 break; |
| 21930 | 3741 case XML_TOK_NONE: |
| 3742 #ifdef XML_DTD | |
| 32911 | 3743 /* for internal PE NOT referenced between declarations */ |
| 3744 if (enc != encoding && !openInternalEntities->betweenDecl) { | |
| 3745 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3746 return XML_ERROR_NONE; |
| 32911 | 3747 } |
| 3748 /* WFC: PE Between Declarations - must check that PE contains | |
| 3749 complete markup, not only for external PEs, but also for | |
| 3750 internal PEs if the reference occurs between declarations. | |
| 3751 */ | |
| 3752 if (isParamEntity || enc != encoding) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3753 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
|
3754 == XML_ROLE_ERROR) |
| 32911 | 3755 return XML_ERROR_INCOMPLETE_PE; |
| 3756 *nextPtr = s; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3757 return XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3758 } |
| 21930 | 3759 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3760 return XML_ERROR_NO_ELEMENTS; |
| 21930 | 3761 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3762 tok = -tok; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3763 next = end; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3764 break; |
| 21930 | 3765 } |
| 3766 } | |
| 3767 role = XmlTokenRole(&prologState, tok, s, next, enc); | |
| 3768 switch (role) { | |
| 3769 case XML_ROLE_XML_DECL: | |
| 3770 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3771 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
|
3772 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3773 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3774 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3775 handleDefault = XML_FALSE; |
| 21930 | 3776 } |
| 3777 break; | |
| 3778 case XML_ROLE_DOCTYPE_NAME: | |
| 3779 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3780 doctypeName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3781 if (!doctypeName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3782 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3783 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3784 doctypePubid = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3785 handleDefault = XML_FALSE; |
| 21930 | 3786 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3787 doctypeSysid = NULL; /* always initialize to NULL */ |
| 21930 | 3788 break; |
| 3789 case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | |
| 3790 if (startDoctypeDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3791 startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3792 doctypePubid, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3793 doctypeName = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3794 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3795 handleDefault = XML_FALSE; |
| 21930 | 3796 } |
| 3797 break; | |
| 3798 #ifdef XML_DTD | |
| 3799 case XML_ROLE_TEXT_DECL: | |
| 3800 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3801 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
|
3802 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3803 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3804 enc = encoding; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3805 handleDefault = XML_FALSE; |
| 21930 | 3806 } |
| 3807 break; | |
| 3808 #endif /* XML_DTD */ | |
| 3809 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
|
3810 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3811 useForeignDTD = XML_FALSE; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
3812 declEntity = (ENTITY *)lookup(parser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
3813 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3814 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3815 sizeof(ENTITY)); |
| 21930 | 3816 if (!declEntity) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3817 return XML_ERROR_NO_MEMORY; |
| 21930 | 3818 #endif /* XML_DTD */ |
| 32911 | 3819 dtd->hasParamEntityRefs = XML_TRUE; |
| 3820 if (startDoctypeDeclHandler) { | |
| 3821 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 3822 return XML_ERROR_PUBLICID; | |
| 3823 doctypePubid = poolStoreString(&tempPool, enc, | |
| 3824 s + enc->minBytesPerChar, | |
| 3825 next - enc->minBytesPerChar); | |
| 3826 if (!doctypePubid) | |
| 3827 return XML_ERROR_NO_MEMORY; | |
| 3828 normalizePublicId((XML_Char *)doctypePubid); | |
| 3829 poolFinish(&tempPool); | |
| 3830 handleDefault = XML_FALSE; | |
| 3831 goto alreadyChecked; | |
| 3832 } | |
| 21930 | 3833 /* fall through */ |
| 3834 case XML_ROLE_ENTITY_PUBLIC_ID: | |
| 3835 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 3836 return XML_ERROR_PUBLICID; |
| 3837 alreadyChecked: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3838 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3839 XML_Char *tem = poolStoreString(&dtd->pool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3840 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3841 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3842 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3843 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3844 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3845 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3846 declEntity->publicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3847 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3848 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3849 handleDefault = XML_FALSE; |
| 21930 | 3850 } |
| 3851 break; | |
| 3852 case XML_ROLE_DOCTYPE_CLOSE: | |
| 3853 if (doctypeName) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3854 startDoctypeDeclHandler(handlerArg, doctypeName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3855 doctypeSysid, doctypePubid, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3856 poolClear(&tempPool); |
|
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 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
|
3860 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
|
3861 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
|
3862 */ |
| 21930 | 3863 #ifdef XML_DTD |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3864 if (doctypeSysid || useForeignDTD) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3865 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3866 dtd->hasParamEntityRefs = XML_TRUE; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3867 if (paramEntityParsing && externalEntityRefHandler) { |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
3868 ENTITY *entity = (ENTITY *)lookup(parser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
3869 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3870 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3871 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3872 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3873 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3874 if (useForeignDTD) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3875 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3876 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3877 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3878 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3879 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3880 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3881 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3882 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3883 if (dtd->paramEntityRead) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3884 if (!dtd->standalone && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3885 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3886 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3887 return XML_ERROR_NOT_STANDALONE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3888 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3889 /* if we didn't read the foreign DTD then this means that there |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3890 is no external subset and we must reset dtd->hasParamEntityRefs |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3891 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3892 else if (!doctypeSysid) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3893 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3894 /* 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
|
3895 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3896 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3897 } |
| 21930 | 3898 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3899 if (endDoctypeDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3900 endDoctypeDeclHandler(handlerArg); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3901 handleDefault = XML_FALSE; |
| 21930 | 3902 } |
| 3903 break; | |
| 3904 case XML_ROLE_INSTANCE_START: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3905 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3906 /* 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
|
3907 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
|
3908 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3909 if (useForeignDTD) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3910 XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3911 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3912 if (paramEntityParsing && externalEntityRefHandler) { |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
3913 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
|
3914 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3915 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3916 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3917 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3918 entity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3919 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3920 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3921 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3922 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3923 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3924 entity->publicId)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3925 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3926 if (dtd->paramEntityRead) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3927 if (!dtd->standalone && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3928 notStandaloneHandler && |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3929 !notStandaloneHandler(handlerArg)) |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3930 return XML_ERROR_NOT_STANDALONE; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3931 } |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3932 /* if we didn't read the foreign DTD then this means that there |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3933 is no external subset and we must reset dtd->hasParamEntityRefs |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3934 */ |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3935 else |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
3936 dtd->hasParamEntityRefs = hadParamEntityRefs; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3937 /* 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
|
3938 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3939 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3940 #endif /* XML_DTD */ |
| 21930 | 3941 processor = contentProcessor; |
| 3942 return contentProcessor(parser, s, end, nextPtr); | |
| 3943 case XML_ROLE_ATTLIST_ELEMENT_NAME: | |
| 3944 declElementType = getElementType(parser, enc, s, next); | |
| 3945 if (!declElementType) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3946 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3947 goto checkAttListDeclHandler; |
| 21930 | 3948 case XML_ROLE_ATTRIBUTE_NAME: |
| 3949 declAttributeId = getAttributeId(parser, enc, s, next); | |
| 3950 if (!declAttributeId) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3951 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3952 declAttributeIsCdata = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3953 declAttributeType = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3954 declAttributeIsId = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3955 goto checkAttListDeclHandler; |
| 21930 | 3956 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
|
3957 declAttributeIsCdata = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3958 declAttributeType = atypeCDATA; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3959 goto checkAttListDeclHandler; |
| 21930 | 3960 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
|
3961 declAttributeIsId = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3962 declAttributeType = atypeID; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3963 goto checkAttListDeclHandler; |
| 21930 | 3964 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
|
3965 declAttributeType = atypeIDREF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3966 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3967 case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3968 declAttributeType = atypeIDREFS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3969 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3970 case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3971 declAttributeType = atypeENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3972 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3973 case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3974 declAttributeType = atypeENTITIES; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3975 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3976 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3977 declAttributeType = atypeNMTOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3978 goto checkAttListDeclHandler; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3979 case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3980 declAttributeType = atypeNMTOKENS; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3981 checkAttListDeclHandler: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3982 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3983 handleDefault = XML_FALSE; |
| 21930 | 3984 break; |
| 3985 case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | |
| 3986 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
|
3987 if (dtd->keepProcessing && attlistDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3988 const XML_Char *prefix; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3989 if (declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3990 prefix = enumValueSep; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3991 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3992 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3993 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
|
3994 ? notationPrefix |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3995 : enumValueStart); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3996 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3997 if (!poolAppendString(&tempPool, prefix)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3998 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
3999 if (!poolAppend(&tempPool, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4000 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4001 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4002 handleDefault = XML_FALSE; |
| 21930 | 4003 } |
| 4004 break; | |
| 4005 case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | |
| 4006 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
|
4007 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4008 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
|
4009 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
|
4010 0, parser)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4011 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4012 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4013 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4014 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4015 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4016 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4017 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4018 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4019 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4020 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4021 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4022 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4023 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4024 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4025 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4026 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
|
4027 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4028 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4029 } |
| 21930 | 4030 } |
| 4031 break; | |
| 4032 case XML_ROLE_DEFAULT_ATTRIBUTE_VALUE: | |
| 4033 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
|
4034 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4035 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
|
4036 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
|
4037 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
|
4038 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
|
4039 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
|
4040 &dtd->pool); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4041 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4042 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4043 attVal = poolStart(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4044 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4045 /* 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
|
4046 if (!defineAttribute(declElementType, declAttributeId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4047 declAttributeIsCdata, XML_FALSE, attVal, parser)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4048 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4049 if (attlistDeclHandler && declAttributeType) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4050 if (*declAttributeType == XML_T('(') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4051 || (*declAttributeType == XML_T('N') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4052 && declAttributeType[1] == XML_T('O'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4053 /* Enumerated or Notation type */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4054 if (!poolAppendChar(&tempPool, XML_T(')')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4055 || !poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4056 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4057 declAttributeType = tempPool.start; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4058 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4059 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4060 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4061 attlistDeclHandler(handlerArg, declElementType->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4062 declAttributeId->name, declAttributeType, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4063 attVal, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4064 role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4065 poolClear(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4066 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4067 } |
| 21930 | 4068 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4069 break; |
| 21930 | 4070 case XML_ROLE_ENTITY_VALUE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4071 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4072 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
|
4073 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4074 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4075 if (declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4076 declEntity->textPtr = poolStart(&dtd->entityValuePool); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4077 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
|
4078 poolFinish(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4079 if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4080 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4081 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4082 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4083 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4084 declEntity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4085 declEntity->textLen, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4086 curBase, 0, 0, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4087 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4088 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4089 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4090 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4091 poolDiscard(&dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4092 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4093 return result; |
| 21930 | 4094 } |
| 4095 break; | |
| 4096 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
|
4097 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4098 useForeignDTD = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4099 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4100 dtd->hasParamEntityRefs = XML_TRUE; |
| 21930 | 4101 if (startDoctypeDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4102 doctypeSysid = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4103 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4104 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4105 if (doctypeSysid == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4106 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4107 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4108 handleDefault = XML_FALSE; |
| 21930 | 4109 } |
| 4110 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4111 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4112 /* 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
|
4113 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
|
4114 doctypeSysid = externalSubsetName; |
| 21930 | 4115 #endif /* XML_DTD */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4116 if (!dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4117 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4118 && !paramEntityParsing |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4119 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4120 && notStandaloneHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4121 && !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4122 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4123 #ifndef XML_DTD |
| 4124 break; | |
| 4125 #else /* XML_DTD */ | |
| 4126 if (!declEntity) { | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4127 declEntity = (ENTITY *)lookup(parser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4128 &dtd->paramEntities, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4129 externalSubsetName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4130 sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4131 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4132 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4133 declEntity->publicId = NULL; |
| 21930 | 4134 } |
| 4135 /* fall through */ | |
| 4136 #endif /* XML_DTD */ | |
| 4137 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
|
4138 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4139 declEntity->systemId = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4140 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4141 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4142 if (!declEntity->systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4143 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4144 declEntity->base = curBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4145 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4146 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4147 handleDefault = XML_FALSE; |
| 21930 | 4148 } |
| 4149 break; | |
| 4150 case XML_ROLE_ENTITY_COMPLETE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4151 if (dtd->keepProcessing && declEntity && entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4152 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4153 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4154 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4155 declEntity->is_param, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4156 0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4157 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4158 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4159 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4160 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4161 handleDefault = XML_FALSE; |
| 21930 | 4162 } |
| 4163 break; | |
| 4164 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
|
4165 if (dtd->keepProcessing && declEntity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4166 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
|
4167 if (!declEntity->notation) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4168 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4169 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4170 if (unparsedEntityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4171 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4172 unparsedEntityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4173 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4174 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4175 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4176 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4177 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4178 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4179 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4180 else if (entityDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4181 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4182 entityDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4183 declEntity->name, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4184 0,0,0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4185 declEntity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4186 declEntity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4187 declEntity->publicId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4188 declEntity->notation); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4189 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4190 } |
| 21930 | 4191 } |
| 4192 break; | |
| 4193 case XML_ROLE_GENERAL_ENTITY_NAME: | |
| 4194 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4195 if (XmlPredefinedEntityName(enc, s, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4196 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4197 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4198 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4199 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4200 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
|
4201 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4202 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4203 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
|
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 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4208 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4209 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4210 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4211 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4212 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4213 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4214 declEntity->is_param = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4215 /* 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
|
4216 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
|
4217 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4218 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4219 if (entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4220 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4221 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4222 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4223 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4224 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4225 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4226 } |
| 21930 | 4227 } |
| 4228 break; | |
| 4229 case XML_ROLE_PARAM_ENTITY_NAME: | |
| 4230 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4231 if (dtd->keepProcessing) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4232 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
|
4233 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4234 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4235 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
|
4236 name, sizeof(ENTITY)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4237 if (!declEntity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4238 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4239 if (declEntity->name != name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4240 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4241 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4242 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4243 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4244 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4245 declEntity->publicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4246 declEntity->is_param = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4247 /* 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
|
4248 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
|
4249 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4250 declEntity->is_internal = !(parentParser || openInternalEntities); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4251 if (entityDeclHandler) |
|
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 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4255 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4256 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4257 declEntity = NULL; |
| 21930 | 4258 } |
| 4259 #else /* not XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4260 declEntity = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4261 #endif /* XML_DTD */ |
| 21930 | 4262 break; |
| 4263 case XML_ROLE_NOTATION_NAME: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4264 declNotationPublicId = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4265 declNotationName = NULL; |
| 21930 | 4266 if (notationDeclHandler) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4267 declNotationName = poolStoreString(&tempPool, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4268 if (!declNotationName) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4269 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4270 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4271 handleDefault = XML_FALSE; |
| 21930 | 4272 } |
| 4273 break; | |
| 4274 case XML_ROLE_NOTATION_PUBLIC_ID: | |
| 4275 if (!XmlIsPublicId(enc, s, next, eventPP)) | |
| 32911 | 4276 return XML_ERROR_PUBLICID; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4277 if (declNotationName) { /* means notationDeclHandler != NULL */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4278 XML_Char *tem = poolStoreString(&tempPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4279 enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4280 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4281 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4282 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4283 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4284 normalizePublicId(tem); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4285 declNotationPublicId = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4286 poolFinish(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4287 handleDefault = XML_FALSE; |
| 21930 | 4288 } |
| 4289 break; | |
| 4290 case XML_ROLE_NOTATION_SYSTEM_ID: | |
| 4291 if (declNotationName && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4292 const XML_Char *systemId |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4293 = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4294 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4295 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4296 if (!systemId) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4297 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4298 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4299 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4300 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4301 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4302 systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4303 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4304 handleDefault = XML_FALSE; |
| 21930 | 4305 } |
| 4306 poolClear(&tempPool); | |
| 4307 break; | |
| 4308 case XML_ROLE_NOTATION_NO_SYSTEM_ID: | |
| 4309 if (declNotationPublicId && notationDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4310 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4311 notationDeclHandler(handlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4312 declNotationName, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4313 curBase, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4314 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4315 declNotationPublicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4316 handleDefault = XML_FALSE; |
| 21930 | 4317 } |
| 4318 poolClear(&tempPool); | |
| 4319 break; | |
| 4320 case XML_ROLE_ERROR: | |
| 4321 switch (tok) { | |
| 4322 case XML_TOK_PARAM_ENTITY_REF: | |
| 32911 | 4323 /* PE references in internal subset are |
| 4324 not allowed within declarations. */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4325 return XML_ERROR_PARAM_ENTITY_REF; |
| 21930 | 4326 case XML_TOK_XML_DECL: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4327 return XML_ERROR_MISPLACED_XML_PI; |
| 21930 | 4328 default: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4329 return XML_ERROR_SYNTAX; |
| 21930 | 4330 } |
| 4331 #ifdef XML_DTD | |
| 4332 case XML_ROLE_IGNORE_SECT: | |
| 4333 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4334 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4335 if (defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4336 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4337 handleDefault = XML_FALSE; |
| 32911 | 4338 result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); |
| 4339 if (result != XML_ERROR_NONE) | |
| 4340 return result; | |
| 4341 else if (!next) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4342 processor = ignoreSectionProcessor; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4343 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4344 } |
| 21930 | 4345 } |
| 4346 break; | |
| 4347 #endif /* XML_DTD */ | |
| 4348 case XML_ROLE_GROUP_OPEN: | |
| 4349 if (prologState.level >= groupSize) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4350 if (groupSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4351 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
|
4352 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4353 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4354 groupConnector = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4355 if (dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4356 int *temp = (int *)REALLOC(dtd->scaffIndex, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4357 groupSize * sizeof(int)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4358 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4359 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4360 dtd->scaffIndex = temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4361 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4362 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4363 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4364 groupConnector = (char *)MALLOC(groupSize = 32); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4365 if (!groupConnector) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4366 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4367 } |
| 21930 | 4368 } |
| 4369 groupConnector[prologState.level] = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4370 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4371 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4372 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4373 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4374 dtd->scaffIndex[dtd->scaffLevel] = myindex; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4375 dtd->scaffLevel++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4376 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
|
4377 if (elementDeclHandler) |
|
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 break; | |
| 4381 case XML_ROLE_GROUP_SEQUENCE: | |
| 4382 if (groupConnector[prologState.level] == '|') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4383 return XML_ERROR_SYNTAX; |
| 21930 | 4384 groupConnector[prologState.level] = ','; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4385 if (dtd->in_eldecl && elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4386 handleDefault = XML_FALSE; |
| 21930 | 4387 break; |
| 4388 case XML_ROLE_GROUP_CHOICE: | |
| 4389 if (groupConnector[prologState.level] == ',') | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4390 return XML_ERROR_SYNTAX; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4391 if (dtd->in_eldecl |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4392 && !groupConnector[prologState.level] |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4393 && (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
|
4394 != XML_CTYPE_MIXED) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4395 ) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4396 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
|
4397 = XML_CTYPE_CHOICE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4398 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4399 handleDefault = XML_FALSE; |
| 21930 | 4400 } |
| 4401 groupConnector[prologState.level] = '|'; | |
| 4402 break; | |
| 4403 case XML_ROLE_PARAM_ENTITY_REF: | |
| 4404 #ifdef XML_DTD | |
| 4405 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
|
4406 dtd->hasParamEntityRefs = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4407 if (!paramEntityParsing) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4408 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4409 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4410 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4411 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4412 name = poolStoreString(&dtd->pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4413 s + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4414 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4415 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4416 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4417 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
|
4418 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4419 /* 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
|
4420 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
|
4421 otherwise call the skipped entity handler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4422 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4423 if (prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4424 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4425 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4426 : !dtd->hasParamEntityRefs)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4427 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4428 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4429 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4430 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
|
4431 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4432 else if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4433 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4434 /* cannot report skipped entities in declarations */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4435 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
|
4436 skippedEntityHandler(handlerArg, name, 1); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4437 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4438 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4439 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4440 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4441 if (entity->open) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4442 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4443 if (entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4444 enum XML_Error result; |
| 32911 | 4445 XML_Bool betweenDecl = |
| 4446 (role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE); | |
| 4447 result = processInternalEntity(parser, entity, betweenDecl); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4448 if (result != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4449 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4450 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4451 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4452 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4453 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4454 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4455 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4456 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4457 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4458 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4459 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4460 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4461 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4462 return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4463 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4464 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4465 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4466 if (!dtd->paramEntityRead) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4467 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4468 break; |
|
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 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4471 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4472 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4473 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4474 } |
| 21930 | 4475 } |
| 4476 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4477 if (!dtd->standalone && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4478 notStandaloneHandler && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4479 !notStandaloneHandler(handlerArg)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4480 return XML_ERROR_NOT_STANDALONE; |
| 21930 | 4481 break; |
| 4482 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4483 /* Element declaration stuff */ |
| 21930 | 4484 |
| 4485 case XML_ROLE_ELEMENT_NAME: | |
| 4486 if (elementDeclHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4487 declElementType = getElementType(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4488 if (!declElementType) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4489 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4490 dtd->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4491 dtd->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4492 dtd->in_eldecl = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4493 handleDefault = XML_FALSE; |
| 21930 | 4494 } |
| 4495 break; | |
| 4496 | |
| 4497 case XML_ROLE_CONTENT_ANY: | |
| 4498 case XML_ROLE_CONTENT_EMPTY: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4499 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4500 if (elementDeclHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4501 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
|
4502 if (!content) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4503 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4504 content->quant = XML_CQUANT_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4505 content->name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4506 content->numchildren = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4507 content->children = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4508 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
|
4509 XML_CTYPE_ANY : |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4510 XML_CTYPE_EMPTY); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4511 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4512 elementDeclHandler(handlerArg, declElementType->name, content); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4513 handleDefault = XML_FALSE; |
|
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 dtd->in_eldecl = XML_FALSE; |
| 21930 | 4516 } |
| 4517 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4518 |
| 21930 | 4519 case XML_ROLE_CONTENT_PCDATA: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4520 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4521 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
|
4522 = XML_CTYPE_MIXED; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4523 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4524 handleDefault = XML_FALSE; |
| 21930 | 4525 } |
| 4526 break; | |
| 4527 | |
| 4528 case XML_ROLE_CONTENT_ELEMENT: | |
| 4529 quant = XML_CQUANT_NONE; | |
| 4530 goto elementContent; | |
| 4531 case XML_ROLE_CONTENT_ELEMENT_OPT: | |
| 4532 quant = XML_CQUANT_OPT; | |
| 4533 goto elementContent; | |
| 4534 case XML_ROLE_CONTENT_ELEMENT_REP: | |
| 4535 quant = XML_CQUANT_REP; | |
| 4536 goto elementContent; | |
| 4537 case XML_ROLE_CONTENT_ELEMENT_PLUS: | |
| 4538 quant = XML_CQUANT_PLUS; | |
| 4539 elementContent: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4540 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4541 ELEMENT_TYPE *el; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4542 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4543 int nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4544 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
|
4545 ? next |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4546 : next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4547 int myindex = nextScaffoldPart(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4548 if (myindex < 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4549 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4550 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
|
4551 dtd->scaffold[myindex].quant = quant; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4552 el = getElementType(parser, enc, s, nxt); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4553 if (!el) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4554 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4555 name = el->name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4556 dtd->scaffold[myindex].name = name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4557 nameLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4558 for (; name[nameLen++]; ); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4559 dtd->contentStringLen += nameLen; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4560 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4561 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4562 } |
| 21930 | 4563 break; |
| 4564 | |
| 4565 case XML_ROLE_GROUP_CLOSE: | |
| 4566 quant = XML_CQUANT_NONE; | |
| 4567 goto closeGroup; | |
| 4568 case XML_ROLE_GROUP_CLOSE_OPT: | |
| 4569 quant = XML_CQUANT_OPT; | |
| 4570 goto closeGroup; | |
| 4571 case XML_ROLE_GROUP_CLOSE_REP: | |
| 4572 quant = XML_CQUANT_REP; | |
| 4573 goto closeGroup; | |
| 4574 case XML_ROLE_GROUP_CLOSE_PLUS: | |
| 4575 quant = XML_CQUANT_PLUS; | |
| 4576 closeGroup: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4577 if (dtd->in_eldecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4578 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4579 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4580 dtd->scaffLevel--; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4581 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
|
4582 if (dtd->scaffLevel == 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4583 if (!handleDefault) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4584 XML_Content *model = build_model(parser); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4585 if (!model) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4586 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4587 *eventEndPP = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4588 elementDeclHandler(handlerArg, declElementType->name, model); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4589 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4590 dtd->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4591 dtd->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4592 } |
| 21930 | 4593 } |
| 4594 break; | |
| 4595 /* End element declaration stuff */ | |
| 4596 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4597 case XML_ROLE_PI: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4598 if (!reportProcessingInstruction(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4599 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4600 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4601 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4602 case XML_ROLE_COMMENT: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4603 if (!reportComment(parser, enc, s, next)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4604 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4605 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4606 break; |
| 21930 | 4607 case XML_ROLE_NONE: |
| 4608 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4609 case XML_TOK_BOM: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4610 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4611 break; |
| 21930 | 4612 } |
| 4613 break; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4614 case XML_ROLE_DOCTYPE_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4615 if (startDoctypeDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4616 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4617 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4618 case XML_ROLE_ENTITY_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4619 if (dtd->keepProcessing && entityDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4620 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4621 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4622 case XML_ROLE_NOTATION_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4623 if (notationDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4624 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4625 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4626 case XML_ROLE_ATTLIST_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4627 if (dtd->keepProcessing && attlistDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4628 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4629 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4630 case XML_ROLE_ELEMENT_NONE: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4631 if (elementDeclHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4632 handleDefault = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4633 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4634 } /* end of big switch */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4635 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4636 if (handleDefault && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4637 reportDefault(parser, enc, s, next); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4638 |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4639 switch (ps_parsing) { |
| 32911 | 4640 case XML_SUSPENDED: |
| 4641 *nextPtr = next; | |
| 4642 return XML_ERROR_NONE; | |
| 4643 case XML_FINISHED: | |
| 4644 return XML_ERROR_ABORTED; | |
| 4645 default: | |
| 4646 s = next; | |
| 4647 tok = XmlPrologTok(enc, s, end, &next); | |
| 4648 } | |
| 21930 | 4649 } |
| 4650 /* not reached */ | |
| 4651 } | |
| 4652 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4653 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4654 epilogProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4655 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4656 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4657 const char **nextPtr) |
| 21930 | 4658 { |
| 4659 processor = epilogProcessor; | |
| 4660 eventPtr = s; | |
| 4661 for (;;) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4662 const char *next = NULL; |
| 21930 | 4663 int tok = XmlPrologTok(encoding, s, end, &next); |
| 4664 eventEndPtr = next; | |
| 4665 switch (tok) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4666 /* report partial linebreak - it might be the last token */ |
| 21930 | 4667 case -XML_TOK_PROLOG_S: |
| 4668 if (defaultHandler) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4669 reportDefault(parser, encoding, s, next); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4670 if (ps_parsing == XML_FINISHED) |
| 32911 | 4671 return XML_ERROR_ABORTED; |
| 21930 | 4672 } |
| 32911 | 4673 *nextPtr = next; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4674 return XML_ERROR_NONE; |
| 21930 | 4675 case XML_TOK_NONE: |
| 32911 | 4676 *nextPtr = s; |
| 21930 | 4677 return XML_ERROR_NONE; |
| 4678 case XML_TOK_PROLOG_S: | |
| 4679 if (defaultHandler) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4680 reportDefault(parser, encoding, s, next); |
| 21930 | 4681 break; |
| 4682 case XML_TOK_PI: | |
| 4683 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
|
4684 return XML_ERROR_NO_MEMORY; |
| 21930 | 4685 break; |
| 4686 case XML_TOK_COMMENT: | |
| 4687 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
|
4688 return XML_ERROR_NO_MEMORY; |
| 21930 | 4689 break; |
| 4690 case XML_TOK_INVALID: | |
| 4691 eventPtr = next; | |
| 4692 return XML_ERROR_INVALID_TOKEN; | |
| 4693 case XML_TOK_PARTIAL: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4694 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4695 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4696 return XML_ERROR_NONE; |
| 21930 | 4697 } |
| 4698 return XML_ERROR_UNCLOSED_TOKEN; | |
| 4699 case XML_TOK_PARTIAL_CHAR: | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4700 if (!ps_finalBuffer) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4701 *nextPtr = s; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4702 return XML_ERROR_NONE; |
| 21930 | 4703 } |
| 4704 return XML_ERROR_PARTIAL_CHAR; | |
| 4705 default: | |
| 4706 return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | |
| 4707 } | |
| 4708 eventPtr = s = next; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4709 switch (ps_parsing) { |
| 32911 | 4710 case XML_SUSPENDED: |
| 4711 *nextPtr = next; | |
| 4712 return XML_ERROR_NONE; | |
| 4713 case XML_FINISHED: | |
| 4714 return XML_ERROR_ABORTED; | |
| 4715 default: ; | |
| 4716 } | |
| 21930 | 4717 } |
| 4718 } | |
| 4719 | |
| 4720 static enum XML_Error | |
| 32911 | 4721 processInternalEntity(XML_Parser parser, ENTITY *entity, |
| 4722 XML_Bool betweenDecl) | |
| 21930 | 4723 { |
| 32911 | 4724 const char *textStart, *textEnd; |
| 4725 const char *next; | |
| 21930 | 4726 enum XML_Error result; |
| 32911 | 4727 OPEN_INTERNAL_ENTITY *openEntity; |
| 4728 | |
| 4729 if (freeInternalEntities) { | |
| 4730 openEntity = freeInternalEntities; | |
| 4731 freeInternalEntities = openEntity->next; | |
| 4732 } | |
| 4733 else { | |
| 4734 openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); | |
| 4735 if (!openEntity) | |
| 4736 return XML_ERROR_NO_MEMORY; | |
| 4737 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4738 entity->open = XML_TRUE; |
| 32911 | 4739 entity->processed = 0; |
| 4740 openEntity->next = openInternalEntities; | |
| 4741 openInternalEntities = openEntity; | |
| 4742 openEntity->entity = entity; | |
| 4743 openEntity->startTagLevel = tagLevel; | |
| 4744 openEntity->betweenDecl = betweenDecl; | |
| 4745 openEntity->internalEventPtr = NULL; | |
| 4746 openEntity->internalEventEndPtr = NULL; | |
| 4747 textStart = (char *)entity->textPtr; | |
| 4748 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4749 | |
| 4750 #ifdef XML_DTD | |
| 4751 if (entity->is_param) { | |
| 4752 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4753 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4754 next, &next, XML_FALSE); | |
| 4755 } | |
| 4756 else | |
| 4757 #endif /* XML_DTD */ | |
| 4758 result = doContent(parser, tagLevel, internalEncoding, textStart, | |
| 4759 textEnd, &next, XML_FALSE); | |
| 4760 | |
| 4761 if (result == XML_ERROR_NONE) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4762 if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4763 entity->processed = (int)(next - textStart); |
| 32911 | 4764 processor = internalEntityProcessor; |
| 4765 } | |
| 4766 else { | |
| 4767 entity->open = XML_FALSE; | |
| 4768 openInternalEntities = openEntity->next; | |
| 4769 /* put openEntity back in list of free instances */ | |
| 4770 openEntity->next = freeInternalEntities; | |
| 4771 freeInternalEntities = openEntity; | |
| 4772 } | |
| 4773 } | |
| 21930 | 4774 return result; |
| 4775 } | |
| 4776 | |
| 32911 | 4777 static enum XML_Error PTRCALL |
| 4778 internalEntityProcessor(XML_Parser parser, | |
| 4779 const char *s, | |
| 4780 const char *end, | |
| 4781 const char **nextPtr) | |
| 4782 { | |
| 4783 ENTITY *entity; | |
| 4784 const char *textStart, *textEnd; | |
| 4785 const char *next; | |
| 4786 enum XML_Error result; | |
| 4787 OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; | |
| 4788 if (!openEntity) | |
| 4789 return XML_ERROR_UNEXPECTED_STATE; | |
| 4790 | |
| 4791 entity = openEntity->entity; | |
| 4792 textStart = ((char *)entity->textPtr) + entity->processed; | |
| 4793 textEnd = (char *)(entity->textPtr + entity->textLen); | |
| 4794 | |
| 4795 #ifdef XML_DTD | |
| 4796 if (entity->is_param) { | |
| 4797 int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | |
| 4798 result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | |
| 4799 next, &next, XML_FALSE); | |
| 4800 } | |
| 4801 else | |
| 21930 | 4802 #endif /* XML_DTD */ |
| 32911 | 4803 result = doContent(parser, openEntity->startTagLevel, internalEncoding, |
| 4804 textStart, textEnd, &next, XML_FALSE); | |
| 4805 | |
| 4806 if (result != XML_ERROR_NONE) | |
| 4807 return result; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4808 else if (textEnd != next && ps_parsing == XML_SUSPENDED) { |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4809 entity->processed = (int)(next - (char *)entity->textPtr); |
| 32911 | 4810 return result; |
| 4811 } | |
| 4812 else { | |
| 4813 entity->open = XML_FALSE; | |
| 4814 openInternalEntities = openEntity->next; | |
| 4815 /* put openEntity back in list of free instances */ | |
| 4816 openEntity->next = freeInternalEntities; | |
| 4817 freeInternalEntities = openEntity; | |
| 4818 } | |
| 4819 | |
| 4820 #ifdef XML_DTD | |
| 4821 if (entity->is_param) { | |
| 4822 int tok; | |
| 4823 processor = prologProcessor; | |
| 4824 tok = XmlPrologTok(encoding, s, end, &next); | |
| 4825 return doProlog(parser, encoding, s, end, tok, next, nextPtr, | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4826 (XML_Bool)!ps_finalBuffer); |
| 32911 | 4827 } |
| 4828 else | |
| 4829 #endif /* XML_DTD */ | |
| 4830 { | |
| 4831 processor = contentProcessor; | |
| 4832 /* see externalEntityContentProcessor vs contentProcessor */ | |
| 4833 return doContent(parser, parentParser ? 1 : 0, encoding, s, end, | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4834 nextPtr, (XML_Bool)!ps_finalBuffer); |
| 32911 | 4835 } |
| 4836 } | |
| 21930 | 4837 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4838 static enum XML_Error PTRCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4839 errorProcessor(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4840 const char *s, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4841 const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4842 const char **nextPtr) |
| 21930 | 4843 { |
| 4844 return errorCode; | |
| 4845 } | |
| 4846 | |
| 4847 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4848 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
|
4849 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4850 STRING_POOL *pool) |
| 21930 | 4851 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4852 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
|
4853 end, pool); |
| 21930 | 4854 if (result) |
| 4855 return result; | |
| 4856 if (!isCdata && poolLength(pool) && poolLastChar(pool) == 0x20) | |
| 4857 poolChop(pool); | |
| 4858 if (!poolAppendChar(pool, XML_T('\0'))) | |
| 4859 return XML_ERROR_NO_MEMORY; | |
| 4860 return XML_ERROR_NONE; | |
| 4861 } | |
| 4862 | |
| 4863 static enum XML_Error | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4864 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
|
4865 const char *ptr, const char *end, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4866 STRING_POOL *pool) |
| 21930 | 4867 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4868 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 4869 for (;;) { |
| 4870 const char *next; | |
| 4871 int tok = XmlAttributeValueTok(enc, ptr, end, &next); | |
| 4872 switch (tok) { | |
| 4873 case XML_TOK_NONE: | |
| 4874 return XML_ERROR_NONE; | |
| 4875 case XML_TOK_INVALID: | |
| 4876 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4877 eventPtr = next; |
| 21930 | 4878 return XML_ERROR_INVALID_TOKEN; |
| 4879 case XML_TOK_PARTIAL: | |
| 4880 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4881 eventPtr = ptr; |
| 21930 | 4882 return XML_ERROR_INVALID_TOKEN; |
| 4883 case XML_TOK_CHAR_REF: | |
| 4884 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4885 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4886 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4887 int n = XmlCharRefNumber(enc, ptr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4888 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4889 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4890 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4891 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4892 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4893 if (!isCdata |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4894 && n == 0x20 /* space */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4895 && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4896 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4897 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4898 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4899 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4900 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4901 return XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4902 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4903 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4904 if (!poolAppendChar(pool, buf[i])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4905 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4906 } |
| 21930 | 4907 } |
| 4908 break; | |
| 4909 case XML_TOK_DATA_CHARS: | |
| 4910 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
|
4911 return XML_ERROR_NO_MEMORY; |
| 21930 | 4912 break; |
| 4913 case XML_TOK_TRAILING_CR: | |
| 4914 next = ptr + enc->minBytesPerChar; | |
| 4915 /* fall through */ | |
| 4916 case XML_TOK_ATTRIBUTE_VALUE_S: | |
| 4917 case XML_TOK_DATA_NEWLINE: | |
| 4918 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
|
4919 break; |
| 21930 | 4920 if (!poolAppendChar(pool, 0x20)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4921 return XML_ERROR_NO_MEMORY; |
| 21930 | 4922 break; |
| 4923 case XML_TOK_ENTITY_REF: | |
| 4924 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4925 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4926 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4927 char checkEntityDecl; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4928 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
|
4929 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4930 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4931 if (ch) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4932 if (!poolAppendChar(pool, ch)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4933 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4934 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4935 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4936 name = poolStoreString(&temp2Pool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4937 ptr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4938 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4939 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4940 return XML_ERROR_NO_MEMORY; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
4941 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
|
4942 poolDiscard(&temp2Pool); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4943 /* First, determine if a check for an existing declaration is needed; |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4944 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
|
4945 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4946 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
|
4947 checkEntityDecl = |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4948 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4949 prologState.documentEntity && |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4950 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4951 (dtd->standalone |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4952 ? !openInternalEntities |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4953 : !dtd->hasParamEntityRefs); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4954 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
|
4955 checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4956 if (checkEntityDecl) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4957 if (!entity) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4958 return XML_ERROR_UNDEFINED_ENTITY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4959 else if (!entity->is_internal) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4960 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
|
4961 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4962 else if (!entity) { |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4963 /* Cannot report skipped entity here - see comments on |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4964 skippedEntityHandler. |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4965 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4966 skippedEntityHandler(handlerArg, name, 0); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4967 */ |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4968 /* Cannot call the default handler because this would be |
|
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4969 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
|
4970 if ((pool == &tempPool) && defaultHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4971 reportDefault(parser, enc, ptr, next); |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
4972 */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4973 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4974 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4975 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4976 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4977 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4978 return XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4979 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4980 if (entity->notation) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4981 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4982 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4983 return XML_ERROR_BINARY_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4984 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4985 if (!entity->textPtr) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4986 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4987 eventPtr = ptr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4988 return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4989 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4990 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4991 enum XML_Error result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4992 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
|
4993 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4994 result = appendAttributeValue(parser, internalEncoding, isCdata, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4995 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4996 (char *)textEnd, pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4997 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4998 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
4999 return result; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5000 } |
| 21930 | 5001 } |
| 5002 break; | |
| 5003 default: | |
| 5004 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5005 eventPtr = ptr; |
| 21930 | 5006 return XML_ERROR_UNEXPECTED_STATE; |
| 5007 } | |
| 5008 ptr = next; | |
| 5009 } | |
| 5010 /* not reached */ | |
| 5011 } | |
| 5012 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5013 static enum XML_Error |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5014 storeEntityValue(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5015 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5016 const char *entityTextPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5017 const char *entityTextEnd) |
| 21930 | 5018 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5019 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
|
5020 STRING_POOL *pool = &(dtd->entityValuePool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5021 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
|
5022 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5023 int oldInEntityValue = prologState.inEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5024 prologState.inEntityValue = 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5025 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5026 /* 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
|
5027 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
|
5028 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
|
5029 if (!pool->blocks) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5030 if (!poolGrow(pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5031 return XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5032 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5033 |
| 21930 | 5034 for (;;) { |
| 5035 const char *next; | |
| 5036 int tok = XmlEntityValueTok(enc, entityTextPtr, entityTextEnd, &next); | |
| 5037 switch (tok) { | |
| 5038 case XML_TOK_PARAM_ENTITY_REF: | |
| 5039 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5040 if (isParamEntity || enc != encoding) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5041 const XML_Char *name; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5042 ENTITY *entity; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5043 name = poolStoreString(&tempPool, enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5044 entityTextPtr + enc->minBytesPerChar, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5045 next - enc->minBytesPerChar); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5046 if (!name) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5047 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5048 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5049 } |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5050 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
|
5051 poolDiscard(&tempPool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5052 if (!entity) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5053 /* 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
|
5054 /* 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
|
5055 skippedEntityHandler |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5056 if (skippedEntityHandler) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5057 skippedEntityHandler(handlerArg, name, 0); |
|
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 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5060 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5061 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5062 if (entity->open) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5063 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5064 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5065 result = XML_ERROR_RECURSIVE_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5066 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5067 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5068 if (entity->systemId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5069 if (externalEntityRefHandler) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5070 dtd->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5071 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5072 if (!externalEntityRefHandler(externalEntityRefHandlerArg, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5073 0, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5074 entity->base, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5075 entity->systemId, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5076 entity->publicId)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5077 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5078 result = XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5079 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5080 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5081 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5082 if (!dtd->paramEntityRead) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5083 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5084 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5085 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5086 dtd->keepProcessing = dtd->standalone; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5087 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5088 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5089 entity->open = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5090 result = storeEntityValue(parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5091 internalEncoding, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5092 (char *)entity->textPtr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5093 (char *)(entity->textPtr |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5094 + entity->textLen)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5095 entity->open = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5096 if (result) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5097 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5098 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5099 break; |
| 21930 | 5100 } |
| 5101 #endif /* XML_DTD */ | |
| 32911 | 5102 /* In the internal subset, PE references are not legal |
| 5103 within markup declarations, e.g entity values in this case. */ | |
| 21930 | 5104 eventPtr = entityTextPtr; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5105 result = XML_ERROR_PARAM_ENTITY_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5106 goto endEntityValue; |
| 21930 | 5107 case XML_TOK_NONE: |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5108 result = XML_ERROR_NONE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5109 goto endEntityValue; |
| 21930 | 5110 case XML_TOK_ENTITY_REF: |
| 5111 case XML_TOK_DATA_CHARS: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5112 if (!poolAppend(pool, enc, entityTextPtr, next)) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5113 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5114 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5115 } |
| 21930 | 5116 break; |
| 5117 case XML_TOK_TRAILING_CR: | |
| 5118 next = entityTextPtr + enc->minBytesPerChar; | |
| 5119 /* fall through */ | |
| 5120 case XML_TOK_DATA_NEWLINE: | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5121 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
|
5122 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5123 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5124 } |
| 21930 | 5125 *(pool->ptr)++ = 0xA; |
| 5126 break; | |
| 5127 case XML_TOK_CHAR_REF: | |
| 5128 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5129 XML_Char buf[XML_ENCODE_MAX]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5130 int i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5131 int n = XmlCharRefNumber(enc, entityTextPtr); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5132 if (n < 0) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5133 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5134 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5135 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5136 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5137 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5138 n = XmlEncode(n, (ICHAR *)buf); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5139 if (!n) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5140 if (enc == encoding) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5141 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5142 result = XML_ERROR_BAD_CHAR_REF; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5143 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5144 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5145 for (i = 0; i < n; i++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5146 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
|
5147 result = XML_ERROR_NO_MEMORY; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5148 goto endEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5149 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5150 *(pool->ptr)++ = buf[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5151 } |
| 21930 | 5152 } |
| 5153 break; | |
| 5154 case XML_TOK_PARTIAL: | |
| 5155 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5156 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5157 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5158 goto endEntityValue; |
| 21930 | 5159 case XML_TOK_INVALID: |
| 5160 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5161 eventPtr = next; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5162 result = XML_ERROR_INVALID_TOKEN; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5163 goto endEntityValue; |
| 21930 | 5164 default: |
| 5165 if (enc == encoding) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5166 eventPtr = entityTextPtr; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5167 result = XML_ERROR_UNEXPECTED_STATE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5168 goto endEntityValue; |
| 21930 | 5169 } |
| 5170 entityTextPtr = next; | |
| 5171 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5172 endEntityValue: |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5173 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5174 prologState.inEntityValue = oldInEntityValue; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5175 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5176 return result; |
| 21930 | 5177 } |
| 5178 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5179 static void FASTCALL |
| 21930 | 5180 normalizeLines(XML_Char *s) |
| 5181 { | |
| 5182 XML_Char *p; | |
| 5183 for (;; s++) { | |
| 5184 if (*s == XML_T('\0')) | |
| 5185 return; | |
| 5186 if (*s == 0xD) | |
| 5187 break; | |
| 5188 } | |
| 5189 p = s; | |
| 5190 do { | |
| 5191 if (*s == 0xD) { | |
| 5192 *p++ = 0xA; | |
| 5193 if (*++s == 0xA) | |
| 5194 s++; | |
| 5195 } | |
| 5196 else | |
| 5197 *p++ = *s++; | |
| 5198 } while (*s); | |
| 5199 *p = XML_T('\0'); | |
| 5200 } | |
| 5201 | |
| 5202 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5203 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
|
5204 const char *start, const char *end) |
| 21930 | 5205 { |
| 5206 const XML_Char *target; | |
| 5207 XML_Char *data; | |
| 5208 const char *tem; | |
| 5209 if (!processingInstructionHandler) { | |
| 5210 if (defaultHandler) | |
| 5211 reportDefault(parser, enc, start, end); | |
| 5212 return 1; | |
| 5213 } | |
| 5214 start += enc->minBytesPerChar * 2; | |
| 5215 tem = start + XmlNameLength(enc, start); | |
| 5216 target = poolStoreString(&tempPool, enc, start, tem); | |
| 5217 if (!target) | |
| 5218 return 0; | |
| 5219 poolFinish(&tempPool); | |
| 5220 data = poolStoreString(&tempPool, enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5221 XmlSkipS(enc, tem), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5222 end - enc->minBytesPerChar*2); |
| 21930 | 5223 if (!data) |
| 5224 return 0; | |
| 5225 normalizeLines(data); | |
| 5226 processingInstructionHandler(handlerArg, target, data); | |
| 5227 poolClear(&tempPool); | |
| 5228 return 1; | |
| 5229 } | |
| 5230 | |
| 5231 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5232 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
|
5233 const char *start, const char *end) |
| 21930 | 5234 { |
| 5235 XML_Char *data; | |
| 5236 if (!commentHandler) { | |
| 5237 if (defaultHandler) | |
| 5238 reportDefault(parser, enc, start, end); | |
| 5239 return 1; | |
| 5240 } | |
| 5241 data = poolStoreString(&tempPool, | |
| 5242 enc, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5243 start + enc->minBytesPerChar * 4, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5244 end - enc->minBytesPerChar * 3); |
| 21930 | 5245 if (!data) |
| 5246 return 0; | |
| 5247 normalizeLines(data); | |
| 5248 commentHandler(handlerArg, data); | |
| 5249 poolClear(&tempPool); | |
| 5250 return 1; | |
| 5251 } | |
| 5252 | |
| 5253 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5254 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
|
5255 const char *s, const char *end) |
| 21930 | 5256 { |
| 5257 if (MUST_CONVERT(enc, s)) { | |
| 5258 const char **eventPP; | |
| 5259 const char **eventEndPP; | |
| 5260 if (enc == encoding) { | |
| 5261 eventPP = &eventPtr; | |
| 5262 eventEndPP = &eventEndPtr; | |
| 5263 } | |
| 5264 else { | |
| 5265 eventPP = &(openInternalEntities->internalEventPtr); | |
| 5266 eventEndPP = &(openInternalEntities->internalEventEndPtr); | |
| 5267 } | |
| 5268 do { | |
| 5269 ICHAR *dataPtr = (ICHAR *)dataBuf; | |
| 5270 XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | |
| 5271 *eventEndPP = s; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5272 defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); |
| 21930 | 5273 *eventPP = s; |
| 5274 } while (s != end); | |
| 5275 } | |
| 5276 else | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5277 defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); |
| 21930 | 5278 } |
| 5279 | |
| 5280 | |
| 5281 static int | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5282 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
|
5283 XML_Bool isId, const XML_Char *value, XML_Parser parser) |
| 21930 | 5284 { |
| 5285 DEFAULT_ATTRIBUTE *att; | |
| 5286 if (value || isId) { | |
| 5287 /* The handling of default attributes gets messed up if we have | |
| 5288 a default which duplicates a non-default. */ | |
| 5289 int i; | |
| 5290 for (i = 0; i < type->nDefaultAtts; i++) | |
| 5291 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
|
5292 return 1; |
| 21930 | 5293 if (isId && !type->idAtt && !attId->xmlns) |
| 5294 type->idAtt = attId; | |
| 5295 } | |
| 5296 if (type->nDefaultAtts == type->allocDefaultAtts) { | |
| 5297 if (type->allocDefaultAtts == 0) { | |
| 5298 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
|
5299 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
|
5300 * sizeof(DEFAULT_ATTRIBUTE)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5301 if (!type->defaultAtts) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5302 return 0; |
| 21930 | 5303 } |
| 5304 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5305 DEFAULT_ATTRIBUTE *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5306 int count = type->allocDefaultAtts * 2; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5307 temp = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5308 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
|
5309 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5310 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5311 type->allocDefaultAtts = count; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5312 type->defaultAtts = temp; |
| 21930 | 5313 } |
| 5314 } | |
| 5315 att = type->defaultAtts + type->nDefaultAtts; | |
| 5316 att->id = attId; | |
| 5317 att->value = value; | |
| 5318 att->isCdata = isCdata; | |
| 5319 if (!isCdata) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5320 attId->maybeTokenized = XML_TRUE; |
| 21930 | 5321 type->nDefaultAtts += 1; |
| 5322 return 1; | |
| 5323 } | |
| 5324 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5325 static int |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5326 setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 21930 | 5327 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5328 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5329 const XML_Char *name; |
| 5330 for (name = elementType->name; *name; name++) { | |
| 5331 if (*name == XML_T(':')) { | |
| 5332 PREFIX *prefix; | |
| 5333 const XML_Char *s; | |
| 5334 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
|
5335 if (!poolAppendChar(&dtd->pool, *s)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5336 return 0; |
| 21930 | 5337 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5338 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
|
5339 return 0; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5340 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
|
5341 sizeof(PREFIX)); |
| 21930 | 5342 if (!prefix) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5343 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5344 if (prefix->name == poolStart(&dtd->pool)) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5345 poolFinish(&dtd->pool); |
| 21930 | 5346 else |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5347 poolDiscard(&dtd->pool); |
| 21930 | 5348 elementType->prefix = prefix; |
| 5349 | |
| 5350 } | |
| 5351 } | |
| 5352 return 1; | |
| 5353 } | |
| 5354 | |
| 5355 static ATTRIBUTE_ID * | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5356 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
|
5357 const char *start, const char *end) |
| 21930 | 5358 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5359 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5360 ATTRIBUTE_ID *id; |
| 5361 const XML_Char *name; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5362 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
|
5363 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5364 name = poolStoreString(&dtd->pool, enc, start, end); |
| 21930 | 5365 if (!name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5366 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
|
5367 /* skip quotation mark - its storage will be re-used (like in name[-1]) */ |
| 21930 | 5368 ++name; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5369 id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, name, sizeof(ATTRIBUTE_ID)); |
| 21930 | 5370 if (!id) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5371 return NULL; |
| 21930 | 5372 if (id->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5373 poolDiscard(&dtd->pool); |
| 21930 | 5374 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5375 poolFinish(&dtd->pool); |
| 21930 | 5376 if (!ns) |
| 5377 ; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5378 else if (name[0] == XML_T('x') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5379 && name[1] == XML_T('m') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5380 && name[2] == XML_T('l') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5381 && name[3] == XML_T('n') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5382 && name[4] == XML_T('s') |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5383 && (name[5] == XML_T('\0') || name[5] == XML_T(':'))) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5384 if (name[5] == XML_T('\0')) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5385 id->prefix = &dtd->defaultPrefix; |
| 21930 | 5386 else |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5387 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
|
5388 id->xmlns = XML_TRUE; |
| 21930 | 5389 } |
| 5390 else { | |
| 5391 int i; | |
| 5392 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
|
5393 /* attributes without prefix are *not* in the default namespace */ |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5394 if (name[i] == XML_T(':')) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5395 int j; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5396 for (j = 0; j < i; j++) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5397 if (!poolAppendChar(&dtd->pool, name[j])) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5398 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5399 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5400 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
|
5401 return NULL; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5402 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
|
5403 sizeof(PREFIX)); |
|
39473
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5404 if (!id->prefix) |
|
bc74afb8e4ef
Handle failures from lookup.
Neal Norwitz <nnorwitz@gmail.com>
parents:
39009
diff
changeset
|
5405 return NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5406 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
|
5407 poolFinish(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5408 else |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5409 poolDiscard(&dtd->pool); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5410 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5411 } |
| 21930 | 5412 } |
| 5413 } | |
| 5414 } | |
| 5415 return id; | |
| 5416 } | |
| 5417 | |
| 5418 #define CONTEXT_SEP XML_T('\f') | |
| 5419 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5420 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5421 getContext(XML_Parser parser) |
| 21930 | 5422 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5423 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5424 HASH_TABLE_ITER iter; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5425 XML_Bool needSep = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5426 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5427 if (dtd->defaultPrefix.binding) { |
| 21930 | 5428 int i; |
| 5429 int len; | |
| 5430 if (!poolAppendChar(&tempPool, XML_T('='))) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5431 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5432 len = dtd->defaultPrefix.binding->uriLen; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5433 if (namespaceSeparator) |
| 21930 | 5434 len--; |
| 5435 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
|
5436 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
|
5437 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5438 needSep = XML_TRUE; |
| 21930 | 5439 } |
| 5440 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5441 hashTableIterInit(&iter, &(dtd->prefixes)); |
| 21930 | 5442 for (;;) { |
| 5443 int i; | |
| 5444 int len; | |
| 5445 const XML_Char *s; | |
| 5446 PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | |
| 5447 if (!prefix) | |
| 5448 break; | |
| 5449 if (!prefix->binding) | |
| 5450 continue; | |
| 5451 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
|
5452 return NULL; |
| 21930 | 5453 for (s = prefix->name; *s; s++) |
| 5454 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5455 return NULL; |
| 21930 | 5456 if (!poolAppendChar(&tempPool, XML_T('='))) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5457 return NULL; |
| 21930 | 5458 len = prefix->binding->uriLen; |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
5459 if (namespaceSeparator) |
| 21930 | 5460 len--; |
| 5461 for (i = 0; i < len; i++) | |
| 5462 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
|
5463 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5464 needSep = XML_TRUE; |
| 21930 | 5465 } |
| 5466 | |
| 5467 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5468 hashTableIterInit(&iter, &(dtd->generalEntities)); |
| 21930 | 5469 for (;;) { |
| 5470 const XML_Char *s; | |
| 5471 ENTITY *e = (ENTITY *)hashTableIterNext(&iter); | |
| 5472 if (!e) | |
| 5473 break; | |
| 5474 if (!e->open) | |
| 5475 continue; | |
| 5476 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
|
5477 return NULL; |
| 21930 | 5478 for (s = e->name; *s; s++) |
| 5479 if (!poolAppendChar(&tempPool, *s)) | |
| 5480 return 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5481 needSep = XML_TRUE; |
| 21930 | 5482 } |
| 5483 | |
| 5484 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
|
5485 return NULL; |
| 21930 | 5486 return tempPool.start; |
| 5487 } | |
| 5488 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5489 static XML_Bool |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5490 setContext(XML_Parser parser, const XML_Char *context) |
| 21930 | 5491 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5492 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 5493 const XML_Char *s = context; |
| 5494 | |
| 5495 while (*context != XML_T('\0')) { | |
| 5496 if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | |
| 5497 ENTITY *e; | |
| 5498 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
|
5499 return XML_FALSE; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5500 e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0); |
| 21930 | 5501 if (e) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5502 e->open = XML_TRUE; |
| 21930 | 5503 if (*s != XML_T('\0')) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5504 s++; |
| 21930 | 5505 context = s; |
| 5506 poolDiscard(&tempPool); | |
| 5507 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5508 else if (*s == XML_T('=')) { |
| 21930 | 5509 PREFIX *prefix; |
| 5510 if (poolLength(&tempPool) == 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5511 prefix = &dtd->defaultPrefix; |
| 21930 | 5512 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5513 if (!poolAppendChar(&tempPool, XML_T('\0'))) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5514 return XML_FALSE; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5515 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
|
5516 sizeof(PREFIX)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5517 if (!prefix) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5518 return XML_FALSE; |
| 21930 | 5519 if (prefix->name == poolStart(&tempPool)) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5520 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
|
5521 if (!prefix->name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5522 return XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5523 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5524 poolDiscard(&tempPool); |
| 21930 | 5525 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5526 for (context = s + 1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5527 *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
|
5528 context++) |
| 21930 | 5529 if (!poolAppendChar(&tempPool, *context)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5530 return XML_FALSE; |
| 21930 | 5531 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
|
5532 return XML_FALSE; |
| 32911 | 5533 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
|
5534 &inheritedBindings) != XML_ERROR_NONE) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5535 return XML_FALSE; |
| 21930 | 5536 poolDiscard(&tempPool); |
| 5537 if (*context != XML_T('\0')) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5538 ++context; |
| 21930 | 5539 s = context; |
| 5540 } | |
| 5541 else { | |
| 5542 if (!poolAppendChar(&tempPool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5543 return XML_FALSE; |
| 21930 | 5544 s++; |
| 5545 } | |
| 5546 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5547 return XML_TRUE; |
| 21930 | 5548 } |
| 5549 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5550 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5551 normalizePublicId(XML_Char *publicId) |
| 21930 | 5552 { |
| 5553 XML_Char *p = publicId; | |
| 5554 XML_Char *s; | |
| 5555 for (s = publicId; *s; s++) { | |
| 5556 switch (*s) { | |
| 5557 case 0x20: | |
| 5558 case 0xD: | |
| 5559 case 0xA: | |
| 5560 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
|
5561 *p++ = 0x20; |
| 21930 | 5562 break; |
| 5563 default: | |
| 5564 *p++ = *s; | |
| 5565 } | |
| 5566 } | |
| 5567 if (p != publicId && p[-1] == 0x20) | |
| 5568 --p; | |
| 5569 *p = XML_T('\0'); | |
| 5570 } | |
| 5571 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5572 static DTD * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5573 dtdCreate(const XML_Memory_Handling_Suite *ms) |
| 21930 | 5574 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5575 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
|
5576 if (p == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5577 return p; |
| 21930 | 5578 poolInit(&(p->pool), ms); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5579 poolInit(&(p->entityValuePool), ms); |
| 21930 | 5580 hashTableInit(&(p->generalEntities), ms); |
| 5581 hashTableInit(&(p->elementTypes), ms); | |
| 5582 hashTableInit(&(p->attributeIds), ms); | |
| 5583 hashTableInit(&(p->prefixes), ms); | |
| 5584 #ifdef XML_DTD | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5585 p->paramEntityRead = XML_FALSE; |
| 21930 | 5586 hashTableInit(&(p->paramEntities), ms); |
| 5587 #endif /* XML_DTD */ | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5588 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5589 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5590 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5591 p->in_eldecl = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5592 p->scaffIndex = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5593 p->scaffold = NULL; |
| 21930 | 5594 p->scaffLevel = 0; |
| 5595 p->scaffSize = 0; | |
| 5596 p->scaffCount = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5597 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5598 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5599 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5600 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5601 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5602 return p; |
| 21930 | 5603 } |
| 5604 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5605 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5606 dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5607 { |
| 5608 HASH_TABLE_ITER iter; | |
| 5609 hashTableIterInit(&iter, &(p->elementTypes)); | |
| 5610 for (;;) { | |
| 5611 ELEMENT_TYPE *e = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5612 if (!e) | |
| 5613 break; | |
| 5614 if (e->allocDefaultAtts != 0) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5615 ms->free_fcn(e->defaultAtts); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5616 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5617 hashTableClear(&(p->generalEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5618 #ifdef XML_DTD |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5619 p->paramEntityRead = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5620 hashTableClear(&(p->paramEntities)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5621 #endif /* XML_DTD */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5622 hashTableClear(&(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5623 hashTableClear(&(p->attributeIds)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5624 hashTableClear(&(p->prefixes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5625 poolClear(&(p->pool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5626 poolClear(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5627 p->defaultPrefix.name = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5628 p->defaultPrefix.binding = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5629 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5630 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
|
5631 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5632 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
|
5633 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
|
5634 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
|
5635 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
|
5636 |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5637 p->scaffLevel = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5638 p->scaffSize = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5639 p->scaffCount = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5640 p->contentStringLen = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5641 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5642 p->keepProcessing = XML_TRUE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5643 p->hasParamEntityRefs = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5644 p->standalone = XML_FALSE; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5645 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5646 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5647 static void |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5648 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
|
5649 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5650 HASH_TABLE_ITER iter; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5651 hashTableIterInit(&iter, &(p->elementTypes)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5652 for (;;) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5653 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
|
5654 if (!e) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5655 break; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5656 if (e->allocDefaultAtts != 0) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5657 ms->free_fcn(e->defaultAtts); |
| 21930 | 5658 } |
| 5659 hashTableDestroy(&(p->generalEntities)); | |
| 5660 #ifdef XML_DTD | |
| 5661 hashTableDestroy(&(p->paramEntities)); | |
| 5662 #endif /* XML_DTD */ | |
| 5663 hashTableDestroy(&(p->elementTypes)); | |
| 5664 hashTableDestroy(&(p->attributeIds)); | |
| 5665 hashTableDestroy(&(p->prefixes)); | |
| 5666 poolDestroy(&(p->pool)); | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5667 poolDestroy(&(p->entityValuePool)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5668 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
|
5669 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
|
5670 ms->free_fcn(p->scaffold); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5671 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5672 ms->free_fcn(p); |
| 21930 | 5673 } |
| 5674 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5675 /* 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
|
5676 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
|
5677 */ |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5678 static int |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5679 dtdCopy(XML_Parser oldParser, DTD *newDtd, const DTD *oldDtd, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5680 { |
| 5681 HASH_TABLE_ITER iter; | |
| 5682 | |
| 5683 /* Copy the prefix table. */ | |
| 5684 | |
| 5685 hashTableIterInit(&iter, &(oldDtd->prefixes)); | |
| 5686 for (;;) { | |
| 5687 const XML_Char *name; | |
| 5688 const PREFIX *oldP = (PREFIX *)hashTableIterNext(&iter); | |
| 5689 if (!oldP) | |
| 5690 break; | |
| 5691 name = poolCopyString(&(newDtd->pool), oldP->name); | |
| 5692 if (!name) | |
| 5693 return 0; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5694 if (!lookup(oldParser, &(newDtd->prefixes), name, sizeof(PREFIX))) |
| 21930 | 5695 return 0; |
| 5696 } | |
| 5697 | |
| 5698 hashTableIterInit(&iter, &(oldDtd->attributeIds)); | |
| 5699 | |
| 5700 /* Copy the attribute id table. */ | |
| 5701 | |
| 5702 for (;;) { | |
| 5703 ATTRIBUTE_ID *newA; | |
| 5704 const XML_Char *name; | |
| 5705 const ATTRIBUTE_ID *oldA = (ATTRIBUTE_ID *)hashTableIterNext(&iter); | |
| 5706 | |
| 5707 if (!oldA) | |
| 5708 break; | |
| 5709 /* Remember to allocate the scratch byte before the name. */ | |
| 5710 if (!poolAppendChar(&(newDtd->pool), XML_T('\0'))) | |
| 5711 return 0; | |
| 5712 name = poolCopyString(&(newDtd->pool), oldA->name); | |
| 5713 if (!name) | |
| 5714 return 0; | |
| 5715 ++name; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5716 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
|
5717 sizeof(ATTRIBUTE_ID)); |
| 21930 | 5718 if (!newA) |
| 5719 return 0; | |
| 5720 newA->maybeTokenized = oldA->maybeTokenized; | |
| 5721 if (oldA->prefix) { | |
| 5722 newA->xmlns = oldA->xmlns; | |
| 5723 if (oldA->prefix == &oldDtd->defaultPrefix) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5724 newA->prefix = &newDtd->defaultPrefix; |
| 21930 | 5725 else |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5726 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
|
5727 oldA->prefix->name, 0); |
| 21930 | 5728 } |
| 5729 } | |
| 5730 | |
| 5731 /* Copy the element type table. */ | |
| 5732 | |
| 5733 hashTableIterInit(&iter, &(oldDtd->elementTypes)); | |
| 5734 | |
| 5735 for (;;) { | |
| 5736 int i; | |
| 5737 ELEMENT_TYPE *newE; | |
| 5738 const XML_Char *name; | |
| 5739 const ELEMENT_TYPE *oldE = (ELEMENT_TYPE *)hashTableIterNext(&iter); | |
| 5740 if (!oldE) | |
| 5741 break; | |
| 5742 name = poolCopyString(&(newDtd->pool), oldE->name); | |
| 5743 if (!name) | |
| 5744 return 0; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5745 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
|
5746 sizeof(ELEMENT_TYPE)); |
| 21930 | 5747 if (!newE) |
| 5748 return 0; | |
| 5749 if (oldE->nDefaultAtts) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5750 newE->defaultAtts = (DEFAULT_ATTRIBUTE *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5751 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
|
5752 if (!newE->defaultAtts) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5753 ms->free_fcn(newE); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5754 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5755 } |
| 21930 | 5756 } |
| 5757 if (oldE->idAtt) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5758 newE->idAtt = (ATTRIBUTE_ID *) |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5759 lookup(oldParser, &(newDtd->attributeIds), oldE->idAtt->name, 0); |
| 21930 | 5760 newE->allocDefaultAtts = newE->nDefaultAtts = oldE->nDefaultAtts; |
| 5761 if (oldE->prefix) | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5762 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
|
5763 oldE->prefix->name, 0); |
| 21930 | 5764 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
|
5765 newE->defaultAtts[i].id = (ATTRIBUTE_ID *) |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5766 lookup(oldParser, &(newDtd->attributeIds), oldE->defaultAtts[i].id->name, 0); |
| 21930 | 5767 newE->defaultAtts[i].isCdata = oldE->defaultAtts[i].isCdata; |
| 5768 if (oldE->defaultAtts[i].value) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5769 newE->defaultAtts[i].value |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5770 = 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
|
5771 if (!newE->defaultAtts[i].value) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5772 return 0; |
| 21930 | 5773 } |
| 5774 else | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5775 newE->defaultAtts[i].value = NULL; |
| 21930 | 5776 } |
| 5777 } | |
| 5778 | |
| 5779 /* Copy the entity tables. */ | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5780 if (!copyEntityTable(oldParser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5781 &(newDtd->generalEntities), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5782 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5783 &(oldDtd->generalEntities))) |
| 21930 | 5784 return 0; |
| 5785 | |
| 5786 #ifdef XML_DTD | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5787 if (!copyEntityTable(oldParser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5788 &(newDtd->paramEntities), |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5789 &(newDtd->pool), |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5790 &(oldDtd->paramEntities))) |
| 21930 | 5791 return 0; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5792 newDtd->paramEntityRead = oldDtd->paramEntityRead; |
| 21930 | 5793 #endif /* XML_DTD */ |
| 5794 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5795 newDtd->keepProcessing = oldDtd->keepProcessing; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5796 newDtd->hasParamEntityRefs = oldDtd->hasParamEntityRefs; |
| 21930 | 5797 newDtd->standalone = oldDtd->standalone; |
| 5798 | |
| 5799 /* Don't want deep copying for scaffolding */ | |
| 5800 newDtd->in_eldecl = oldDtd->in_eldecl; | |
| 5801 newDtd->scaffold = oldDtd->scaffold; | |
| 5802 newDtd->contentStringLen = oldDtd->contentStringLen; | |
| 5803 newDtd->scaffSize = oldDtd->scaffSize; | |
| 5804 newDtd->scaffLevel = oldDtd->scaffLevel; | |
| 5805 newDtd->scaffIndex = oldDtd->scaffIndex; | |
| 5806 | |
| 5807 return 1; | |
| 5808 } /* End dtdCopy */ | |
| 5809 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5810 static int |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5811 copyEntityTable(XML_Parser oldParser, |
|
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5812 HASH_TABLE *newTable, |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5813 STRING_POOL *newPool, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5814 const HASH_TABLE *oldTable) |
| 21930 | 5815 { |
| 5816 HASH_TABLE_ITER iter; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5817 const XML_Char *cachedOldBase = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5818 const XML_Char *cachedNewBase = NULL; |
| 21930 | 5819 |
| 5820 hashTableIterInit(&iter, oldTable); | |
| 5821 | |
| 5822 for (;;) { | |
| 5823 ENTITY *newE; | |
| 5824 const XML_Char *name; | |
| 5825 const ENTITY *oldE = (ENTITY *)hashTableIterNext(&iter); | |
| 5826 if (!oldE) | |
| 5827 break; | |
| 5828 name = poolCopyString(newPool, oldE->name); | |
| 5829 if (!name) | |
| 5830 return 0; | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5831 newE = (ENTITY *)lookup(oldParser, newTable, name, sizeof(ENTITY)); |
| 21930 | 5832 if (!newE) |
| 5833 return 0; | |
| 5834 if (oldE->systemId) { | |
| 5835 const XML_Char *tem = poolCopyString(newPool, oldE->systemId); | |
| 5836 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5837 return 0; |
| 21930 | 5838 newE->systemId = tem; |
| 5839 if (oldE->base) { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5840 if (oldE->base == cachedOldBase) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5841 newE->base = cachedNewBase; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5842 else { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5843 cachedOldBase = oldE->base; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5844 tem = poolCopyString(newPool, cachedOldBase); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5845 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5846 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5847 cachedNewBase = newE->base = tem; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5848 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5849 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5850 if (oldE->publicId) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5851 tem = poolCopyString(newPool, oldE->publicId); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5852 if (!tem) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5853 return 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5854 newE->publicId = tem; |
| 21930 | 5855 } |
| 5856 } | |
| 5857 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5858 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
|
5859 oldE->textLen); |
| 21930 | 5860 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5861 return 0; |
| 21930 | 5862 newE->textPtr = tem; |
| 5863 newE->textLen = oldE->textLen; | |
| 5864 } | |
| 5865 if (oldE->notation) { | |
| 5866 const XML_Char *tem = poolCopyString(newPool, oldE->notation); | |
| 5867 if (!tem) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5868 return 0; |
| 21930 | 5869 newE->notation = tem; |
| 5870 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5871 newE->is_param = oldE->is_param; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5872 newE->is_internal = oldE->is_internal; |
| 21930 | 5873 } |
| 5874 return 1; | |
| 5875 } | |
| 5876 | |
|
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
|
5877 #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
|
5878 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5879 static XML_Bool FASTCALL |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5880 keyeq(KEY s1, KEY s2) |
| 21930 | 5881 { |
| 5882 for (; *s1 == *s2; s1++, s2++) | |
| 5883 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
|
5884 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
|
5885 return XML_FALSE; |
| 21930 | 5886 } |
| 5887 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5888 static unsigned long FASTCALL |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5889 hash(XML_Parser parser, KEY s) |
| 21930 | 5890 { |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5891 unsigned long h = hash_secret_salt; |
| 21930 | 5892 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
|
5893 h = CHAR_HASH(h, *s++); |
| 21930 | 5894 return h; |
| 5895 } | |
| 5896 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5897 static NAMED * |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5898 lookup(XML_Parser parser, HASH_TABLE *table, KEY name, size_t createSize) |
| 21930 | 5899 { |
| 5900 size_t i; | |
| 5901 if (table->size == 0) { | |
| 5902 size_t tsize; | |
| 5903 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5904 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
|
5905 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
|
5906 /* 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
|
5907 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
|
5908 tsize = table->size * sizeof(NAMED *); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5909 table->v = (NAMED **)table->mem->malloc_fcn(tsize); |
| 32911 | 5910 if (!table->v) { |
| 5911 table->size = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5912 return NULL; |
| 32911 | 5913 } |
| 21930 | 5914 memset(table->v, 0, tsize); |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5915 i = hash(parser, name) & ((unsigned long)table->size - 1); |
| 21930 | 5916 } |
| 5917 else { | |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5918 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
|
5919 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
|
5920 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
|
5921 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
|
5922 while (table->v[i]) { |
| 21930 | 5923 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
|
5924 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
|
5925 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
|
5926 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
|
5927 i < step ? (i += table->size - step) : (i -= step); |
| 21930 | 5928 } |
| 5929 if (!createSize) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5930 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
|
5931 |
|
6248dd5d192a
Update to Expat 1.95.7; there are no changes to the Expat sources.
Fred Drake <fdrake@acm.org>
parents:
27466
diff
changeset
|
5932 /* 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
|
5933 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
|
5934 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
|
5935 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
|
5936 unsigned long newMask = (unsigned long)newSize - 1; |
| 21930 | 5937 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
|
5938 NAMED **newV = (NAMED **)table->mem->malloc_fcn(tsize); |
| 21930 | 5939 if (!newV) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5940 return NULL; |
| 21930 | 5941 memset(newV, 0, tsize); |
| 5942 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
|
5943 if (table->v[i]) { |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
5944 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
|
5945 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
|
5946 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
|
5947 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
|
5948 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
|
5949 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
|
5950 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
|
5951 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5952 newV[j] = table->v[i]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5953 } |
| 21930 | 5954 table->mem->free_fcn(table->v); |
| 5955 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
|
5956 table->power = newPower; |
| 21930 | 5957 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
|
5958 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
|
5959 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
|
5960 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
|
5961 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
|
5962 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
|
5963 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
|
5964 } |
| 21930 | 5965 } |
| 5966 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5967 table->v[i] = (NAMED *)table->mem->malloc_fcn(createSize); |
| 21930 | 5968 if (!table->v[i]) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5969 return NULL; |
| 21930 | 5970 memset(table->v[i], 0, createSize); |
| 5971 table->v[i]->name = name; | |
| 5972 (table->used)++; | |
| 5973 return table->v[i]; | |
| 5974 } | |
| 5975 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5976 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5977 hashTableClear(HASH_TABLE *table) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5978 { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5979 size_t i; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5980 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
|
5981 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
|
5982 table->v[i] = NULL; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5983 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5984 table->used = 0; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5985 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5986 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5987 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5988 hashTableDestroy(HASH_TABLE *table) |
| 21930 | 5989 { |
| 5990 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
|
5991 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
|
5992 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
|
5993 table->mem->free_fcn(table->v); |
| 21930 | 5994 } |
| 5995 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5996 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
5997 hashTableInit(HASH_TABLE *p, const XML_Memory_Handling_Suite *ms) |
| 21930 | 5998 { |
|
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
|
5999 p->power = 0; |
| 21930 | 6000 p->size = 0; |
| 6001 p->used = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6002 p->v = NULL; |
| 21930 | 6003 p->mem = ms; |
| 6004 } | |
| 6005 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6006 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6007 hashTableIterInit(HASH_TABLE_ITER *iter, const HASH_TABLE *table) |
| 21930 | 6008 { |
| 6009 iter->p = table->v; | |
| 6010 iter->end = iter->p + table->size; | |
| 6011 } | |
| 6012 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6013 static NAMED * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6014 hashTableIterNext(HASH_TABLE_ITER *iter) |
| 21930 | 6015 { |
| 6016 while (iter->p != iter->end) { | |
| 6017 NAMED *tem = *(iter->p)++; | |
| 6018 if (tem) | |
| 6019 return tem; | |
| 6020 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6021 return NULL; |
| 21930 | 6022 } |
| 6023 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6024 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6025 poolInit(STRING_POOL *pool, const XML_Memory_Handling_Suite *ms) |
| 21930 | 6026 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6027 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6028 pool->freeBlocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6029 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6030 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6031 pool->end = NULL; |
| 21930 | 6032 pool->mem = ms; |
| 6033 } | |
| 6034 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6035 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6036 poolClear(STRING_POOL *pool) |
| 21930 | 6037 { |
| 6038 if (!pool->freeBlocks) | |
| 6039 pool->freeBlocks = pool->blocks; | |
| 6040 else { | |
| 6041 BLOCK *p = pool->blocks; | |
| 6042 while (p) { | |
| 6043 BLOCK *tem = p->next; | |
| 6044 p->next = pool->freeBlocks; | |
| 6045 pool->freeBlocks = p; | |
| 6046 p = tem; | |
| 6047 } | |
| 6048 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6049 pool->blocks = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6050 pool->start = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6051 pool->ptr = NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6052 pool->end = NULL; |
| 21930 | 6053 } |
| 6054 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6055 static void FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6056 poolDestroy(STRING_POOL *pool) |
| 21930 | 6057 { |
| 6058 BLOCK *p = pool->blocks; | |
| 6059 while (p) { | |
| 6060 BLOCK *tem = p->next; | |
| 6061 pool->mem->free_fcn(p); | |
| 6062 p = tem; | |
| 6063 } | |
| 6064 p = pool->freeBlocks; | |
| 6065 while (p) { | |
| 6066 BLOCK *tem = p->next; | |
| 6067 pool->mem->free_fcn(p); | |
| 6068 p = tem; | |
| 6069 } | |
| 6070 } | |
| 6071 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6072 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6073 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
|
6074 const char *ptr, const char *end) |
| 21930 | 6075 { |
| 6076 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6077 return NULL; |
| 21930 | 6078 for (;;) { |
| 6079 XmlConvert(enc, &ptr, end, (ICHAR **)&(pool->ptr), (ICHAR *)pool->end); | |
| 6080 if (ptr == end) | |
| 6081 break; | |
| 6082 if (!poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6083 return NULL; |
| 21930 | 6084 } |
| 6085 return pool->start; | |
| 6086 } | |
| 6087 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6088 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6089 poolCopyString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6090 { |
| 6091 do { | |
| 6092 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6093 return NULL; |
| 21930 | 6094 } while (*s++); |
| 6095 s = pool->start; | |
| 6096 poolFinish(pool); | |
| 6097 return s; | |
| 6098 } | |
| 6099 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6100 static const XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6101 poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 21930 | 6102 { |
| 6103 if (!pool->ptr && !poolGrow(pool)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6104 return NULL; |
| 21930 | 6105 for (; n > 0; --n, s++) { |
| 6106 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6107 return NULL; |
| 21930 | 6108 } |
| 6109 s = pool->start; | |
| 6110 poolFinish(pool); | |
| 6111 return s; | |
| 6112 } | |
| 6113 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6114 static const XML_Char * FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6115 poolAppendString(STRING_POOL *pool, const XML_Char *s) |
| 21930 | 6116 { |
| 6117 while (*s) { | |
| 6118 if (!poolAppendChar(pool, *s)) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6119 return NULL; |
| 21930 | 6120 s++; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6121 } |
| 21930 | 6122 return pool->start; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6123 } |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6124 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6125 static XML_Char * |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6126 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
|
6127 const char *ptr, const char *end) |
| 21930 | 6128 { |
| 6129 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
|
6130 return NULL; |
| 21930 | 6131 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
|
6132 return NULL; |
| 21930 | 6133 *(pool->ptr)++ = 0; |
| 6134 return pool->start; | |
| 6135 } | |
| 6136 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6137 static XML_Bool FASTCALL |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6138 poolGrow(STRING_POOL *pool) |
| 21930 | 6139 { |
| 6140 if (pool->freeBlocks) { | |
| 6141 if (pool->start == 0) { | |
| 6142 pool->blocks = pool->freeBlocks; | |
| 6143 pool->freeBlocks = pool->freeBlocks->next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6144 pool->blocks->next = NULL; |
| 21930 | 6145 pool->start = pool->blocks->s; |
| 6146 pool->end = pool->start + pool->blocks->size; | |
| 6147 pool->ptr = pool->start; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6148 return XML_TRUE; |
| 21930 | 6149 } |
| 6150 if (pool->end - pool->start < pool->freeBlocks->size) { | |
| 6151 BLOCK *tem = pool->freeBlocks->next; | |
| 6152 pool->freeBlocks->next = pool->blocks; | |
| 6153 pool->blocks = pool->freeBlocks; | |
| 6154 pool->freeBlocks = tem; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6155 memcpy(pool->blocks->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6156 (pool->end - pool->start) * sizeof(XML_Char)); |
| 21930 | 6157 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); |
| 6158 pool->start = pool->blocks->s; | |
| 6159 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
|
6160 return XML_TRUE; |
| 21930 | 6161 } |
| 6162 } | |
| 6163 if (pool->blocks && pool->start == pool->blocks->s) { | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
6164 int blockSize = (int)(pool->end - pool->start)*2; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6165 pool->blocks = (BLOCK *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6166 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
|
6167 (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
|
6168 + blockSize * sizeof(XML_Char))); |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6169 if (pool->blocks == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6170 return XML_FALSE; |
| 21930 | 6171 pool->blocks->size = blockSize; |
| 6172 pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | |
| 6173 pool->start = pool->blocks->s; | |
| 6174 pool->end = pool->start + blockSize; | |
| 6175 } | |
| 6176 else { | |
| 6177 BLOCK *tem; | |
|
38885
f19e877281e4
Upgrade pyexpat to expat 2.0.0 (http://python.org/sf/1462338).
Trent Mick <trentm@activestate.com>
parents:
38080
diff
changeset
|
6178 int blockSize = (int)(pool->end - pool->start); |
| 21930 | 6179 if (blockSize < INIT_BLOCK_SIZE) |
| 6180 blockSize = INIT_BLOCK_SIZE; | |
| 6181 else | |
| 6182 blockSize *= 2; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6183 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
|
6184 + blockSize * sizeof(XML_Char)); |
| 21930 | 6185 if (!tem) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6186 return XML_FALSE; |
| 21930 | 6187 tem->size = blockSize; |
| 6188 tem->next = pool->blocks; | |
| 6189 pool->blocks = tem; | |
| 6190 if (pool->ptr != pool->start) | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6191 memcpy(tem->s, pool->start, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6192 (pool->ptr - pool->start) * sizeof(XML_Char)); |
| 21930 | 6193 pool->ptr = tem->s + (pool->ptr - pool->start); |
| 6194 pool->start = tem->s; | |
| 6195 pool->end = tem->s + blockSize; | |
| 6196 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6197 return XML_TRUE; |
| 21930 | 6198 } |
| 6199 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6200 static int FASTCALL |
| 21930 | 6201 nextScaffoldPart(XML_Parser parser) |
| 6202 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6203 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6204 CONTENT_SCAFFOLD * me; |
| 6205 int next; | |
| 6206 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6207 if (!dtd->scaffIndex) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6208 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
|
6209 if (!dtd->scaffIndex) |
| 21930 | 6210 return -1; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6211 dtd->scaffIndex[0] = 0; |
| 21930 | 6212 } |
| 6213 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6214 if (dtd->scaffCount >= dtd->scaffSize) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6215 CONTENT_SCAFFOLD *temp; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6216 if (dtd->scaffold) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6217 temp = (CONTENT_SCAFFOLD *) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6218 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
|
6219 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6220 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6221 dtd->scaffSize *= 2; |
| 21930 | 6222 } |
| 6223 else { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6224 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
|
6225 * sizeof(CONTENT_SCAFFOLD)); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6226 if (temp == NULL) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6227 return -1; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6228 dtd->scaffSize = INIT_SCAFFOLD_ELEMENTS; |
| 21930 | 6229 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6230 dtd->scaffold = temp; |
| 21930 | 6231 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6232 next = dtd->scaffCount++; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6233 me = &dtd->scaffold[next]; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6234 if (dtd->scaffLevel) { |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6235 CONTENT_SCAFFOLD *parent = &dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel-1]]; |
| 21930 | 6236 if (parent->lastchild) { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6237 dtd->scaffold[parent->lastchild].nextsib = next; |
| 21930 | 6238 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6239 if (!parent->childcnt) |
| 21930 | 6240 parent->firstchild = next; |
| 6241 parent->lastchild = next; | |
| 6242 parent->childcnt++; | |
| 6243 } | |
| 6244 me->firstchild = me->lastchild = me->childcnt = me->nextsib = 0; | |
| 6245 return next; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6246 } |
| 21930 | 6247 |
| 6248 static void | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6249 build_node(XML_Parser parser, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6250 int src_node, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6251 XML_Content *dest, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6252 XML_Content **contpos, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6253 XML_Char **strpos) |
| 21930 | 6254 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6255 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
|
6256 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
|
6257 dest->quant = dtd->scaffold[src_node].quant; |
| 21930 | 6258 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
|
6259 const XML_Char *src; |
| 21930 | 6260 dest->name = *strpos; |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6261 src = dtd->scaffold[src_node].name; |
| 21930 | 6262 for (;;) { |
| 6263 *(*strpos)++ = *src; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6264 if (!*src) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6265 break; |
| 21930 | 6266 src++; |
| 6267 } | |
| 6268 dest->numchildren = 0; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6269 dest->children = NULL; |
| 21930 | 6270 } |
| 6271 else { | |
| 6272 unsigned int i; | |
| 6273 int cn; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6274 dest->numchildren = dtd->scaffold[src_node].childcnt; |
| 21930 | 6275 dest->children = *contpos; |
| 6276 *contpos += dest->numchildren; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6277 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
|
6278 i < dest->numchildren; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6279 i++, cn = dtd->scaffold[cn].nextsib) { |
| 21930 | 6280 build_node(parser, cn, &(dest->children[i]), contpos, strpos); |
| 6281 } | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6282 dest->name = NULL; |
| 21930 | 6283 } |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6284 } |
| 21930 | 6285 |
| 6286 static XML_Content * | |
| 6287 build_model (XML_Parser parser) | |
| 6288 { | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6289 DTD * const dtd = _dtd; /* save one level of indirection */ |
| 21930 | 6290 XML_Content *ret; |
| 6291 XML_Content *cpos; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6292 XML_Char * str; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6293 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
|
6294 + (dtd->contentStringLen * sizeof(XML_Char))); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6295 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6296 ret = (XML_Content *)MALLOC(allocsize); |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6297 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6298 return NULL; |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6299 |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6300 str = (XML_Char *) (&ret[dtd->scaffCount]); |
| 21930 | 6301 cpos = &ret[1]; |
| 6302 | |
| 6303 build_node(parser, 0, ret, &cpos, &str); | |
| 6304 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6305 } |
| 21930 | 6306 |
| 6307 static ELEMENT_TYPE * | |
| 6308 getElementType(XML_Parser parser, | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6309 const ENCODING *enc, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6310 const char *ptr, |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6311 const char *end) |
| 21930 | 6312 { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6313 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
|
6314 const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 21930 | 6315 ELEMENT_TYPE *ret; |
| 6316 | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6317 if (!name) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6318 return NULL; |
|
75667
b54f5849013c
Fixes Issue #14234: CVE-2012-0876: Randomize hashes of xml attributes
Gregory P. Smith <greg@krypto.org>
parents:
58437
diff
changeset
|
6319 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
|
6320 if (!ret) |
|
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6321 return NULL; |
| 21930 | 6322 if (ret->name != name) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6323 poolDiscard(&dtd->pool); |
| 21930 | 6324 else { |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6325 poolFinish(&dtd->pool); |
| 21930 | 6326 if (!setElementTypePrefix(parser, ret)) |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6327 return NULL; |
| 21930 | 6328 } |
| 6329 return ret; | |
|
27384
d363f83c2846
Incorporate Expat 1.95.6.
Martin v. Löwis <martin@v.loewis.de>
parents:
21931
diff
changeset
|
6330 } |
