diff options
| author | Tobias Markmann <tm@ayena.de> | 2019-07-26 09:04:38 (GMT) |
|---|---|---|
| committer | Tobias Markmann <tm@ayena.de> | 2019-07-26 09:31:03 (GMT) |
| commit | e74a38b60d600d547b3b2e4dfdd7ddb543855e3f (patch) | |
| tree | e46b154a4f52026bc5d4be7e2768d45a8d1c28f2 /3rdParty/Expat/src | |
| parent | f6fb85ba98fdd6601c4b8323c51c8367ccc4b52e (diff) | |
| download | swift-e74a38b60d600d547b3b2e4dfdd7ddb543855e3f.zip swift-e74a38b60d600d547b3b2e4dfdd7ddb543855e3f.tar.bz2 | |
Update 3rdParty/Expat to 2.2.7
Test-Information:
None yet.
Change-Id: Ia5b570c918b8059561b52062e8d43496f188ee4a
Diffstat (limited to '3rdParty/Expat/src')
| -rw-r--r-- | 3rdParty/Expat/src/ascii.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/asciitab.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/expat.h | 37 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/expat_external.h | 92 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/iasciitab.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/internal.h | 36 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/latin1tab.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/loadlibrary.c | 143 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/nametab.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/siphash.h | 81 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/utf8tab.h | 33 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/winconfig.h | 41 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmlparse.c | 3201 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmlrole.c | 62 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmlrole.h | 32 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmltok.c | 103 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmltok.h | 37 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmltok_impl.c | 132 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmltok_impl.h | 31 | ||||
| -rw-r--r-- | 3rdParty/Expat/src/xmltok_ns.c | 33 |
20 files changed, 2657 insertions, 1597 deletions
diff --git a/3rdParty/Expat/src/ascii.h b/3rdParty/Expat/src/ascii.h index d10530b..c3587e5 100644 --- a/3rdParty/Expat/src/ascii.h +++ b/3rdParty/Expat/src/ascii.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #define ASCII_A 0x41 | 33 | #define ASCII_A 0x41 |
diff --git a/3rdParty/Expat/src/asciitab.h b/3rdParty/Expat/src/asciitab.h index 79a15c2..2f59fd9 100644 --- a/3rdParty/Expat/src/asciitab.h +++ b/3rdParty/Expat/src/asciitab.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, | 33 | /* 0x00 */ BT_NONXML, BT_NONXML, BT_NONXML, BT_NONXML, |
diff --git a/3rdParty/Expat/src/expat.h b/3rdParty/Expat/src/expat.h index 28b0f95..c050f1d 100644 --- a/3rdParty/Expat/src/expat.h +++ b/3rdParty/Expat/src/expat.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #ifndef Expat_INCLUDED | 33 | #ifndef Expat_INCLUDED |
| @@ -24,7 +52,6 @@ extern "C" { | |||
| 24 | struct XML_ParserStruct; | 52 | struct XML_ParserStruct; |
| 25 | typedef struct XML_ParserStruct *XML_Parser; | 53 | typedef struct XML_ParserStruct *XML_Parser; |
| 26 | 54 | ||
| 27 | /* Should this be defined using stdbool.h when C99 is available? */ | ||
| 28 | typedef unsigned char XML_Bool; | 55 | typedef unsigned char XML_Bool; |
| 29 | #define XML_TRUE ((XML_Bool) 1) | 56 | #define XML_TRUE ((XML_Bool) 1) |
| 30 | #define XML_FALSE ((XML_Bool) 0) | 57 | #define XML_FALSE ((XML_Bool) 0) |
| @@ -237,7 +264,7 @@ XML_ParserCreate_MM(const XML_Char *encoding, | |||
| 237 | const XML_Char *namespaceSeparator); | 264 | const XML_Char *namespaceSeparator); |
| 238 | 265 | ||
| 239 | /* Prepare a parser object to be re-used. This is particularly | 266 | /* Prepare a parser object to be re-used. This is particularly |
| 240 | valuable when memory allocation overhead is disproportionatly high, | 267 | valuable when memory allocation overhead is disproportionately high, |
| 241 | such as when a large number of small documnents need to be parsed. | 268 | such as when a large number of small documnents need to be parsed. |
| 242 | All handlers are cleared from the parser, except for the | 269 | All handlers are cleared from the parser, except for the |
| 243 | unknownEncodingHandler. The parser's external state is re-initialized | 270 | unknownEncodingHandler. The parser's external state is re-initialized |
| @@ -1049,7 +1076,7 @@ XML_GetFeatureList(void); | |||
| 1049 | */ | 1076 | */ |
| 1050 | #define XML_MAJOR_VERSION 2 | 1077 | #define XML_MAJOR_VERSION 2 |
| 1051 | #define XML_MINOR_VERSION 2 | 1078 | #define XML_MINOR_VERSION 2 |
| 1052 | #define XML_MICRO_VERSION 1 | 1079 | #define XML_MICRO_VERSION 7 |
| 1053 | 1080 | ||
| 1054 | #ifdef __cplusplus | 1081 | #ifdef __cplusplus |
| 1055 | } | 1082 | } |
diff --git a/3rdParty/Expat/src/expat_external.h b/3rdParty/Expat/src/expat_external.h index 892eb4b..875225d 100644 --- a/3rdParty/Expat/src/expat_external.h +++ b/3rdParty/Expat/src/expat_external.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #ifndef Expat_External_INCLUDED | 33 | #ifndef Expat_External_INCLUDED |
| @@ -8,7 +36,7 @@ | |||
| 8 | /* External API definitions */ | 36 | /* External API definitions */ |
| 9 | 37 | ||
| 10 | #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) | 38 | #if defined(_MSC_EXTENSIONS) && !defined(__BEOS__) && !defined(__CYGWIN__) |
| 11 | #define XML_USE_MSC_EXTENSIONS 1 | 39 | # define XML_USE_MSC_EXTENSIONS 1 |
| 12 | #endif | 40 | #endif |
| 13 | 41 | ||
| 14 | /* Expat tries very hard to make the API boundary very specifically | 42 | /* Expat tries very hard to make the API boundary very specifically |
| @@ -34,11 +62,11 @@ | |||
| 34 | system headers may assume the cdecl convention. | 62 | system headers may assume the cdecl convention. |
| 35 | */ | 63 | */ |
| 36 | #ifndef XMLCALL | 64 | #ifndef XMLCALL |
| 37 | #if defined(_MSC_VER) | 65 | # if defined(_MSC_VER) |
| 38 | #define XMLCALL __cdecl | 66 | # define XMLCALL __cdecl |
| 39 | #elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) | 67 | # elif defined(__GNUC__) && defined(__i386) && !defined(__INTEL_COMPILER) |
| 40 | #define XMLCALL __attribute__((cdecl)) | 68 | # define XMLCALL __attribute__((cdecl)) |
| 41 | #else | 69 | # else |
| 42 | /* For any platform which uses this definition and supports more than | 70 | /* For any platform which uses this definition and supports more than |
| 43 | one calling convention, we need to extend this definition to | 71 | one calling convention, we need to extend this definition to |
| 44 | declare the convention used on that platform, if it's possible to | 72 | declare the convention used on that platform, if it's possible to |
| @@ -49,41 +77,45 @@ | |||
| 49 | pre-processor and how to specify the same calling convention as the | 77 | pre-processor and how to specify the same calling convention as the |
| 50 | platform's malloc() implementation. | 78 | platform's malloc() implementation. |
| 51 | */ | 79 | */ |
| 52 | #define XMLCALL | 80 | # define XMLCALL |
| 53 | #endif | 81 | # endif |
| 54 | #endif /* not defined XMLCALL */ | 82 | #endif /* not defined XMLCALL */ |
| 55 | 83 | ||
| 56 | 84 | ||
| 57 | #if !defined(XML_STATIC) && !defined(XMLIMPORT) | 85 | #if !defined(XML_STATIC) && !defined(XMLIMPORT) |
| 58 | #ifndef XML_BUILDING_EXPAT | 86 | # ifndef XML_BUILDING_EXPAT |
| 59 | /* using Expat from an application */ | 87 | /* using Expat from an application */ |
| 60 | 88 | ||
| 61 | #ifdef XML_USE_MSC_EXTENSIONS | 89 | # ifdef XML_USE_MSC_EXTENSIONS |
| 62 | #define XMLIMPORT __declspec(dllimport) | 90 | # define XMLIMPORT __declspec(dllimport) |
| 63 | #endif | 91 | # endif |
| 64 | 92 | ||
| 65 | #endif | 93 | # endif |
| 66 | #endif /* not defined XML_STATIC */ | 94 | #endif /* not defined XML_STATIC */ |
| 67 | 95 | ||
| 68 | #if !defined(XMLIMPORT) && defined(__GNUC__) && (__GNUC__ >= 4) | 96 | #ifndef XML_ENABLE_VISIBILITY |
| 69 | #define XMLIMPORT __attribute__ ((visibility ("default"))) | 97 | # define XML_ENABLE_VISIBILITY 0 |
| 98 | #endif | ||
| 99 | |||
| 100 | #if !defined(XMLIMPORT) && XML_ENABLE_VISIBILITY | ||
| 101 | # define XMLIMPORT __attribute__ ((visibility ("default"))) | ||
| 70 | #endif | 102 | #endif |
| 71 | 103 | ||
| 72 | /* If we didn't define it above, define it away: */ | 104 | /* If we didn't define it above, define it away: */ |
| 73 | #ifndef XMLIMPORT | 105 | #ifndef XMLIMPORT |
| 74 | #define XMLIMPORT | 106 | # define XMLIMPORT |
| 75 | #endif | 107 | #endif |
| 76 | 108 | ||
| 77 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) | 109 | #if defined(__GNUC__) && (__GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 96)) |
| 78 | #define XML_ATTR_MALLOC __attribute__((__malloc__)) | 110 | # define XML_ATTR_MALLOC __attribute__((__malloc__)) |
| 79 | #else | 111 | #else |
| 80 | #define XML_ATTR_MALLOC | 112 | # define XML_ATTR_MALLOC |
| 81 | #endif | 113 | #endif |
| 82 | 114 | ||
| 83 | #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) | 115 | #if defined(__GNUC__) && ((__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)) |
| 84 | #define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) | 116 | # define XML_ATTR_ALLOC_SIZE(x) __attribute__((__alloc_size__(x))) |
| 85 | #else | 117 | #else |
| 86 | #define XML_ATTR_ALLOC_SIZE(x) | 118 | # define XML_ATTR_ALLOC_SIZE(x) |
| 87 | #endif | 119 | #endif |
| 88 | 120 | ||
| 89 | #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL | 121 | #define XMLPARSEAPI(type) XMLIMPORT type XMLCALL |
| @@ -93,33 +125,35 @@ extern "C" { | |||
| 93 | #endif | 125 | #endif |
| 94 | 126 | ||
| 95 | #ifdef XML_UNICODE_WCHAR_T | 127 | #ifdef XML_UNICODE_WCHAR_T |
| 96 | # define XML_UNICODE | 128 | # ifndef XML_UNICODE |
| 129 | # define XML_UNICODE | ||
| 130 | # endif | ||
| 97 | # if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) | 131 | # if defined(__SIZEOF_WCHAR_T__) && (__SIZEOF_WCHAR_T__ != 2) |
| 98 | # error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" | 132 | # error "sizeof(wchar_t) != 2; Need -fshort-wchar for both Expat and libc" |
| 99 | # endif | 133 | # endif |
| 100 | #endif | 134 | #endif |
| 101 | 135 | ||
| 102 | #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ | 136 | #ifdef XML_UNICODE /* Information is UTF-16 encoded. */ |
| 103 | #ifdef XML_UNICODE_WCHAR_T | 137 | # ifdef XML_UNICODE_WCHAR_T |
| 104 | typedef wchar_t XML_Char; | 138 | typedef wchar_t XML_Char; |
| 105 | typedef wchar_t XML_LChar; | 139 | typedef wchar_t XML_LChar; |
| 106 | #else | 140 | # else |
| 107 | typedef unsigned short XML_Char; | 141 | typedef unsigned short XML_Char; |
| 108 | typedef char XML_LChar; | 142 | typedef char XML_LChar; |
| 109 | #endif /* XML_UNICODE_WCHAR_T */ | 143 | # endif /* XML_UNICODE_WCHAR_T */ |
| 110 | #else /* Information is UTF-8 encoded. */ | 144 | #else /* Information is UTF-8 encoded. */ |
| 111 | typedef char XML_Char; | 145 | typedef char XML_Char; |
| 112 | typedef char XML_LChar; | 146 | typedef char XML_LChar; |
| 113 | #endif /* XML_UNICODE */ | 147 | #endif /* XML_UNICODE */ |
| 114 | 148 | ||
| 115 | #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ | 149 | #ifdef XML_LARGE_SIZE /* Use large integers for file/stream positions. */ |
| 116 | #if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 | 150 | # if defined(XML_USE_MSC_EXTENSIONS) && _MSC_VER < 1400 |
| 117 | typedef __int64 XML_Index; | 151 | typedef __int64 XML_Index; |
| 118 | typedef unsigned __int64 XML_Size; | 152 | typedef unsigned __int64 XML_Size; |
| 119 | #else | 153 | # else |
| 120 | typedef long long XML_Index; | 154 | typedef long long XML_Index; |
| 121 | typedef unsigned long long XML_Size; | 155 | typedef unsigned long long XML_Size; |
| 122 | #endif | 156 | # endif |
| 123 | #else | 157 | #else |
| 124 | typedef long XML_Index; | 158 | typedef long XML_Index; |
| 125 | typedef unsigned long XML_Size; | 159 | typedef unsigned long XML_Size; |
diff --git a/3rdParty/Expat/src/iasciitab.h b/3rdParty/Expat/src/iasciitab.h index 24a1d5c..ce4a4bf 100644 --- a/3rdParty/Expat/src/iasciitab.h +++ b/3rdParty/Expat/src/iasciitab.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ | 33 | /* Like asciitab.h, except that 0xD has code BT_S rather than BT_CR */ |
diff --git a/3rdParty/Expat/src/internal.h b/3rdParty/Expat/src/internal.h index 94cb98e..dc4ef0c 100644 --- a/3rdParty/Expat/src/internal.h +++ b/3rdParty/Expat/src/internal.h | |||
| @@ -18,6 +18,35 @@ | |||
| 18 | 18 | ||
| 19 | Note: Use of these macros is based on judgement, not hard rules, | 19 | Note: Use of these macros is based on judgement, not hard rules, |
| 20 | and therefore subject to change. | 20 | and therefore subject to change. |
| 21 | __ __ _ | ||
| 22 | ___\ \/ /_ __ __ _| |_ | ||
| 23 | / _ \\ /| '_ \ / _` | __| | ||
| 24 | | __// \| |_) | (_| | |_ | ||
| 25 | \___/_/\_\ .__/ \__,_|\__| | ||
| 26 | |_| XML parser | ||
| 27 | |||
| 28 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 29 | Copyright (c) 2000-2017 Expat development team | ||
| 30 | Licensed under the MIT license: | ||
| 31 | |||
| 32 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 33 | a copy of this software and associated documentation files (the | ||
| 34 | "Software"), to deal in the Software without restriction, including | ||
| 35 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 36 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 37 | persons to whom the Software is furnished to do so, subject to the | ||
| 38 | following conditions: | ||
| 39 | |||
| 40 | The above copyright notice and this permission notice shall be included | ||
| 41 | in all copies or substantial portions of the Software. | ||
| 42 | |||
| 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 44 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 45 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 46 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 47 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 48 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 49 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 21 | */ | 50 | */ |
| 22 | 51 | ||
| 23 | #if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) | 52 | #if defined(__GNUC__) && defined(__i386__) && !defined(__MINGW32__) |
| @@ -86,8 +115,13 @@ extern "C" { | |||
| 86 | #endif | 115 | #endif |
| 87 | 116 | ||
| 88 | 117 | ||
| 118 | #ifdef XML_ENABLE_VISIBILITY | ||
| 119 | #if XML_ENABLE_VISIBILITY | ||
| 120 | __attribute__ ((visibility ("default"))) | ||
| 121 | #endif | ||
| 122 | #endif | ||
| 89 | void | 123 | void |
| 90 | align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef); | 124 | _INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef); |
| 91 | 125 | ||
| 92 | 126 | ||
| 93 | #ifdef __cplusplus | 127 | #ifdef __cplusplus |
diff --git a/3rdParty/Expat/src/latin1tab.h b/3rdParty/Expat/src/latin1tab.h index 53c25d7..95dfa52 100644 --- a/3rdParty/Expat/src/latin1tab.h +++ b/3rdParty/Expat/src/latin1tab.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, | 33 | /* 0x80 */ BT_OTHER, BT_OTHER, BT_OTHER, BT_OTHER, |
diff --git a/3rdParty/Expat/src/loadlibrary.c b/3rdParty/Expat/src/loadlibrary.c new file mode 100644 index 0000000..35fdf98 --- /dev/null +++ b/3rdParty/Expat/src/loadlibrary.c | |||
| @@ -0,0 +1,143 @@ | |||
| 1 | /*************************************************************************** | ||
| 2 | * _ _ ____ _ | ||
| 3 | * Project ___| | | | _ \| | | ||
| 4 | * / __| | | | |_) | | | ||
| 5 | * | (__| |_| | _ <| |___ | ||
| 6 | * \___|\___/|_| \_\_____| | ||
| 7 | * | ||
| 8 | * Copyright (C) 2016 - 2017, Steve Holme, <steve_holme@hotmail.com>. | ||
| 9 | * Copyright (C) 2017, Expat development team | ||
| 10 | * | ||
| 11 | * All rights reserved. | ||
| 12 | * Licensed under the MIT license: | ||
| 13 | * | ||
| 14 | * Permission to use, copy, modify, and distribute this software for any | ||
| 15 | * purpose with or without fee is hereby granted, provided that the above | ||
| 16 | * copyright notice and this permission notice appear in all copies. | ||
| 17 | * | ||
| 18 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 19 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 20 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF | ||
| 21 | * THIRD PARTY RIGHTS. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
| 22 | * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF | ||
| 23 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH | ||
| 24 | * THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 25 | * | ||
| 26 | * Except as contained in this notice, the name of a copyright holder shall | ||
| 27 | * not be used in advertising or otherwise to promote the sale, use or other | ||
| 28 | * dealings in this Software without prior written authorization of the | ||
| 29 | * copyright holder. | ||
| 30 | * | ||
| 31 | ***************************************************************************/ | ||
| 32 | |||
| 33 | #if defined(_WIN32) | ||
| 34 | |||
| 35 | #include <windows.h> | ||
| 36 | #include <tchar.h> | ||
| 37 | |||
| 38 | |||
| 39 | HMODULE _Expat_LoadLibrary(LPCTSTR filename); | ||
| 40 | |||
| 41 | |||
| 42 | #if !defined(LOAD_WITH_ALTERED_SEARCH_PATH) | ||
| 43 | #define LOAD_WITH_ALTERED_SEARCH_PATH 0x00000008 | ||
| 44 | #endif | ||
| 45 | |||
| 46 | #if !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) | ||
| 47 | #define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 | ||
| 48 | #endif | ||
| 49 | |||
| 50 | /* We use our own typedef here since some headers might lack these */ | ||
| 51 | typedef HMODULE (APIENTRY *LOADLIBRARYEX_FN)(LPCTSTR, HANDLE, DWORD); | ||
| 52 | |||
| 53 | /* See function definitions in winbase.h */ | ||
| 54 | #ifdef UNICODE | ||
| 55 | # ifdef _WIN32_WCE | ||
| 56 | # define LOADLIBARYEX L"LoadLibraryExW" | ||
| 57 | # else | ||
| 58 | # define LOADLIBARYEX "LoadLibraryExW" | ||
| 59 | # endif | ||
| 60 | #else | ||
| 61 | # define LOADLIBARYEX "LoadLibraryExA" | ||
| 62 | #endif | ||
| 63 | |||
| 64 | |||
| 65 | /* | ||
| 66 | * _Expat_LoadLibrary() | ||
| 67 | * | ||
| 68 | * This is used to dynamically load DLLs using the most secure method available | ||
| 69 | * for the version of Windows that we are running on. | ||
| 70 | * | ||
| 71 | * Parameters: | ||
| 72 | * | ||
| 73 | * filename [in] - The filename or full path of the DLL to load. If only the | ||
| 74 | * filename is passed then the DLL will be loaded from the | ||
| 75 | * Windows system directory. | ||
| 76 | * | ||
| 77 | * Returns the handle of the module on success; otherwise NULL. | ||
| 78 | */ | ||
| 79 | HMODULE _Expat_LoadLibrary(LPCTSTR filename) | ||
| 80 | { | ||
| 81 | HMODULE hModule = NULL; | ||
| 82 | LOADLIBRARYEX_FN pLoadLibraryEx = NULL; | ||
| 83 | |||
| 84 | /* Get a handle to kernel32 so we can access it's functions at runtime */ | ||
| 85 | HMODULE hKernel32 = GetModuleHandle(TEXT("kernel32")); | ||
| 86 | if(!hKernel32) | ||
| 87 | return NULL; /* LCOV_EXCL_LINE */ | ||
| 88 | |||
| 89 | /* Attempt to find LoadLibraryEx() which is only available on Windows 2000 | ||
| 90 | and above */ | ||
| 91 | pLoadLibraryEx = (LOADLIBRARYEX_FN) GetProcAddress(hKernel32, LOADLIBARYEX); | ||
| 92 | |||
| 93 | /* Detect if there's already a path in the filename and load the library if | ||
| 94 | there is. Note: Both back slashes and forward slashes have been supported | ||
| 95 | since the earlier days of DOS at an API level although they are not | ||
| 96 | supported by command prompt */ | ||
| 97 | if(_tcspbrk(filename, TEXT("\\/"))) { | ||
| 98 | /** !checksrc! disable BANNEDFUNC 1 **/ | ||
| 99 | hModule = pLoadLibraryEx ? | ||
| 100 | pLoadLibraryEx(filename, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : | ||
| 101 | LoadLibrary(filename); | ||
| 102 | } | ||
| 103 | /* Detect if KB2533623 is installed, as LOAD_LIBARY_SEARCH_SYSTEM32 is only | ||
| 104 | supported on Windows Vista, Windows Server 2008, Windows 7 and Windows | ||
| 105 | Server 2008 R2 with this patch or natively on Windows 8 and above */ | ||
| 106 | else if(pLoadLibraryEx && GetProcAddress(hKernel32, "AddDllDirectory")) { | ||
| 107 | /* Load the DLL from the Windows system directory */ | ||
| 108 | hModule = pLoadLibraryEx(filename, NULL, LOAD_LIBRARY_SEARCH_SYSTEM32); | ||
| 109 | } | ||
| 110 | else { | ||
| 111 | /* Attempt to get the Windows system path */ | ||
| 112 | UINT systemdirlen = GetSystemDirectory(NULL, 0); | ||
| 113 | if(systemdirlen) { | ||
| 114 | /* Allocate space for the full DLL path (Room for the null terminator | ||
| 115 | is included in systemdirlen) */ | ||
| 116 | size_t filenamelen = _tcslen(filename); | ||
| 117 | TCHAR *path = malloc(sizeof(TCHAR) * (systemdirlen + 1 + filenamelen)); | ||
| 118 | if(path && GetSystemDirectory(path, systemdirlen)) { | ||
| 119 | /* Calculate the full DLL path */ | ||
| 120 | _tcscpy(path + _tcslen(path), TEXT("\\")); | ||
| 121 | _tcscpy(path + _tcslen(path), filename); | ||
| 122 | |||
| 123 | /* Load the DLL from the Windows system directory */ | ||
| 124 | /** !checksrc! disable BANNEDFUNC 1 **/ | ||
| 125 | hModule = pLoadLibraryEx ? | ||
| 126 | pLoadLibraryEx(path, NULL, LOAD_WITH_ALTERED_SEARCH_PATH) : | ||
| 127 | LoadLibrary(path); | ||
| 128 | |||
| 129 | } | ||
| 130 | free(path); | ||
| 131 | } | ||
| 132 | } | ||
| 133 | |||
| 134 | return hModule; | ||
| 135 | } | ||
| 136 | |||
| 137 | #else /* defined(_WIN32) */ | ||
| 138 | |||
| 139 | /* ISO C requires a translation unit to contain at least one declaration | ||
| 140 | [-Wempty-translation-unit] */ | ||
| 141 | typedef int _TRANSLATION_UNIT_LOAD_LIBRARY_C_NOT_EMTPY; | ||
| 142 | |||
| 143 | #endif /* defined(_WIN32) */ | ||
diff --git a/3rdParty/Expat/src/nametab.h b/3rdParty/Expat/src/nametab.h index b05e62c..bfa2bd3 100644 --- a/3rdParty/Expat/src/nametab.h +++ b/3rdParty/Expat/src/nametab.h | |||
| @@ -1,3 +1,35 @@ | |||
| 1 | /* | ||
| 2 | __ __ _ | ||
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | */ | ||
| 32 | |||
| 1 | static const unsigned namingBitmap[] = { | 33 | static const unsigned namingBitmap[] = { |
| 2 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 34 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
| 3 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, | 35 | 0x00000000, 0x00000000, 0x00000000, 0x00000000, |
diff --git a/3rdParty/Expat/src/siphash.h b/3rdParty/Expat/src/siphash.h index 23b56d2..4d6786d 100644 --- a/3rdParty/Expat/src/siphash.h +++ b/3rdParty/Expat/src/siphash.h | |||
| @@ -2,9 +2,8 @@ | |||
| 2 | * siphash.h - SipHash-2-4 in a single header file | 2 | * siphash.h - SipHash-2-4 in a single header file |
| 3 | * -------------------------------------------------------------------------- | 3 | * -------------------------------------------------------------------------- |
| 4 | * Derived by William Ahern from the reference implementation[1] published[2] | 4 | * Derived by William Ahern from the reference implementation[1] published[2] |
| 5 | * by Jean-Philippe Aumasson and Daniel J. Berstein. Licensed in kind. | ||
| 6 | * by Jean-Philippe Aumasson and Daniel J. Berstein. | 5 | * by Jean-Philippe Aumasson and Daniel J. Berstein. |
| 7 | * Minimal changes by Sebastian Pipping on top, details below. | 6 | * Minimal changes by Sebastian Pipping and Victor Stinner on top, see below. |
| 8 | * Licensed under the CC0 Public Domain Dedication license. | 7 | * Licensed under the CC0 Public Domain Dedication license. |
| 9 | * | 8 | * |
| 10 | * 1. https://www.131002.net/siphash/siphash24.c | 9 | * 1. https://www.131002.net/siphash/siphash24.c |
| @@ -12,14 +11,31 @@ | |||
| 12 | * -------------------------------------------------------------------------- | 11 | * -------------------------------------------------------------------------- |
| 13 | * HISTORY: | 12 | * HISTORY: |
| 14 | * | 13 | * |
| 15 | * 2017-06-10 (Sebastian Pipping) | 14 | * 2018-07-08 (Anton Maklakov) |
| 15 | * - Add "fall through" markers for GCC's -Wimplicit-fallthrough | ||
| 16 | * | ||
| 17 | * 2017-11-03 (Sebastian Pipping) | ||
| 18 | * - Hide sip_tobin and sip_binof unless SIPHASH_TOBIN macro is defined | ||
| 19 | * | ||
| 20 | * 2017-07-25 (Vadim Zeitlin) | ||
| 21 | * - Fix use of SIPHASH_MAIN macro | ||
| 22 | * | ||
| 23 | * 2017-07-05 (Sebastian Pipping) | ||
| 24 | * - Use _SIP_ULL macro to not require a C++11 compiler if compiled as C++ | ||
| 25 | * - Add const qualifiers at two places | ||
| 26 | * - Ensure <=80 characters line length (assuming tab width 4) | ||
| 27 | * | ||
| 28 | * 2017-06-23 (Victor Stinner) | ||
| 29 | * - Address Win64 compile warnings | ||
| 30 | * | ||
| 31 | * 2017-06-18 (Sebastian Pipping) | ||
| 16 | * - Clarify license note in the header | 32 | * - Clarify license note in the header |
| 17 | * - Address C89 issues: | 33 | * - Address C89 issues: |
| 18 | * - Stop using inline keyword (and let compiler decide) | 34 | * - Stop using inline keyword (and let compiler decide) |
| 19 | * - Turn integer suffix ULL to UL | ||
| 20 | * - Replace _Bool by int | 35 | * - Replace _Bool by int |
| 21 | * - Turn macro siphash24 into a function | 36 | * - Turn macro siphash24 into a function |
| 22 | * - Address invalid conversion (void pointer) by explicit cast | 37 | * - Address invalid conversion (void pointer) by explicit cast |
| 38 | * - Address lack of stdint.h for Visual Studio 2003 to 2008 | ||
| 23 | * - Always expose sip24_valid (for self-tests) | 39 | * - Always expose sip24_valid (for self-tests) |
| 24 | * | 40 | * |
| 25 | * 2012-11-04 - Born. (William Ahern) | 41 | * 2012-11-04 - Born. (William Ahern) |
| @@ -76,7 +92,23 @@ | |||
| 76 | #define SIPHASH_H | 92 | #define SIPHASH_H |
| 77 | 93 | ||
| 78 | #include <stddef.h> /* size_t */ | 94 | #include <stddef.h> /* size_t */ |
| 79 | #include <stdint.h> /* uint64_t uint32_t uint8_t */ | 95 | |
| 96 | #if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1600) | ||
| 97 | /* For vs2003/7.1 up to vs2008/9.0; _MSC_VER 1600 is vs2010/10.0 */ | ||
| 98 | typedef unsigned __int8 uint8_t; | ||
| 99 | typedef unsigned __int32 uint32_t; | ||
| 100 | typedef unsigned __int64 uint64_t; | ||
| 101 | #else | ||
| 102 | #include <stdint.h> /* uint64_t uint32_t uint8_t */ | ||
| 103 | #endif | ||
| 104 | |||
| 105 | |||
| 106 | /* | ||
| 107 | * Workaround to not require a C++11 compiler for using ULL suffix | ||
| 108 | * if this code is included and compiled as C++; related GCC warning is: | ||
| 109 | * warning: use of C++11 long long integer constant [-Wlong-long] | ||
| 110 | */ | ||
| 111 | #define _SIP_ULL(high, low) (((uint64_t)high << 32) | low) | ||
| 80 | 112 | ||
| 81 | 113 | ||
| 82 | #define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ( (x) >> (64 - (b)))) | 114 | #define SIP_ROTL(x, b) (uint64_t)(((x) << (b)) | ( (x) >> (64 - (b)))) |
| @@ -125,6 +157,8 @@ static struct sipkey *sip_tokey(struct sipkey *key, const void *src) { | |||
| 125 | } /* sip_tokey() */ | 157 | } /* sip_tokey() */ |
| 126 | 158 | ||
| 127 | 159 | ||
| 160 | #ifdef SIPHASH_TOBIN | ||
| 161 | |||
| 128 | #define sip_binof(v) sip_tobin((unsigned char[8]){ 0 }, (v)) | 162 | #define sip_binof(v) sip_tobin((unsigned char[8]){ 0 }, (v)) |
| 129 | 163 | ||
| 130 | static void *sip_tobin(void *dst, uint64_t u64) { | 164 | static void *sip_tobin(void *dst, uint64_t u64) { |
| @@ -132,6 +166,8 @@ static void *sip_tobin(void *dst, uint64_t u64) { | |||
| 132 | return dst; | 166 | return dst; |
| 133 | } /* sip_tobin() */ | 167 | } /* sip_tobin() */ |
| 134 | 168 | ||
| 169 | #endif /* SIPHASH_TOBIN */ | ||
| 170 | |||
| 135 | 171 | ||
| 136 | static void sip_round(struct siphash *H, const int rounds) { | 172 | static void sip_round(struct siphash *H, const int rounds) { |
| 137 | int i; | 173 | int i; |
| @@ -158,11 +194,12 @@ static void sip_round(struct siphash *H, const int rounds) { | |||
| 158 | } /* sip_round() */ | 194 | } /* sip_round() */ |
| 159 | 195 | ||
| 160 | 196 | ||
| 161 | static struct siphash *sip24_init(struct siphash *H, const struct sipkey *key) { | 197 | static struct siphash *sip24_init(struct siphash *H, |
| 162 | H->v0 = 0x736f6d6570736575UL ^ key->k[0]; | 198 | const struct sipkey *key) { |
| 163 | H->v1 = 0x646f72616e646f6dUL ^ key->k[1]; | 199 | H->v0 = _SIP_ULL(0x736f6d65U, 0x70736575U) ^ key->k[0]; |
| 164 | H->v2 = 0x6c7967656e657261UL ^ key->k[0]; | 200 | H->v1 = _SIP_ULL(0x646f7261U, 0x6e646f6dU) ^ key->k[1]; |
| 165 | H->v3 = 0x7465646279746573UL ^ key->k[1]; | 201 | H->v2 = _SIP_ULL(0x6c796765U, 0x6e657261U) ^ key->k[0]; |
| 202 | H->v3 = _SIP_ULL(0x74656462U, 0x79746573U) ^ key->k[1]; | ||
| 166 | 203 | ||
| 167 | H->p = H->buf; | 204 | H->p = H->buf; |
| 168 | H->c = 0; | 205 | H->c = 0; |
| @@ -173,7 +210,8 @@ static struct siphash *sip24_init(struct siphash *H, const struct sipkey *key) { | |||
| 173 | 210 | ||
| 174 | #define sip_endof(a) (&(a)[sizeof (a) / sizeof *(a)]) | 211 | #define sip_endof(a) (&(a)[sizeof (a) / sizeof *(a)]) |
| 175 | 212 | ||
| 176 | static struct siphash *sip24_update(struct siphash *H, const void *src, size_t len) { | 213 | static struct siphash *sip24_update(struct siphash *H, const void *src, |
| 214 | size_t len) { | ||
| 177 | const unsigned char *p = (const unsigned char *)src, *pe = p + len; | 215 | const unsigned char *p = (const unsigned char *)src, *pe = p + len; |
| 178 | uint64_t m; | 216 | uint64_t m; |
| 179 | 217 | ||
| @@ -198,17 +236,24 @@ static struct siphash *sip24_update(struct siphash *H, const void *src, size_t l | |||
| 198 | 236 | ||
| 199 | 237 | ||
| 200 | static uint64_t sip24_final(struct siphash *H) { | 238 | static uint64_t sip24_final(struct siphash *H) { |
| 201 | char left = H->p - H->buf; | 239 | const char left = (char)(H->p - H->buf); |
| 202 | uint64_t b = (H->c + left) << 56; | 240 | uint64_t b = (H->c + left) << 56; |
| 203 | 241 | ||
| 204 | switch (left) { | 242 | switch (left) { |
| 205 | case 7: b |= (uint64_t)H->buf[6] << 48; | 243 | case 7: b |= (uint64_t)H->buf[6] << 48; |
| 244 | /* fall through */ | ||
| 206 | case 6: b |= (uint64_t)H->buf[5] << 40; | 245 | case 6: b |= (uint64_t)H->buf[5] << 40; |
| 246 | /* fall through */ | ||
| 207 | case 5: b |= (uint64_t)H->buf[4] << 32; | 247 | case 5: b |= (uint64_t)H->buf[4] << 32; |
| 248 | /* fall through */ | ||
| 208 | case 4: b |= (uint64_t)H->buf[3] << 24; | 249 | case 4: b |= (uint64_t)H->buf[3] << 24; |
| 250 | /* fall through */ | ||
| 209 | case 3: b |= (uint64_t)H->buf[2] << 16; | 251 | case 3: b |= (uint64_t)H->buf[2] << 16; |
| 252 | /* fall through */ | ||
| 210 | case 2: b |= (uint64_t)H->buf[1] << 8; | 253 | case 2: b |= (uint64_t)H->buf[1] << 8; |
| 254 | /* fall through */ | ||
| 211 | case 1: b |= (uint64_t)H->buf[0] << 0; | 255 | case 1: b |= (uint64_t)H->buf[0] << 0; |
| 256 | /* fall through */ | ||
| 212 | case 0: break; | 257 | case 0: break; |
| 213 | } | 258 | } |
| 214 | 259 | ||
| @@ -222,7 +267,8 @@ static uint64_t sip24_final(struct siphash *H) { | |||
| 222 | } /* sip24_final() */ | 267 | } /* sip24_final() */ |
| 223 | 268 | ||
| 224 | 269 | ||
| 225 | static uint64_t siphash24(const void *src, size_t len, const struct sipkey *key) { | 270 | static uint64_t siphash24(const void *src, size_t len, |
| 271 | const struct sipkey *key) { | ||
| 226 | struct siphash state = SIPHASH_INITIALIZER; | 272 | struct siphash state = SIPHASH_INITIALIZER; |
| 227 | return sip24_final(sip24_update(sip24_init(&state, key), src, len)); | 273 | return sip24_final(sip24_update(sip24_init(&state, key), src, len)); |
| 228 | } /* siphash24() */ | 274 | } /* siphash24() */ |
| @@ -310,10 +356,11 @@ static int sip24_valid(void) { | |||
| 310 | struct sipkey k; | 356 | struct sipkey k; |
| 311 | size_t i; | 357 | size_t i; |
| 312 | 358 | ||
| 313 | sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011\012\013\014\015\016\017"); | 359 | sip_tokey(&k, "\000\001\002\003\004\005\006\007\010\011" |
| 360 | "\012\013\014\015\016\017"); | ||
| 314 | 361 | ||
| 315 | for (i = 0; i < sizeof in; ++i) { | 362 | for (i = 0; i < sizeof in; ++i) { |
| 316 | in[i] = i; | 363 | in[i] = (unsigned char)i; |
| 317 | 364 | ||
| 318 | if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i])) | 365 | if (siphash24(in, i, &k) != SIP_U8TO64_LE(vectors[i])) |
| 319 | return 0; | 366 | return 0; |
| @@ -323,12 +370,12 @@ static int sip24_valid(void) { | |||
| 323 | } /* sip24_valid() */ | 370 | } /* sip24_valid() */ |
| 324 | 371 | ||
| 325 | 372 | ||
| 326 | #if SIPHASH_MAIN | 373 | #ifdef SIPHASH_MAIN |
| 327 | 374 | ||
| 328 | #include <stdio.h> | 375 | #include <stdio.h> |
| 329 | 376 | ||
| 330 | int main(void) { | 377 | int main(void) { |
| 331 | int ok = sip24_valid(); | 378 | const int ok = sip24_valid(); |
| 332 | 379 | ||
| 333 | if (ok) | 380 | if (ok) |
| 334 | puts("OK"); | 381 | puts("OK"); |
diff --git a/3rdParty/Expat/src/utf8tab.h b/3rdParty/Expat/src/utf8tab.h index 7bb3e77..fa0bed6 100644 --- a/3rdParty/Expat/src/utf8tab.h +++ b/3rdParty/Expat/src/utf8tab.h | |||
| @@ -1,7 +1,34 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | */ | 3 | ___\ \/ /_ __ __ _| |_ |
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 4 | 20 | ||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 31 | */ | ||
| 5 | 32 | ||
| 6 | /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, | 33 | /* 0x80 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, |
| 7 | /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, | 34 | /* 0x84 */ BT_TRAIL, BT_TRAIL, BT_TRAIL, BT_TRAIL, |
diff --git a/3rdParty/Expat/src/winconfig.h b/3rdParty/Expat/src/winconfig.h index 9bf014d..28a043c 100644 --- a/3rdParty/Expat/src/winconfig.h +++ b/3rdParty/Expat/src/winconfig.h | |||
| @@ -1,10 +1,33 @@ | |||
| 1 | /*================================================================ | 1 | /* |
| 2 | ** Copyright 2000, Clark Cooper | 2 | __ __ _ |
| 3 | ** All rights reserved. | 3 | ___\ \/ /_ __ __ _| |_ |
| 4 | ** | 4 | / _ \\ /| '_ \ / _` | __| |
| 5 | ** This is free software. You are permitted to copy, distribute, or modify | 5 | | __// \| |_) | (_| | |_ |
| 6 | ** it under the terms of the MIT/X license (contained in the COPYING file | 6 | \___/_/\_\ .__/ \__,_|\__| |
| 7 | ** with this distribution.) | 7 | |_| XML parser |
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 8 | */ | 31 | */ |
| 9 | 32 | ||
| 10 | #ifndef WINCONFIG_H | 33 | #ifndef WINCONFIG_H |
| @@ -30,10 +53,6 @@ | |||
| 30 | /* we will assume all Windows platforms are little endian */ | 53 | /* we will assume all Windows platforms are little endian */ |
| 31 | #define BYTEORDER 1234 | 54 | #define BYTEORDER 1234 |
| 32 | 55 | ||
| 33 | /* Windows has memmove() available. */ | ||
| 34 | #define HAVE_MEMMOVE | ||
| 35 | |||
| 36 | |||
| 37 | #endif /* !defined(HAVE_EXPAT_CONFIG_H) */ | 56 | #endif /* !defined(HAVE_EXPAT_CONFIG_H) */ |
| 38 | 57 | ||
| 39 | 58 | ||
diff --git a/3rdParty/Expat/src/xmlparse.c b/3rdParty/Expat/src/xmlparse.c index 76f078e..02a11ae 100644 --- a/3rdParty/Expat/src/xmlparse.c +++ b/3rdParty/Expat/src/xmlparse.c | |||
| @@ -1,10 +1,38 @@ | |||
| 1 | /* Copyright (c) 1998, 1999, 2000 Thai Open Source Software Center Ltd | 1 | /* 69df5be70289a11fb834869ce4a91c23c1d9dd04baffcbd10e86742d149a080c (2.2.7+) |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | 3 | ___\ \/ /_ __ __ _| |_ | |
| 4 | 77fea421d361dca90041d0040ecf1dca651167fadf2af79e990e35168d70d933 (2.2.1+) | 4 | / _ \\ /| '_ \ / _` | __| |
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 5 | */ | 31 | */ |
| 6 | 32 | ||
| 7 | #define _GNU_SOURCE /* syscall prototype */ | 33 | #if !defined(_GNU_SOURCE) |
| 34 | # define _GNU_SOURCE 1 /* syscall prototype */ | ||
| 35 | #endif | ||
| 8 | 36 | ||
| 9 | #include <stddef.h> | 37 | #include <stddef.h> |
| 10 | #include <string.h> /* memset(), memcpy() */ | 38 | #include <string.h> /* memset(), memcpy() */ |
| @@ -19,6 +47,8 @@ | |||
| 19 | #include <sys/time.h> /* gettimeofday() */ | 47 | #include <sys/time.h> /* gettimeofday() */ |
| 20 | #include <sys/types.h> /* getpid() */ | 48 | #include <sys/types.h> /* getpid() */ |
| 21 | #include <unistd.h> /* getpid() */ | 49 | #include <unistd.h> /* getpid() */ |
| 50 | #include <fcntl.h> /* O_RDONLY */ | ||
| 51 | #include <errno.h> | ||
| 22 | #endif | 52 | #endif |
| 23 | 53 | ||
| 24 | #define XML_BUILDING_EXPAT 1 | 54 | #define XML_BUILDING_EXPAT 1 |
| @@ -33,6 +63,54 @@ | |||
| 33 | #include "expat.h" | 63 | #include "expat.h" |
| 34 | #include "siphash.h" | 64 | #include "siphash.h" |
| 35 | 65 | ||
| 66 | #if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) | ||
| 67 | # if defined(HAVE_GETRANDOM) | ||
| 68 | # include <sys/random.h> /* getrandom */ | ||
| 69 | # else | ||
| 70 | # include <unistd.h> /* syscall */ | ||
| 71 | # include <sys/syscall.h> /* SYS_getrandom */ | ||
| 72 | # endif | ||
| 73 | # if ! defined(GRND_NONBLOCK) | ||
| 74 | # define GRND_NONBLOCK 0x0001 | ||
| 75 | # endif /* defined(GRND_NONBLOCK) */ | ||
| 76 | #endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ | ||
| 77 | |||
| 78 | #if defined(HAVE_LIBBSD) \ | ||
| 79 | && (defined(HAVE_ARC4RANDOM_BUF) || defined(HAVE_ARC4RANDOM)) | ||
| 80 | # include <bsd/stdlib.h> | ||
| 81 | #endif | ||
| 82 | |||
| 83 | #if defined(_WIN32) && !defined(LOAD_LIBRARY_SEARCH_SYSTEM32) | ||
| 84 | # define LOAD_LIBRARY_SEARCH_SYSTEM32 0x00000800 | ||
| 85 | #endif | ||
| 86 | |||
| 87 | #if !defined(HAVE_GETRANDOM) && !defined(HAVE_SYSCALL_GETRANDOM) \ | ||
| 88 | && !defined(HAVE_ARC4RANDOM_BUF) && !defined(HAVE_ARC4RANDOM) \ | ||
| 89 | && !defined(XML_DEV_URANDOM) \ | ||
| 90 | && !defined(_WIN32) \ | ||
| 91 | && !defined(XML_POOR_ENTROPY) | ||
| 92 | # error \ | ||
| 93 | You do not have support for any sources of high quality entropy \ | ||
| 94 | enabled. For end user security, that is probably not what you want. \ | ||
| 95 | \ | ||
| 96 | Your options include: \ | ||
| 97 | * Linux + glibc >=2.25 (getrandom): HAVE_GETRANDOM, \ | ||
| 98 | * Linux + glibc <2.25 (syscall SYS_getrandom): HAVE_SYSCALL_GETRANDOM, \ | ||
| 99 | * BSD / macOS >=10.7 (arc4random_buf): HAVE_ARC4RANDOM_BUF, \ | ||
| 100 | * BSD / macOS <10.7 (arc4random): HAVE_ARC4RANDOM, \ | ||
| 101 | * libbsd (arc4random_buf): HAVE_ARC4RANDOM_BUF + HAVE_LIBBSD, \ | ||
| 102 | * libbsd (arc4random): HAVE_ARC4RANDOM + HAVE_LIBBSD, \ | ||
| 103 | * Linux / BSD / macOS (/dev/urandom): XML_DEV_URANDOM \ | ||
| 104 | * Windows (RtlGenRandom): _WIN32. \ | ||
| 105 | \ | ||
| 106 | If insist on not using any of these, bypass this error by defining \ | ||
| 107 | XML_POOR_ENTROPY; you have been warned. \ | ||
| 108 | \ | ||
| 109 | If you have reasons to patch this detection code away or need changes \ | ||
| 110 | to the build system, please open a bug. Thank you! | ||
| 111 | #endif | ||
| 112 | |||
| 113 | |||
| 36 | #ifdef XML_UNICODE | 114 | #ifdef XML_UNICODE |
| 37 | #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX | 115 | #define XML_ENCODE_MAX XML_UTF16_ENCODE_MAX |
| 38 | #define XmlConvert XmlUtf16Convert | 116 | #define XmlConvert XmlUtf16Convert |
| @@ -83,14 +161,8 @@ typedef char ICHAR; | |||
| 83 | /* Round up n to be a multiple of sz, where sz is a power of 2. */ | 161 | /* Round up n to be a multiple of sz, where sz is a power of 2. */ |
| 84 | #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) | 162 | #define ROUND_UP(n, sz) (((n) + ((sz) - 1)) & ~((sz) - 1)) |
| 85 | 163 | ||
| 86 | /* Handle the case where memmove() doesn't exist. */ | 164 | /* Do safe (NULL-aware) pointer arithmetic */ |
| 87 | #ifndef HAVE_MEMMOVE | 165 | #define EXPAT_SAFE_PTR_DIFF(p, q) (((p) && (q)) ? ((p) - (q)) : 0) |
| 88 | #ifdef HAVE_BCOPY | ||
| 89 | #define memmove(d,s,l) bcopy((s),(d),(l)) | ||
| 90 | #else | ||
| 91 | #error memmove does not exist on this platform, nor is a substitute available | ||
| 92 | #endif /* HAVE_BCOPY */ | ||
| 93 | #endif /* HAVE_MEMMOVE */ | ||
| 94 | 166 | ||
| 95 | #include "internal.h" | 167 | #include "internal.h" |
| 96 | #include "xmltok.h" | 168 | #include "xmltok.h" |
| @@ -392,7 +464,7 @@ setContext(XML_Parser parser, const XML_Char *context); | |||
| 392 | static void FASTCALL normalizePublicId(XML_Char *s); | 464 | static void FASTCALL normalizePublicId(XML_Char *s); |
| 393 | 465 | ||
| 394 | static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); | 466 | static DTD * dtdCreate(const XML_Memory_Handling_Suite *ms); |
| 395 | /* do not call if parentParser != NULL */ | 467 | /* do not call if m_parentParser != NULL */ |
| 396 | static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); | 468 | static void dtdReset(DTD *p, const XML_Memory_Handling_Suite *ms); |
| 397 | static void | 469 | static void |
| 398 | dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); | 470 | dtdDestroy(DTD *p, XML_Bool isDocEntity, const XML_Memory_Handling_Suite *ms); |
| @@ -436,6 +508,9 @@ static ELEMENT_TYPE * | |||
| 436 | getElementType(XML_Parser parser, const ENCODING *enc, | 508 | getElementType(XML_Parser parser, const ENCODING *enc, |
| 437 | const char *ptr, const char *end); | 509 | const char *ptr, const char *end); |
| 438 | 510 | ||
| 511 | static XML_Char *copyString(const XML_Char *s, | ||
| 512 | const XML_Memory_Handling_Suite *memsuite); | ||
| 513 | |||
| 439 | static unsigned long generate_hash_secret_salt(XML_Parser parser); | 514 | static unsigned long generate_hash_secret_salt(XML_Parser parser); |
| 440 | static XML_Bool startParsing(XML_Parser parser); | 515 | static XML_Bool startParsing(XML_Parser parser); |
| 441 | 516 | ||
| @@ -461,7 +536,7 @@ parserInit(XML_Parser parser, const XML_Char *encodingName); | |||
| 461 | : ((*((pool)->ptr)++ = c), 1)) | 536 | : ((*((pool)->ptr)++ = c), 1)) |
| 462 | 537 | ||
| 463 | struct XML_ParserStruct { | 538 | struct XML_ParserStruct { |
| 464 | /* The first member must be userData so that the XML_GetUserData | 539 | /* The first member must be m_userData so that the XML_GetUserData |
| 465 | macro works. */ | 540 | macro works. */ |
| 466 | void *m_userData; | 541 | void *m_userData; |
| 467 | void *m_handlerArg; | 542 | void *m_handlerArg; |
| @@ -471,7 +546,7 @@ struct XML_ParserStruct { | |||
| 471 | const char *m_bufferPtr; | 546 | const char *m_bufferPtr; |
| 472 | /* past last character to be parsed */ | 547 | /* past last character to be parsed */ |
| 473 | char *m_bufferEnd; | 548 | char *m_bufferEnd; |
| 474 | /* allocated end of buffer */ | 549 | /* allocated end of m_buffer */ |
| 475 | const char *m_bufferLim; | 550 | const char *m_bufferLim; |
| 476 | XML_Index m_parseEndByteIndex; | 551 | XML_Index m_parseEndByteIndex; |
| 477 | const char *m_parseEndPtr; | 552 | const char *m_parseEndPtr; |
| @@ -563,113 +638,10 @@ struct XML_ParserStruct { | |||
| 563 | unsigned long m_hash_secret_salt; | 638 | unsigned long m_hash_secret_salt; |
| 564 | }; | 639 | }; |
| 565 | 640 | ||
| 566 | #define MALLOC(s) (parser->m_mem.malloc_fcn((s))) | 641 | #define MALLOC(parser, s) (parser->m_mem.malloc_fcn((s))) |
| 567 | #define REALLOC(p,s) (parser->m_mem.realloc_fcn((p),(s))) | 642 | #define REALLOC(parser, p, s) (parser->m_mem.realloc_fcn((p),(s))) |
| 568 | #define FREE(p) (parser->m_mem.free_fcn((p))) | 643 | #define FREE(parser, p) (parser->m_mem.free_fcn((p))) |
| 569 | 644 | ||
| 570 | #define userData (parser->m_userData) | ||
| 571 | #define handlerArg (parser->m_handlerArg) | ||
| 572 | #define startElementHandler (parser->m_startElementHandler) | ||
| 573 | #define endElementHandler (parser->m_endElementHandler) | ||
| 574 | #define characterDataHandler (parser->m_characterDataHandler) | ||
| 575 | #define processingInstructionHandler \ | ||
| 576 | (parser->m_processingInstructionHandler) | ||
| 577 | #define commentHandler (parser->m_commentHandler) | ||
| 578 | #define startCdataSectionHandler \ | ||
| 579 | (parser->m_startCdataSectionHandler) | ||
| 580 | #define endCdataSectionHandler (parser->m_endCdataSectionHandler) | ||
| 581 | #define defaultHandler (parser->m_defaultHandler) | ||
| 582 | #define startDoctypeDeclHandler (parser->m_startDoctypeDeclHandler) | ||
| 583 | #define endDoctypeDeclHandler (parser->m_endDoctypeDeclHandler) | ||
| 584 | #define unparsedEntityDeclHandler \ | ||
| 585 | (parser->m_unparsedEntityDeclHandler) | ||
| 586 | #define notationDeclHandler (parser->m_notationDeclHandler) | ||
| 587 | #define startNamespaceDeclHandler \ | ||
| 588 | (parser->m_startNamespaceDeclHandler) | ||
| 589 | #define endNamespaceDeclHandler (parser->m_endNamespaceDeclHandler) | ||
| 590 | #define notStandaloneHandler (parser->m_notStandaloneHandler) | ||
| 591 | #define externalEntityRefHandler \ | ||
| 592 | (parser->m_externalEntityRefHandler) | ||
| 593 | #define externalEntityRefHandlerArg \ | ||
| 594 | (parser->m_externalEntityRefHandlerArg) | ||
| 595 | #define internalEntityRefHandler \ | ||
| 596 | (parser->m_internalEntityRefHandler) | ||
| 597 | #define skippedEntityHandler (parser->m_skippedEntityHandler) | ||
| 598 | #define unknownEncodingHandler (parser->m_unknownEncodingHandler) | ||
| 599 | #define elementDeclHandler (parser->m_elementDeclHandler) | ||
| 600 | #define attlistDeclHandler (parser->m_attlistDeclHandler) | ||
| 601 | #define entityDeclHandler (parser->m_entityDeclHandler) | ||
| 602 | #define xmlDeclHandler (parser->m_xmlDeclHandler) | ||
| 603 | #define encoding (parser->m_encoding) | ||
| 604 | #define initEncoding (parser->m_initEncoding) | ||
| 605 | #define internalEncoding (parser->m_internalEncoding) | ||
| 606 | #define unknownEncodingMem (parser->m_unknownEncodingMem) | ||
| 607 | #define unknownEncodingData (parser->m_unknownEncodingData) | ||
| 608 | #define unknownEncodingHandlerData \ | ||
| 609 | (parser->m_unknownEncodingHandlerData) | ||
| 610 | #define unknownEncodingRelease (parser->m_unknownEncodingRelease) | ||
| 611 | #define protocolEncodingName (parser->m_protocolEncodingName) | ||
| 612 | #define ns (parser->m_ns) | ||
| 613 | #define ns_triplets (parser->m_ns_triplets) | ||
| 614 | #define prologState (parser->m_prologState) | ||
| 615 | #define processor (parser->m_processor) | ||
| 616 | #define errorCode (parser->m_errorCode) | ||
| 617 | #define eventPtr (parser->m_eventPtr) | ||
| 618 | #define eventEndPtr (parser->m_eventEndPtr) | ||
| 619 | #define positionPtr (parser->m_positionPtr) | ||
| 620 | #define position (parser->m_position) | ||
| 621 | #define openInternalEntities (parser->m_openInternalEntities) | ||
| 622 | #define freeInternalEntities (parser->m_freeInternalEntities) | ||
| 623 | #define defaultExpandInternalEntities \ | ||
| 624 | (parser->m_defaultExpandInternalEntities) | ||
| 625 | #define tagLevel (parser->m_tagLevel) | ||
| 626 | #define buffer (parser->m_buffer) | ||
| 627 | #define bufferPtr (parser->m_bufferPtr) | ||
| 628 | #define bufferEnd (parser->m_bufferEnd) | ||
| 629 | #define parseEndByteIndex (parser->m_parseEndByteIndex) | ||
| 630 | #define parseEndPtr (parser->m_parseEndPtr) | ||
| 631 | #define bufferLim (parser->m_bufferLim) | ||
| 632 | #define dataBuf (parser->m_dataBuf) | ||
| 633 | #define dataBufEnd (parser->m_dataBufEnd) | ||
| 634 | #define _dtd (parser->m_dtd) | ||
| 635 | #define curBase (parser->m_curBase) | ||
| 636 | #define declEntity (parser->m_declEntity) | ||
| 637 | #define doctypeName (parser->m_doctypeName) | ||
| 638 | #define doctypeSysid (parser->m_doctypeSysid) | ||
| 639 | #define doctypePubid (parser->m_doctypePubid) | ||
| 640 | #define declAttributeType (parser->m_declAttributeType) | ||
| 641 | #define declNotationName (parser->m_declNotationName) | ||
| 642 | #define declNotationPublicId (parser->m_declNotationPublicId) | ||
| 643 | #define declElementType (parser->m_declElementType) | ||
| 644 | #define declAttributeId (parser->m_declAttributeId) | ||
| 645 | #define declAttributeIsCdata (parser->m_declAttributeIsCdata) | ||
| 646 | #define declAttributeIsId (parser->m_declAttributeIsId) | ||
| 647 | #define freeTagList (parser->m_freeTagList) | ||
| 648 | #define freeBindingList (parser->m_freeBindingList) | ||
| 649 | #define inheritedBindings (parser->m_inheritedBindings) | ||
| 650 | #define tagStack (parser->m_tagStack) | ||
| 651 | #define atts (parser->m_atts) | ||
| 652 | #define attsSize (parser->m_attsSize) | ||
| 653 | #define nSpecifiedAtts (parser->m_nSpecifiedAtts) | ||
| 654 | #define idAttIndex (parser->m_idAttIndex) | ||
| 655 | #define nsAtts (parser->m_nsAtts) | ||
| 656 | #define nsAttsVersion (parser->m_nsAttsVersion) | ||
| 657 | #define nsAttsPower (parser->m_nsAttsPower) | ||
| 658 | #define attInfo (parser->m_attInfo) | ||
| 659 | #define tempPool (parser->m_tempPool) | ||
| 660 | #define temp2Pool (parser->m_temp2Pool) | ||
| 661 | #define groupConnector (parser->m_groupConnector) | ||
| 662 | #define groupSize (parser->m_groupSize) | ||
| 663 | #define namespaceSeparator (parser->m_namespaceSeparator) | ||
| 664 | #define parentParser (parser->m_parentParser) | ||
| 665 | #define ps_parsing (parser->m_parsingStatus.parsing) | ||
| 666 | #define ps_finalBuffer (parser->m_parsingStatus.finalBuffer) | ||
| 667 | #ifdef XML_DTD | ||
| 668 | #define isParamEntity (parser->m_isParamEntity) | ||
| 669 | #define useForeignDTD (parser->m_useForeignDTD) | ||
| 670 | #define paramEntityParsing (parser->m_paramEntityParsing) | ||
| 671 | #endif /* XML_DTD */ | ||
| 672 | #define hash_secret_salt (parser->m_hash_secret_salt) | ||
| 673 | 645 | ||
| 674 | XML_Parser XMLCALL | 646 | XML_Parser XMLCALL |
| 675 | XML_ParserCreate(const XML_Char *encodingName) | 647 | XML_ParserCreate(const XML_Char *encodingName) |
| @@ -695,22 +667,17 @@ static const XML_Char implicitContext[] = { | |||
| 695 | }; | 667 | }; |
| 696 | 668 | ||
| 697 | 669 | ||
| 698 | #if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) | 670 | /* To avoid warnings about unused functions: */ |
| 699 | # include <errno.h> | 671 | #if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) |
| 700 | 672 | ||
| 701 | # if defined(HAVE_GETRANDOM) | 673 | #if defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) |
| 702 | # include <sys/random.h> /* getrandom */ | ||
| 703 | # else | ||
| 704 | # include <unistd.h> /* syscall */ | ||
| 705 | # include <sys/syscall.h> /* SYS_getrandom */ | ||
| 706 | # endif | ||
| 707 | 674 | ||
| 708 | /* Obtain entropy on Linux 3.17+ */ | 675 | /* Obtain entropy on Linux 3.17+ */ |
| 709 | static int | 676 | static int |
| 710 | writeRandomBytes_getrandom(void * target, size_t count) { | 677 | writeRandomBytes_getrandom_nonblock(void * target, size_t count) { |
| 711 | int success = 0; /* full count bytes written? */ | 678 | int success = 0; /* full count bytes written? */ |
| 712 | size_t bytesWrittenTotal = 0; | 679 | size_t bytesWrittenTotal = 0; |
| 713 | const unsigned int getrandomFlags = 0; | 680 | const unsigned int getrandomFlags = GRND_NONBLOCK; |
| 714 | 681 | ||
| 715 | do { | 682 | do { |
| 716 | void * const currentTarget = (void*)((char*)target + bytesWrittenTotal); | 683 | void * const currentTarget = (void*)((char*)target + bytesWrittenTotal); |
| @@ -728,7 +695,7 @@ writeRandomBytes_getrandom(void * target, size_t count) { | |||
| 728 | if (bytesWrittenTotal >= count) | 695 | if (bytesWrittenTotal >= count) |
| 729 | success = 1; | 696 | success = 1; |
| 730 | } | 697 | } |
| 731 | } while (! success && (errno == EINTR || errno == EAGAIN)); | 698 | } while (! success && (errno == EINTR)); |
| 732 | 699 | ||
| 733 | return success; | 700 | return success; |
| 734 | } | 701 | } |
| @@ -736,12 +703,69 @@ writeRandomBytes_getrandom(void * target, size_t count) { | |||
| 736 | #endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ | 703 | #endif /* defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) */ |
| 737 | 704 | ||
| 738 | 705 | ||
| 706 | #if ! defined(_WIN32) && defined(XML_DEV_URANDOM) | ||
| 707 | |||
| 708 | /* Extract entropy from /dev/urandom */ | ||
| 709 | static int | ||
| 710 | writeRandomBytes_dev_urandom(void * target, size_t count) { | ||
| 711 | int success = 0; /* full count bytes written? */ | ||
| 712 | size_t bytesWrittenTotal = 0; | ||
| 713 | |||
| 714 | const int fd = open("/dev/urandom", O_RDONLY); | ||
| 715 | if (fd < 0) { | ||
| 716 | return 0; | ||
| 717 | } | ||
| 718 | |||
| 719 | do { | ||
| 720 | void * const currentTarget = (void*)((char*)target + bytesWrittenTotal); | ||
| 721 | const size_t bytesToWrite = count - bytesWrittenTotal; | ||
| 722 | |||
| 723 | const ssize_t bytesWrittenMore = read(fd, currentTarget, bytesToWrite); | ||
| 724 | |||
| 725 | if (bytesWrittenMore > 0) { | ||
| 726 | bytesWrittenTotal += bytesWrittenMore; | ||
| 727 | if (bytesWrittenTotal >= count) | ||
| 728 | success = 1; | ||
| 729 | } | ||
| 730 | } while (! success && (errno == EINTR)); | ||
| 731 | |||
| 732 | close(fd); | ||
| 733 | return success; | ||
| 734 | } | ||
| 735 | |||
| 736 | #endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ | ||
| 737 | |||
| 738 | #endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ | ||
| 739 | |||
| 740 | |||
| 741 | #if defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) | ||
| 742 | |||
| 743 | static void | ||
| 744 | writeRandomBytes_arc4random(void * target, size_t count) { | ||
| 745 | size_t bytesWrittenTotal = 0; | ||
| 746 | |||
| 747 | while (bytesWrittenTotal < count) { | ||
| 748 | const uint32_t random32 = arc4random(); | ||
| 749 | size_t i = 0; | ||
| 750 | |||
| 751 | for (; (i < sizeof(random32)) && (bytesWrittenTotal < count); | ||
| 752 | i++, bytesWrittenTotal++) { | ||
| 753 | const uint8_t random8 = (uint8_t)(random32 >> (i * 8)); | ||
| 754 | ((uint8_t *)target)[bytesWrittenTotal] = random8; | ||
| 755 | } | ||
| 756 | } | ||
| 757 | } | ||
| 758 | |||
| 759 | #endif /* defined(HAVE_ARC4RANDOM) && ! defined(HAVE_ARC4RANDOM_BUF) */ | ||
| 760 | |||
| 761 | |||
| 739 | #ifdef _WIN32 | 762 | #ifdef _WIN32 |
| 740 | 763 | ||
| 741 | typedef BOOLEAN (APIENTRY *RTLGENRANDOM_FUNC)(PVOID, ULONG); | 764 | typedef BOOLEAN (APIENTRY *RTLGENRANDOM_FUNC)(PVOID, ULONG); |
| 765 | HMODULE _Expat_LoadLibrary(LPCTSTR filename); /* see loadlibrary.c */ | ||
| 742 | 766 | ||
| 743 | /* Obtain entropy on Windows XP / Windows Server 2003 and later. | 767 | /* Obtain entropy on Windows XP / Windows Server 2003 and later. |
| 744 | * Hint on RtlGenRandom and the following article from libsodioum. | 768 | * Hint on RtlGenRandom and the following article from libsodium. |
| 745 | * | 769 | * |
| 746 | * Michael Howard: Cryptographically Secure Random number on Windows without using CryptoAPI | 770 | * Michael Howard: Cryptographically Secure Random number on Windows without using CryptoAPI |
| 747 | * https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/ | 771 | * https://blogs.msdn.microsoft.com/michael_howard/2005/01/14/cryptographically-secure-random-number-on-windows-without-using-cryptoapi/ |
| @@ -749,7 +773,7 @@ typedef BOOLEAN (APIENTRY *RTLGENRANDOM_FUNC)(PVOID, ULONG); | |||
| 749 | static int | 773 | static int |
| 750 | writeRandomBytes_RtlGenRandom(void * target, size_t count) { | 774 | writeRandomBytes_RtlGenRandom(void * target, size_t count) { |
| 751 | int success = 0; /* full count bytes written? */ | 775 | int success = 0; /* full count bytes written? */ |
| 752 | const HMODULE advapi32 = LoadLibrary("ADVAPI32.DLL"); | 776 | const HMODULE advapi32 = _Expat_LoadLibrary(TEXT("ADVAPI32.DLL")); |
| 753 | 777 | ||
| 754 | if (advapi32) { | 778 | if (advapi32) { |
| 755 | const RTLGENRANDOM_FUNC RtlGenRandom | 779 | const RTLGENRANDOM_FUNC RtlGenRandom |
| @@ -768,6 +792,8 @@ writeRandomBytes_RtlGenRandom(void * target, size_t count) { | |||
| 768 | #endif /* _WIN32 */ | 792 | #endif /* _WIN32 */ |
| 769 | 793 | ||
| 770 | 794 | ||
| 795 | #if ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) | ||
| 796 | |||
| 771 | static unsigned long | 797 | static unsigned long |
| 772 | gather_time_entropy(void) | 798 | gather_time_entropy(void) |
| 773 | { | 799 | { |
| @@ -780,16 +806,20 @@ gather_time_entropy(void) | |||
| 780 | int gettimeofday_res; | 806 | int gettimeofday_res; |
| 781 | 807 | ||
| 782 | gettimeofday_res = gettimeofday(&tv, NULL); | 808 | gettimeofday_res = gettimeofday(&tv, NULL); |
| 809 | |||
| 810 | #if defined(NDEBUG) | ||
| 811 | (void)gettimeofday_res; | ||
| 812 | #else | ||
| 783 | assert (gettimeofday_res == 0); | 813 | assert (gettimeofday_res == 0); |
| 814 | #endif /* defined(NDEBUG) */ | ||
| 784 | 815 | ||
| 785 | /* Microseconds time is <20 bits entropy */ | 816 | /* Microseconds time is <20 bits entropy */ |
| 786 | return tv.tv_usec; | 817 | return tv.tv_usec; |
| 787 | #endif | 818 | #endif |
| 788 | } | 819 | } |
| 789 | 820 | ||
| 790 | #if defined(HAVE_ARC4RANDOM_BUF) && defined(HAVE_LIBBSD) | 821 | #endif /* ! defined(HAVE_ARC4RANDOM_BUF) && ! defined(HAVE_ARC4RANDOM) */ |
| 791 | # include <bsd/stdlib.h> | 822 | |
| 792 | #endif | ||
| 793 | 823 | ||
| 794 | static unsigned long | 824 | static unsigned long |
| 795 | ENTROPY_DEBUG(const char * label, unsigned long entropy) { | 825 | ENTROPY_DEBUG(const char * label, unsigned long entropy) { |
| @@ -808,10 +838,14 @@ generate_hash_secret_salt(XML_Parser parser) | |||
| 808 | { | 838 | { |
| 809 | unsigned long entropy; | 839 | unsigned long entropy; |
| 810 | (void)parser; | 840 | (void)parser; |
| 811 | #if defined(HAVE_ARC4RANDOM_BUF) || defined(__CloudABI__) | 841 | |
| 812 | (void)gather_time_entropy; | 842 | /* "Failproof" high quality providers: */ |
| 843 | #if defined(HAVE_ARC4RANDOM_BUF) | ||
| 813 | arc4random_buf(&entropy, sizeof(entropy)); | 844 | arc4random_buf(&entropy, sizeof(entropy)); |
| 814 | return ENTROPY_DEBUG("arc4random_buf", entropy); | 845 | return ENTROPY_DEBUG("arc4random_buf", entropy); |
| 846 | #elif defined(HAVE_ARC4RANDOM) | ||
| 847 | writeRandomBytes_arc4random((void *)&entropy, sizeof(entropy)); | ||
| 848 | return ENTROPY_DEBUG("arc4random", entropy); | ||
| 815 | #else | 849 | #else |
| 816 | /* Try high quality providers first .. */ | 850 | /* Try high quality providers first .. */ |
| 817 | #ifdef _WIN32 | 851 | #ifdef _WIN32 |
| @@ -819,10 +853,15 @@ generate_hash_secret_salt(XML_Parser parser) | |||
| 819 | return ENTROPY_DEBUG("RtlGenRandom", entropy); | 853 | return ENTROPY_DEBUG("RtlGenRandom", entropy); |
| 820 | } | 854 | } |
| 821 | #elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) | 855 | #elif defined(HAVE_GETRANDOM) || defined(HAVE_SYSCALL_GETRANDOM) |
| 822 | if (writeRandomBytes_getrandom((void *)&entropy, sizeof(entropy))) { | 856 | if (writeRandomBytes_getrandom_nonblock((void *)&entropy, sizeof(entropy))) { |
| 823 | return ENTROPY_DEBUG("getrandom", entropy); | 857 | return ENTROPY_DEBUG("getrandom", entropy); |
| 824 | } | 858 | } |
| 825 | #endif | 859 | #endif |
| 860 | #if ! defined(_WIN32) && defined(XML_DEV_URANDOM) | ||
| 861 | if (writeRandomBytes_dev_urandom((void *)&entropy, sizeof(entropy))) { | ||
| 862 | return ENTROPY_DEBUG("/dev/urandom", entropy); | ||
| 863 | } | ||
| 864 | #endif /* ! defined(_WIN32) && defined(XML_DEV_URANDOM) */ | ||
| 826 | /* .. and self-made low quality for backup: */ | 865 | /* .. and self-made low quality for backup: */ |
| 827 | 866 | ||
| 828 | /* Process ID is 0 bits entropy if attacker has local access */ | 867 | /* Process ID is 0 bits entropy if attacker has local access */ |
| @@ -833,7 +872,7 @@ generate_hash_secret_salt(XML_Parser parser) | |||
| 833 | return ENTROPY_DEBUG("fallback(4)", entropy * 2147483647); | 872 | return ENTROPY_DEBUG("fallback(4)", entropy * 2147483647); |
| 834 | } else { | 873 | } else { |
| 835 | return ENTROPY_DEBUG("fallback(8)", | 874 | return ENTROPY_DEBUG("fallback(8)", |
| 836 | entropy * (unsigned long)2305843009213693951); | 875 | entropy * (unsigned long)2305843009213693951ULL); |
| 837 | } | 876 | } |
| 838 | #endif | 877 | #endif |
| 839 | } | 878 | } |
| @@ -849,9 +888,9 @@ static XML_Bool /* only valid for root parser */ | |||
| 849 | startParsing(XML_Parser parser) | 888 | startParsing(XML_Parser parser) |
| 850 | { | 889 | { |
| 851 | /* hash functions must be initialized before setContext() is called */ | 890 | /* hash functions must be initialized before setContext() is called */ |
| 852 | if (hash_secret_salt == 0) | 891 | if (parser->m_hash_secret_salt == 0) |
| 853 | hash_secret_salt = generate_hash_secret_salt(parser); | 892 | parser->m_hash_secret_salt = generate_hash_secret_salt(parser); |
| 854 | if (ns) { | 893 | if (parser->m_ns) { |
| 855 | /* implicit context only set for root parser, since child | 894 | /* implicit context only set for root parser, since child |
| 856 | parsers (i.e. external entity parsers) will inherit it | 895 | parsers (i.e. external entity parsers) will inherit it |
| 857 | */ | 896 | */ |
| @@ -901,83 +940,85 @@ parserCreate(const XML_Char *encodingName, | |||
| 901 | if (!parser) | 940 | if (!parser) |
| 902 | return parser; | 941 | return parser; |
| 903 | 942 | ||
| 904 | buffer = NULL; | 943 | parser->m_buffer = NULL; |
| 905 | bufferLim = NULL; | 944 | parser->m_bufferLim = NULL; |
| 906 | 945 | ||
| 907 | attsSize = INIT_ATTS_SIZE; | 946 | parser->m_attsSize = INIT_ATTS_SIZE; |
| 908 | atts = (ATTRIBUTE *)MALLOC(attsSize * sizeof(ATTRIBUTE)); | 947 | parser->m_atts = (ATTRIBUTE *)MALLOC(parser, parser->m_attsSize * sizeof(ATTRIBUTE)); |
| 909 | if (atts == NULL) { | 948 | if (parser->m_atts == NULL) { |
| 910 | FREE(parser); | 949 | FREE(parser, parser); |
| 911 | return NULL; | 950 | return NULL; |
| 912 | } | 951 | } |
| 913 | #ifdef XML_ATTR_INFO | 952 | #ifdef XML_ATTR_INFO |
| 914 | attInfo = (XML_AttrInfo*)MALLOC(attsSize * sizeof(XML_AttrInfo)); | 953 | parser->m_attInfo = (XML_AttrInfo*)MALLOC(parser, parser->m_attsSize * sizeof(XML_AttrInfo)); |
| 915 | if (attInfo == NULL) { | 954 | if (parser->m_attInfo == NULL) { |
| 916 | FREE(atts); | 955 | FREE(parser, parser->m_atts); |
| 917 | FREE(parser); | 956 | FREE(parser, parser); |
| 918 | return NULL; | 957 | return NULL; |
| 919 | } | 958 | } |
| 920 | #endif | 959 | #endif |
| 921 | dataBuf = (XML_Char *)MALLOC(INIT_DATA_BUF_SIZE * sizeof(XML_Char)); | 960 | parser->m_dataBuf = (XML_Char *)MALLOC(parser, INIT_DATA_BUF_SIZE * sizeof(XML_Char)); |
| 922 | if (dataBuf == NULL) { | 961 | if (parser->m_dataBuf == NULL) { |
| 923 | FREE(atts); | 962 | FREE(parser, parser->m_atts); |
| 924 | #ifdef XML_ATTR_INFO | 963 | #ifdef XML_ATTR_INFO |
| 925 | FREE(attInfo); | 964 | FREE(parser, parser->m_attInfo); |
| 926 | #endif | 965 | #endif |
| 927 | FREE(parser); | 966 | FREE(parser, parser); |
| 928 | return NULL; | 967 | return NULL; |
| 929 | } | 968 | } |
| 930 | dataBufEnd = dataBuf + INIT_DATA_BUF_SIZE; | 969 | parser->m_dataBufEnd = parser->m_dataBuf + INIT_DATA_BUF_SIZE; |
| 931 | 970 | ||
| 932 | if (dtd) | 971 | if (dtd) |
| 933 | _dtd = dtd; | 972 | parser->m_dtd = dtd; |
| 934 | else { | 973 | else { |
| 935 | _dtd = dtdCreate(&parser->m_mem); | 974 | parser->m_dtd = dtdCreate(&parser->m_mem); |
| 936 | if (_dtd == NULL) { | 975 | if (parser->m_dtd == NULL) { |
| 937 | FREE(dataBuf); | 976 | FREE(parser, parser->m_dataBuf); |
| 938 | FREE(atts); | 977 | FREE(parser, parser->m_atts); |
| 939 | #ifdef XML_ATTR_INFO | 978 | #ifdef XML_ATTR_INFO |
| 940 | FREE(attInfo); | 979 | FREE(parser, parser->m_attInfo); |
| 941 | #endif | 980 | #endif |
| 942 | FREE(parser); | 981 | FREE(parser, parser); |
| 943 | return NULL; | 982 | return NULL; |
| 944 | } | 983 | } |
| 945 | } | 984 | } |
| 946 | 985 | ||
| 947 | freeBindingList = NULL; | 986 | parser->m_freeBindingList = NULL; |
| 948 | freeTagList = NULL; | 987 | parser->m_freeTagList = NULL; |
| 949 | freeInternalEntities = NULL; | 988 | parser->m_freeInternalEntities = NULL; |
| 989 | |||
| 990 | parser->m_groupSize = 0; | ||
| 991 | parser->m_groupConnector = NULL; | ||
| 950 | 992 | ||
| 951 | groupSize = 0; | 993 | parser->m_unknownEncodingHandler = NULL; |
| 952 | groupConnector = NULL; | 994 | parser->m_unknownEncodingHandlerData = NULL; |
| 953 | 995 | ||
| 954 | unknownEncodingHandler = NULL; | 996 | parser->m_namespaceSeparator = ASCII_EXCL; |
| 955 | unknownEncodingHandlerData = NULL; | 997 | parser->m_ns = XML_FALSE; |
| 998 | parser->m_ns_triplets = XML_FALSE; | ||
| 956 | 999 | ||
| 957 | namespaceSeparator = ASCII_EXCL; | 1000 | parser->m_nsAtts = NULL; |
| 958 | ns = XML_FALSE; | 1001 | parser->m_nsAttsVersion = 0; |
| 959 | ns_triplets = XML_FALSE; | 1002 | parser->m_nsAttsPower = 0; |
| 960 | 1003 | ||
| 961 | nsAtts = NULL; | 1004 | parser->m_protocolEncodingName = NULL; |
| 962 | nsAttsVersion = 0; | ||
| 963 | nsAttsPower = 0; | ||
| 964 | 1005 | ||
| 965 | poolInit(&tempPool, &(parser->m_mem)); | 1006 | poolInit(&parser->m_tempPool, &(parser->m_mem)); |
| 966 | poolInit(&temp2Pool, &(parser->m_mem)); | 1007 | poolInit(&parser->m_temp2Pool, &(parser->m_mem)); |
| 967 | parserInit(parser, encodingName); | 1008 | parserInit(parser, encodingName); |
| 968 | 1009 | ||
| 969 | if (encodingName && !protocolEncodingName) { | 1010 | if (encodingName && !parser->m_protocolEncodingName) { |
| 970 | XML_ParserFree(parser); | 1011 | XML_ParserFree(parser); |
| 971 | return NULL; | 1012 | return NULL; |
| 972 | } | 1013 | } |
| 973 | 1014 | ||
| 974 | if (nameSep) { | 1015 | if (nameSep) { |
| 975 | ns = XML_TRUE; | 1016 | parser->m_ns = XML_TRUE; |
| 976 | internalEncoding = XmlGetInternalEncodingNS(); | 1017 | parser->m_internalEncoding = XmlGetInternalEncodingNS(); |
| 977 | namespaceSeparator = *nameSep; | 1018 | parser->m_namespaceSeparator = *nameSep; |
| 978 | } | 1019 | } |
| 979 | else { | 1020 | else { |
| 980 | internalEncoding = XmlGetInternalEncoding(); | 1021 | parser->m_internalEncoding = XmlGetInternalEncoding(); |
| 981 | } | 1022 | } |
| 982 | 1023 | ||
| 983 | return parser; | 1024 | return parser; |
| @@ -986,85 +1027,85 @@ parserCreate(const XML_Char *encodingName, | |||
| 986 | static void | 1027 | static void |
| 987 | parserInit(XML_Parser parser, const XML_Char *encodingName) | 1028 | parserInit(XML_Parser parser, const XML_Char *encodingName) |
| 988 | { | 1029 | { |
| 989 | processor = prologInitProcessor; | 1030 | parser->m_processor = prologInitProcessor; |
| 990 | XmlPrologStateInit(&prologState); | 1031 | XmlPrologStateInit(&parser->m_prologState); |
| 991 | protocolEncodingName = (encodingName != NULL | 1032 | if (encodingName != NULL) { |
| 992 | ? poolCopyString(&tempPool, encodingName) | 1033 | parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem)); |
| 993 | : NULL); | 1034 | } |
| 994 | curBase = NULL; | 1035 | parser->m_curBase = NULL; |
| 995 | XmlInitEncoding(&initEncoding, &encoding, 0); | 1036 | XmlInitEncoding(&parser->m_initEncoding, &parser->m_encoding, 0); |
| 996 | userData = NULL; | 1037 | parser->m_userData = NULL; |
| 997 | handlerArg = NULL; | 1038 | parser->m_handlerArg = NULL; |
| 998 | startElementHandler = NULL; | 1039 | parser->m_startElementHandler = NULL; |
| 999 | endElementHandler = NULL; | 1040 | parser->m_endElementHandler = NULL; |
| 1000 | characterDataHandler = NULL; | 1041 | parser->m_characterDataHandler = NULL; |
| 1001 | processingInstructionHandler = NULL; | 1042 | parser->m_processingInstructionHandler = NULL; |
| 1002 | commentHandler = NULL; | 1043 | parser->m_commentHandler = NULL; |
| 1003 | startCdataSectionHandler = NULL; | 1044 | parser->m_startCdataSectionHandler = NULL; |
| 1004 | endCdataSectionHandler = NULL; | 1045 | parser->m_endCdataSectionHandler = NULL; |
| 1005 | defaultHandler = NULL; | 1046 | parser->m_defaultHandler = NULL; |
| 1006 | startDoctypeDeclHandler = NULL; | 1047 | parser->m_startDoctypeDeclHandler = NULL; |
| 1007 | endDoctypeDeclHandler = NULL; | 1048 | parser->m_endDoctypeDeclHandler = NULL; |
| 1008 | unparsedEntityDeclHandler = NULL; | 1049 | parser->m_unparsedEntityDeclHandler = NULL; |
| 1009 | notationDeclHandler = NULL; | 1050 | parser->m_notationDeclHandler = NULL; |
| 1010 | startNamespaceDeclHandler = NULL; | 1051 | parser->m_startNamespaceDeclHandler = NULL; |
| 1011 | endNamespaceDeclHandler = NULL; | 1052 | parser->m_endNamespaceDeclHandler = NULL; |
| 1012 | notStandaloneHandler = NULL; | 1053 | parser->m_notStandaloneHandler = NULL; |
| 1013 | externalEntityRefHandler = NULL; | 1054 | parser->m_externalEntityRefHandler = NULL; |
| 1014 | externalEntityRefHandlerArg = parser; | 1055 | parser->m_externalEntityRefHandlerArg = parser; |
| 1015 | skippedEntityHandler = NULL; | 1056 | parser->m_skippedEntityHandler = NULL; |
| 1016 | elementDeclHandler = NULL; | 1057 | parser->m_elementDeclHandler = NULL; |
| 1017 | attlistDeclHandler = NULL; | 1058 | parser->m_attlistDeclHandler = NULL; |
| 1018 | entityDeclHandler = NULL; | 1059 | parser->m_entityDeclHandler = NULL; |
| 1019 | xmlDeclHandler = NULL; | 1060 | parser->m_xmlDeclHandler = NULL; |
| 1020 | bufferPtr = buffer; | 1061 | parser->m_bufferPtr = parser->m_buffer; |
| 1021 | bufferEnd = buffer; | 1062 | parser->m_bufferEnd = parser->m_buffer; |
| 1022 | parseEndByteIndex = 0; | 1063 | parser->m_parseEndByteIndex = 0; |
| 1023 | parseEndPtr = NULL; | 1064 | parser->m_parseEndPtr = NULL; |
| 1024 | declElementType = NULL; | 1065 | parser->m_declElementType = NULL; |
| 1025 | declAttributeId = NULL; | 1066 | parser->m_declAttributeId = NULL; |
| 1026 | declEntity = NULL; | 1067 | parser->m_declEntity = NULL; |
| 1027 | doctypeName = NULL; | 1068 | parser->m_doctypeName = NULL; |
| 1028 | doctypeSysid = NULL; | 1069 | parser->m_doctypeSysid = NULL; |
| 1029 | doctypePubid = NULL; | 1070 | parser->m_doctypePubid = NULL; |
| 1030 | declAttributeType = NULL; | 1071 | parser->m_declAttributeType = NULL; |
| 1031 | declNotationName = NULL; | 1072 | parser->m_declNotationName = NULL; |
| 1032 | declNotationPublicId = NULL; | 1073 | parser->m_declNotationPublicId = NULL; |
| 1033 | declAttributeIsCdata = XML_FALSE; | 1074 | parser->m_declAttributeIsCdata = XML_FALSE; |
| 1034 | declAttributeIsId = XML_FALSE; | 1075 | parser->m_declAttributeIsId = XML_FALSE; |
| 1035 | memset(&position, 0, sizeof(POSITION)); | 1076 | memset(&parser->m_position, 0, sizeof(POSITION)); |
| 1036 | errorCode = XML_ERROR_NONE; | 1077 | parser->m_errorCode = XML_ERROR_NONE; |
| 1037 | eventPtr = NULL; | 1078 | parser->m_eventPtr = NULL; |
| 1038 | eventEndPtr = NULL; | 1079 | parser->m_eventEndPtr = NULL; |
| 1039 | positionPtr = NULL; | 1080 | parser->m_positionPtr = NULL; |
| 1040 | openInternalEntities = NULL; | 1081 | parser->m_openInternalEntities = NULL; |
| 1041 | defaultExpandInternalEntities = XML_TRUE; | 1082 | parser->m_defaultExpandInternalEntities = XML_TRUE; |
| 1042 | tagLevel = 0; | 1083 | parser->m_tagLevel = 0; |
| 1043 | tagStack = NULL; | 1084 | parser->m_tagStack = NULL; |
| 1044 | inheritedBindings = NULL; | 1085 | parser->m_inheritedBindings = NULL; |
| 1045 | nSpecifiedAtts = 0; | 1086 | parser->m_nSpecifiedAtts = 0; |
| 1046 | unknownEncodingMem = NULL; | 1087 | parser->m_unknownEncodingMem = NULL; |
| 1047 | unknownEncodingRelease = NULL; | 1088 | parser->m_unknownEncodingRelease = NULL; |
| 1048 | unknownEncodingData = NULL; | 1089 | parser->m_unknownEncodingData = NULL; |
| 1049 | parentParser = NULL; | 1090 | parser->m_parentParser = NULL; |
| 1050 | ps_parsing = XML_INITIALIZED; | 1091 | parser->m_parsingStatus.parsing = XML_INITIALIZED; |
| 1051 | #ifdef XML_DTD | 1092 | #ifdef XML_DTD |
| 1052 | isParamEntity = XML_FALSE; | 1093 | parser->m_isParamEntity = XML_FALSE; |
| 1053 | useForeignDTD = XML_FALSE; | 1094 | parser->m_useForeignDTD = XML_FALSE; |
| 1054 | paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | 1095 | parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
| 1055 | #endif | 1096 | #endif |
| 1056 | hash_secret_salt = 0; | 1097 | parser->m_hash_secret_salt = 0; |
| 1057 | } | 1098 | } |
| 1058 | 1099 | ||
| 1059 | /* moves list of bindings to freeBindingList */ | 1100 | /* moves list of bindings to m_freeBindingList */ |
| 1060 | static void FASTCALL | 1101 | static void FASTCALL |
| 1061 | moveToFreeBindingList(XML_Parser parser, BINDING *bindings) | 1102 | moveToFreeBindingList(XML_Parser parser, BINDING *bindings) |
| 1062 | { | 1103 | { |
| 1063 | while (bindings) { | 1104 | while (bindings) { |
| 1064 | BINDING *b = bindings; | 1105 | BINDING *b = bindings; |
| 1065 | bindings = bindings->nextTagBinding; | 1106 | bindings = bindings->nextTagBinding; |
| 1066 | b->nextTagBinding = freeBindingList; | 1107 | b->nextTagBinding = parser->m_freeBindingList; |
| 1067 | freeBindingList = b; | 1108 | parser->m_freeBindingList = b; |
| 1068 | } | 1109 | } |
| 1069 | } | 1110 | } |
| 1070 | 1111 | ||
| @@ -1077,34 +1118,36 @@ XML_ParserReset(XML_Parser parser, const XML_Char *encodingName) | |||
| 1077 | if (parser == NULL) | 1118 | if (parser == NULL) |
| 1078 | return XML_FALSE; | 1119 | return XML_FALSE; |
| 1079 | 1120 | ||
| 1080 | if (parentParser) | 1121 | if (parser->m_parentParser) |
| 1081 | return XML_FALSE; | 1122 | return XML_FALSE; |
| 1082 | /* move tagStack to freeTagList */ | 1123 | /* move m_tagStack to m_freeTagList */ |
| 1083 | tStk = tagStack; | 1124 | tStk = parser->m_tagStack; |
| 1084 | while (tStk) { | 1125 | while (tStk) { |
| 1085 | TAG *tag = tStk; | 1126 | TAG *tag = tStk; |
| 1086 | tStk = tStk->parent; | 1127 | tStk = tStk->parent; |
| 1087 | tag->parent = freeTagList; | 1128 | tag->parent = parser->m_freeTagList; |
| 1088 | moveToFreeBindingList(parser, tag->bindings); | 1129 | moveToFreeBindingList(parser, tag->bindings); |
| 1089 | tag->bindings = NULL; | 1130 | tag->bindings = NULL; |
| 1090 | freeTagList = tag; | 1131 | parser->m_freeTagList = tag; |
| 1091 | } | 1132 | } |
| 1092 | /* move openInternalEntities to freeInternalEntities */ | 1133 | /* move m_openInternalEntities to m_freeInternalEntities */ |
| 1093 | openEntityList = openInternalEntities; | 1134 | openEntityList = parser->m_openInternalEntities; |
| 1094 | while (openEntityList) { | 1135 | while (openEntityList) { |
| 1095 | OPEN_INTERNAL_ENTITY *openEntity = openEntityList; | 1136 | OPEN_INTERNAL_ENTITY *openEntity = openEntityList; |
| 1096 | openEntityList = openEntity->next; | 1137 | openEntityList = openEntity->next; |
| 1097 | openEntity->next = freeInternalEntities; | 1138 | openEntity->next = parser->m_freeInternalEntities; |
| 1098 | freeInternalEntities = openEntity; | 1139 | parser->m_freeInternalEntities = openEntity; |
| 1099 | } | 1140 | } |
| 1100 | moveToFreeBindingList(parser, inheritedBindings); | 1141 | moveToFreeBindingList(parser, parser->m_inheritedBindings); |
| 1101 | FREE(unknownEncodingMem); | 1142 | FREE(parser, parser->m_unknownEncodingMem); |
| 1102 | if (unknownEncodingRelease) | 1143 | if (parser->m_unknownEncodingRelease) |
| 1103 | unknownEncodingRelease(unknownEncodingData); | 1144 | parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); |
| 1104 | poolClear(&tempPool); | 1145 | poolClear(&parser->m_tempPool); |
| 1105 | poolClear(&temp2Pool); | 1146 | poolClear(&parser->m_temp2Pool); |
| 1147 | FREE(parser, (void *)parser->m_protocolEncodingName); | ||
| 1148 | parser->m_protocolEncodingName = NULL; | ||
| 1106 | parserInit(parser, encodingName); | 1149 | parserInit(parser, encodingName); |
| 1107 | dtdReset(_dtd, &parser->m_mem); | 1150 | dtdReset(parser->m_dtd, &parser->m_mem); |
| 1108 | return XML_TRUE; | 1151 | return XML_TRUE; |
| 1109 | } | 1152 | } |
| 1110 | 1153 | ||
| @@ -1117,13 +1160,19 @@ XML_SetEncoding(XML_Parser parser, const XML_Char *encodingName) | |||
| 1117 | XXX There's no way for the caller to determine which of the | 1160 | XXX There's no way for the caller to determine which of the |
| 1118 | XXX possible error cases caused the XML_STATUS_ERROR return. | 1161 | XXX possible error cases caused the XML_STATUS_ERROR return. |
| 1119 | */ | 1162 | */ |
| 1120 | if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) | 1163 | if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 1121 | return XML_STATUS_ERROR; | 1164 | return XML_STATUS_ERROR; |
| 1165 | |||
| 1166 | /* Get rid of any previous encoding name */ | ||
| 1167 | FREE(parser, (void *)parser->m_protocolEncodingName); | ||
| 1168 | |||
| 1122 | if (encodingName == NULL) | 1169 | if (encodingName == NULL) |
| 1123 | protocolEncodingName = NULL; | 1170 | /* No new encoding name */ |
| 1171 | parser->m_protocolEncodingName = NULL; | ||
| 1124 | else { | 1172 | else { |
| 1125 | protocolEncodingName = poolCopyString(&tempPool, encodingName); | 1173 | /* Copy the new encoding name into allocated memory */ |
| 1126 | if (!protocolEncodingName) | 1174 | parser->m_protocolEncodingName = copyString(encodingName, &(parser->m_mem)); |
| 1175 | if (!parser->m_protocolEncodingName) | ||
| 1127 | return XML_STATUS_ERROR; | 1176 | return XML_STATUS_ERROR; |
| 1128 | } | 1177 | } |
| 1129 | return XML_STATUS_OK; | 1178 | return XML_STATUS_OK; |
| @@ -1180,44 +1229,44 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, | |||
| 1180 | return NULL; | 1229 | return NULL; |
| 1181 | 1230 | ||
| 1182 | /* Stash the original parser contents on the stack */ | 1231 | /* Stash the original parser contents on the stack */ |
| 1183 | oldDtd = _dtd; | 1232 | oldDtd = parser->m_dtd; |
| 1184 | oldStartElementHandler = startElementHandler; | 1233 | oldStartElementHandler = parser->m_startElementHandler; |
| 1185 | oldEndElementHandler = endElementHandler; | 1234 | oldEndElementHandler = parser->m_endElementHandler; |
| 1186 | oldCharacterDataHandler = characterDataHandler; | 1235 | oldCharacterDataHandler = parser->m_characterDataHandler; |
| 1187 | oldProcessingInstructionHandler = processingInstructionHandler; | 1236 | oldProcessingInstructionHandler = parser->m_processingInstructionHandler; |
| 1188 | oldCommentHandler = commentHandler; | 1237 | oldCommentHandler = parser->m_commentHandler; |
| 1189 | oldStartCdataSectionHandler = startCdataSectionHandler; | 1238 | oldStartCdataSectionHandler = parser->m_startCdataSectionHandler; |
| 1190 | oldEndCdataSectionHandler = endCdataSectionHandler; | 1239 | oldEndCdataSectionHandler = parser->m_endCdataSectionHandler; |
| 1191 | oldDefaultHandler = defaultHandler; | 1240 | oldDefaultHandler = parser->m_defaultHandler; |
| 1192 | oldUnparsedEntityDeclHandler = unparsedEntityDeclHandler; | 1241 | oldUnparsedEntityDeclHandler = parser->m_unparsedEntityDeclHandler; |
| 1193 | oldNotationDeclHandler = notationDeclHandler; | 1242 | oldNotationDeclHandler = parser->m_notationDeclHandler; |
| 1194 | oldStartNamespaceDeclHandler = startNamespaceDeclHandler; | 1243 | oldStartNamespaceDeclHandler = parser->m_startNamespaceDeclHandler; |
| 1195 | oldEndNamespaceDeclHandler = endNamespaceDeclHandler; | 1244 | oldEndNamespaceDeclHandler = parser->m_endNamespaceDeclHandler; |
| 1196 | oldNotStandaloneHandler = notStandaloneHandler; | 1245 | oldNotStandaloneHandler = parser->m_notStandaloneHandler; |
| 1197 | oldExternalEntityRefHandler = externalEntityRefHandler; | 1246 | oldExternalEntityRefHandler = parser->m_externalEntityRefHandler; |
| 1198 | oldSkippedEntityHandler = skippedEntityHandler; | 1247 | oldSkippedEntityHandler = parser->m_skippedEntityHandler; |
| 1199 | oldUnknownEncodingHandler = unknownEncodingHandler; | 1248 | oldUnknownEncodingHandler = parser->m_unknownEncodingHandler; |
| 1200 | oldElementDeclHandler = elementDeclHandler; | 1249 | oldElementDeclHandler = parser->m_elementDeclHandler; |
| 1201 | oldAttlistDeclHandler = attlistDeclHandler; | 1250 | oldAttlistDeclHandler = parser->m_attlistDeclHandler; |
| 1202 | oldEntityDeclHandler = entityDeclHandler; | 1251 | oldEntityDeclHandler = parser->m_entityDeclHandler; |
| 1203 | oldXmlDeclHandler = xmlDeclHandler; | 1252 | oldXmlDeclHandler = parser->m_xmlDeclHandler; |
| 1204 | oldDeclElementType = declElementType; | 1253 | oldDeclElementType = parser->m_declElementType; |
| 1205 | 1254 | ||
| 1206 | oldUserData = userData; | 1255 | oldUserData = parser->m_userData; |
| 1207 | oldHandlerArg = handlerArg; | 1256 | oldHandlerArg = parser->m_handlerArg; |
| 1208 | oldDefaultExpandInternalEntities = defaultExpandInternalEntities; | 1257 | oldDefaultExpandInternalEntities = parser->m_defaultExpandInternalEntities; |
| 1209 | oldExternalEntityRefHandlerArg = externalEntityRefHandlerArg; | 1258 | oldExternalEntityRefHandlerArg = parser->m_externalEntityRefHandlerArg; |
| 1210 | #ifdef XML_DTD | 1259 | #ifdef XML_DTD |
| 1211 | oldParamEntityParsing = paramEntityParsing; | 1260 | oldParamEntityParsing = parser->m_paramEntityParsing; |
| 1212 | oldInEntityValue = prologState.inEntityValue; | 1261 | oldInEntityValue = parser->m_prologState.inEntityValue; |
| 1213 | #endif | 1262 | #endif |
| 1214 | oldns_triplets = ns_triplets; | 1263 | oldns_triplets = parser->m_ns_triplets; |
| 1215 | /* Note that the new parser shares the same hash secret as the old | 1264 | /* Note that the new parser shares the same hash secret as the old |
| 1216 | parser, so that dtdCopy and copyEntityTable can lookup values | 1265 | parser, so that dtdCopy and copyEntityTable can lookup values |
| 1217 | from hash tables associated with either parser without us having | 1266 | from hash tables associated with either parser without us having |
| 1218 | to worry which hash secrets each table has. | 1267 | to worry which hash secrets each table has. |
| 1219 | */ | 1268 | */ |
| 1220 | oldhash_secret_salt = hash_secret_salt; | 1269 | oldhash_secret_salt = parser->m_hash_secret_salt; |
| 1221 | 1270 | ||
| 1222 | #ifdef XML_DTD | 1271 | #ifdef XML_DTD |
| 1223 | if (!context) | 1272 | if (!context) |
| @@ -1229,9 +1278,9 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, | |||
| 1229 | here. This makes this function more painful to follow than it | 1278 | here. This makes this function more painful to follow than it |
| 1230 | would be otherwise. | 1279 | would be otherwise. |
| 1231 | */ | 1280 | */ |
| 1232 | if (ns) { | 1281 | if (parser->m_ns) { |
| 1233 | XML_Char tmp[2]; | 1282 | XML_Char tmp[2]; |
| 1234 | *tmp = namespaceSeparator; | 1283 | *tmp = parser->m_namespaceSeparator; |
| 1235 | parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); | 1284 | parser = parserCreate(encodingName, &parser->m_mem, tmp, newDtd); |
| 1236 | } | 1285 | } |
| 1237 | else { | 1286 | else { |
| @@ -1241,62 +1290,62 @@ XML_ExternalEntityParserCreate(XML_Parser oldParser, | |||
| 1241 | if (!parser) | 1290 | if (!parser) |
| 1242 | return NULL; | 1291 | return NULL; |
| 1243 | 1292 | ||
| 1244 | startElementHandler = oldStartElementHandler; | 1293 | parser->m_startElementHandler = oldStartElementHandler; |
| 1245 | endElementHandler = oldEndElementHandler; | 1294 | parser->m_endElementHandler = oldEndElementHandler; |
| 1246 | characterDataHandler = oldCharacterDataHandler; | 1295 | parser->m_characterDataHandler = oldCharacterDataHandler; |
| 1247 | processingInstructionHandler = oldProcessingInstructionHandler; | 1296 | parser->m_processingInstructionHandler = oldProcessingInstructionHandler; |
| 1248 | commentHandler = oldCommentHandler; | 1297 | parser->m_commentHandler = oldCommentHandler; |
| 1249 | startCdataSectionHandler = oldStartCdataSectionHandler; | 1298 | parser->m_startCdataSectionHandler = oldStartCdataSectionHandler; |
| 1250 | endCdataSectionHandler = oldEndCdataSectionHandler; | 1299 | parser->m_endCdataSectionHandler = oldEndCdataSectionHandler; |
| 1251 | defaultHandler = oldDefaultHandler; | 1300 | parser->m_defaultHandler = oldDefaultHandler; |
| 1252 | unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; | 1301 | parser->m_unparsedEntityDeclHandler = oldUnparsedEntityDeclHandler; |
| 1253 | notationDeclHandler = oldNotationDeclHandler; | 1302 | parser->m_notationDeclHandler = oldNotationDeclHandler; |
| 1254 | startNamespaceDeclHandler = oldStartNamespaceDeclHandler; | 1303 | parser->m_startNamespaceDeclHandler = oldStartNamespaceDeclHandler; |
| 1255 | endNamespaceDeclHandler = oldEndNamespaceDeclHandler; | 1304 | parser->m_endNamespaceDeclHandler = oldEndNamespaceDeclHandler; |
| 1256 | notStandaloneHandler = oldNotStandaloneHandler; | 1305 | parser->m_notStandaloneHandler = oldNotStandaloneHandler; |
| 1257 | externalEntityRefHandler = oldExternalEntityRefHandler; | 1306 | parser->m_externalEntityRefHandler = oldExternalEntityRefHandler; |
| 1258 | skippedEntityHandler = oldSkippedEntityHandler; | 1307 | parser->m_skippedEntityHandler = oldSkippedEntityHandler; |
| 1259 | unknownEncodingHandler = oldUnknownEncodingHandler; | 1308 | parser->m_unknownEncodingHandler = oldUnknownEncodingHandler; |
| 1260 | elementDeclHandler = oldElementDeclHandler; | 1309 | parser->m_elementDeclHandler = oldElementDeclHandler; |
| 1261 | attlistDeclHandler = oldAttlistDeclHandler; | 1310 | parser->m_attlistDeclHandler = oldAttlistDeclHandler; |
| 1262 | entityDeclHandler = oldEntityDeclHandler; | 1311 | parser->m_entityDeclHandler = oldEntityDeclHandler; |
| 1263 | xmlDeclHandler = oldXmlDeclHandler; | 1312 | parser->m_xmlDeclHandler = oldXmlDeclHandler; |
| 1264 | declElementType = oldDeclElementType; | 1313 | parser->m_declElementType = oldDeclElementType; |
| 1265 | userData = oldUserData; | 1314 | parser->m_userData = oldUserData; |
| 1266 | if (oldUserData == oldHandlerArg) | 1315 | if (oldUserData == oldHandlerArg) |
| 1267 | handlerArg = userData; | 1316 | parser->m_handlerArg = parser->m_userData; |
| 1268 | else | 1317 | else |
| 1269 | handlerArg = parser; | 1318 | parser->m_handlerArg = parser; |
| 1270 | if (oldExternalEntityRefHandlerArg != oldParser) | 1319 | if (oldExternalEntityRefHandlerArg != oldParser) |
| 1271 | externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; | 1320 | parser->m_externalEntityRefHandlerArg = oldExternalEntityRefHandlerArg; |
| 1272 | defaultExpandInternalEntities = oldDefaultExpandInternalEntities; | 1321 | parser->m_defaultExpandInternalEntities = oldDefaultExpandInternalEntities; |
| 1273 | ns_triplets = oldns_triplets; | 1322 | parser->m_ns_triplets = oldns_triplets; |
| 1274 | hash_secret_salt = oldhash_secret_salt; | 1323 | parser->m_hash_secret_salt = oldhash_secret_salt; |
| 1275 | parentParser = oldParser; | 1324 | parser->m_parentParser = oldParser; |
| 1276 | #ifdef XML_DTD | 1325 | #ifdef XML_DTD |
| 1277 | paramEntityParsing = oldParamEntityParsing; | 1326 | parser->m_paramEntityParsing = oldParamEntityParsing; |
| 1278 | prologState.inEntityValue = oldInEntityValue; | 1327 | parser->m_prologState.inEntityValue = oldInEntityValue; |
| 1279 | if (context) { | 1328 | if (context) { |
| 1280 | #endif /* XML_DTD */ | 1329 | #endif /* XML_DTD */ |
| 1281 | if (!dtdCopy(oldParser, _dtd, oldDtd, &parser->m_mem) | 1330 | if (!dtdCopy(oldParser, parser->m_dtd, oldDtd, &parser->m_mem) |
| 1282 | || !setContext(parser, context)) { | 1331 | || !setContext(parser, context)) { |
| 1283 | XML_ParserFree(parser); | 1332 | XML_ParserFree(parser); |
| 1284 | return NULL; | 1333 | return NULL; |
| 1285 | } | 1334 | } |
| 1286 | processor = externalEntityInitProcessor; | 1335 | parser->m_processor = externalEntityInitProcessor; |
| 1287 | #ifdef XML_DTD | 1336 | #ifdef XML_DTD |
| 1288 | } | 1337 | } |
| 1289 | else { | 1338 | else { |
| 1290 | /* The DTD instance referenced by _dtd is shared between the document's | 1339 | /* The DTD instance referenced by parser->m_dtd is shared between the document's |
| 1291 | root parser and external PE parsers, therefore one does not need to | 1340 | root parser and external PE parsers, therefore one does not need to |
| 1292 | call setContext. In addition, one also *must* not call setContext, | 1341 | call setContext. In addition, one also *must* not call setContext, |
| 1293 | because this would overwrite existing prefix->binding pointers in | 1342 | because this would overwrite existing prefix->binding pointers in |
| 1294 | _dtd with ones that get destroyed with the external PE parser. | 1343 | parser->m_dtd with ones that get destroyed with the external PE parser. |
| 1295 | This would leave those prefixes with dangling pointers. | 1344 | This would leave those prefixes with dangling pointers. |
| 1296 | */ | 1345 | */ |
| 1297 | isParamEntity = XML_TRUE; | 1346 | parser->m_isParamEntity = XML_TRUE; |
| 1298 | XmlPrologStateInitExternalEntity(&prologState); | 1347 | XmlPrologStateInitExternalEntity(&parser->m_prologState); |
| 1299 | processor = externalParEntInitProcessor; | 1348 | parser->m_processor = externalParEntInitProcessor; |
| 1300 | } | 1349 | } |
| 1301 | #endif /* XML_DTD */ | 1350 | #endif /* XML_DTD */ |
| 1302 | return parser; | 1351 | return parser; |
| @@ -1310,8 +1359,8 @@ destroyBindings(BINDING *bindings, XML_Parser parser) | |||
| 1310 | if (!b) | 1359 | if (!b) |
| 1311 | break; | 1360 | break; |
| 1312 | bindings = b->nextTagBinding; | 1361 | bindings = b->nextTagBinding; |
| 1313 | FREE(b->uri); | 1362 | FREE(parser, b->uri); |
| 1314 | FREE(b); | 1363 | FREE(parser, b); |
| 1315 | } | 1364 | } |
| 1316 | } | 1365 | } |
| 1317 | 1366 | ||
| @@ -1322,69 +1371,70 @@ XML_ParserFree(XML_Parser parser) | |||
| 1322 | OPEN_INTERNAL_ENTITY *entityList; | 1371 | OPEN_INTERNAL_ENTITY *entityList; |
| 1323 | if (parser == NULL) | 1372 | if (parser == NULL) |
| 1324 | return; | 1373 | return; |
| 1325 | /* free tagStack and freeTagList */ | 1374 | /* free m_tagStack and m_freeTagList */ |
| 1326 | tagList = tagStack; | 1375 | tagList = parser->m_tagStack; |
| 1327 | for (;;) { | 1376 | for (;;) { |
| 1328 | TAG *p; | 1377 | TAG *p; |
| 1329 | if (tagList == NULL) { | 1378 | if (tagList == NULL) { |
| 1330 | if (freeTagList == NULL) | 1379 | if (parser->m_freeTagList == NULL) |
| 1331 | break; | 1380 | break; |
| 1332 | tagList = freeTagList; | 1381 | tagList = parser->m_freeTagList; |
| 1333 | freeTagList = NULL; | 1382 | parser->m_freeTagList = NULL; |
| 1334 | } | 1383 | } |
| 1335 | p = tagList; | 1384 | p = tagList; |
| 1336 | tagList = tagList->parent; | 1385 | tagList = tagList->parent; |
| 1337 | FREE(p->buf); | 1386 | FREE(parser, p->buf); |
| 1338 | destroyBindings(p->bindings, parser); | 1387 | destroyBindings(p->bindings, parser); |
| 1339 | FREE(p); | 1388 | FREE(parser, p); |
| 1340 | } | 1389 | } |
| 1341 | /* free openInternalEntities and freeInternalEntities */ | 1390 | /* free m_openInternalEntities and m_freeInternalEntities */ |
| 1342 | entityList = openInternalEntities; | 1391 | entityList = parser->m_openInternalEntities; |
| 1343 | for (;;) { | 1392 | for (;;) { |
| 1344 | OPEN_INTERNAL_ENTITY *openEntity; | 1393 | OPEN_INTERNAL_ENTITY *openEntity; |
| 1345 | if (entityList == NULL) { | 1394 | if (entityList == NULL) { |
| 1346 | if (freeInternalEntities == NULL) | 1395 | if (parser->m_freeInternalEntities == NULL) |
| 1347 | break; | 1396 | break; |
| 1348 | entityList = freeInternalEntities; | 1397 | entityList = parser->m_freeInternalEntities; |
| 1349 | freeInternalEntities = NULL; | 1398 | parser->m_freeInternalEntities = NULL; |
| 1350 | } | 1399 | } |
| 1351 | openEntity = entityList; | 1400 | openEntity = entityList; |
| 1352 | entityList = entityList->next; | 1401 | entityList = entityList->next; |
| 1353 | FREE(openEntity); | 1402 | FREE(parser, openEntity); |
| 1354 | } | 1403 | } |
| 1355 | 1404 | ||
| 1356 | destroyBindings(freeBindingList, parser); | 1405 | destroyBindings(parser->m_freeBindingList, parser); |
| 1357 | destroyBindings(inheritedBindings, parser); | 1406 | destroyBindings(parser->m_inheritedBindings, parser); |
| 1358 | poolDestroy(&tempPool); | 1407 | poolDestroy(&parser->m_tempPool); |
| 1359 | poolDestroy(&temp2Pool); | 1408 | poolDestroy(&parser->m_temp2Pool); |
| 1409 | FREE(parser, (void *)parser->m_protocolEncodingName); | ||
| 1360 | #ifdef XML_DTD | 1410 | #ifdef XML_DTD |
| 1361 | /* external parameter entity parsers share the DTD structure | 1411 | /* external parameter entity parsers share the DTD structure |
| 1362 | parser->m_dtd with the root parser, so we must not destroy it | 1412 | parser->m_dtd with the root parser, so we must not destroy it |
| 1363 | */ | 1413 | */ |
| 1364 | if (!isParamEntity && _dtd) | 1414 | if (!parser->m_isParamEntity && parser->m_dtd) |
| 1365 | #else | 1415 | #else |
| 1366 | if (_dtd) | 1416 | if (parser->m_dtd) |
| 1367 | #endif /* XML_DTD */ | 1417 | #endif /* XML_DTD */ |
| 1368 | dtdDestroy(_dtd, (XML_Bool)!parentParser, &parser->m_mem); | 1418 | dtdDestroy(parser->m_dtd, (XML_Bool)!parser->m_parentParser, &parser->m_mem); |
| 1369 | FREE((void *)atts); | 1419 | FREE(parser, (void *)parser->m_atts); |
| 1370 | #ifdef XML_ATTR_INFO | 1420 | #ifdef XML_ATTR_INFO |
| 1371 | FREE((void *)attInfo); | 1421 | FREE(parser, (void *)parser->m_attInfo); |
| 1372 | #endif | 1422 | #endif |
| 1373 | FREE(groupConnector); | 1423 | FREE(parser, parser->m_groupConnector); |
| 1374 | FREE(buffer); | 1424 | FREE(parser, parser->m_buffer); |
| 1375 | FREE(dataBuf); | 1425 | FREE(parser, parser->m_dataBuf); |
| 1376 | FREE(nsAtts); | 1426 | FREE(parser, parser->m_nsAtts); |
| 1377 | FREE(unknownEncodingMem); | 1427 | FREE(parser, parser->m_unknownEncodingMem); |
| 1378 | if (unknownEncodingRelease) | 1428 | if (parser->m_unknownEncodingRelease) |
| 1379 | unknownEncodingRelease(unknownEncodingData); | 1429 | parser->m_unknownEncodingRelease(parser->m_unknownEncodingData); |
| 1380 | FREE(parser); | 1430 | FREE(parser, parser); |
| 1381 | } | 1431 | } |
| 1382 | 1432 | ||
| 1383 | void XMLCALL | 1433 | void XMLCALL |
| 1384 | XML_UseParserAsHandlerArg(XML_Parser parser) | 1434 | XML_UseParserAsHandlerArg(XML_Parser parser) |
| 1385 | { | 1435 | { |
| 1386 | if (parser != NULL) | 1436 | if (parser != NULL) |
| 1387 | handlerArg = parser; | 1437 | parser->m_handlerArg = parser; |
| 1388 | } | 1438 | } |
| 1389 | 1439 | ||
| 1390 | enum XML_Error XMLCALL | 1440 | enum XML_Error XMLCALL |
| @@ -1394,9 +1444,9 @@ XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD) | |||
| 1394 | return XML_ERROR_INVALID_ARGUMENT; | 1444 | return XML_ERROR_INVALID_ARGUMENT; |
| 1395 | #ifdef XML_DTD | 1445 | #ifdef XML_DTD |
| 1396 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ | 1446 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
| 1397 | if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) | 1447 | if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 1398 | return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; | 1448 | return XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING; |
| 1399 | useForeignDTD = useDTD; | 1449 | parser->m_useForeignDTD = useDTD; |
| 1400 | return XML_ERROR_NONE; | 1450 | return XML_ERROR_NONE; |
| 1401 | #else | 1451 | #else |
| 1402 | return XML_ERROR_FEATURE_REQUIRES_XML_DTD; | 1452 | return XML_ERROR_FEATURE_REQUIRES_XML_DTD; |
| @@ -1409,9 +1459,9 @@ XML_SetReturnNSTriplet(XML_Parser parser, int do_nst) | |||
| 1409 | if (parser == NULL) | 1459 | if (parser == NULL) |
| 1410 | return; | 1460 | return; |
| 1411 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ | 1461 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
| 1412 | if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) | 1462 | if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 1413 | return; | 1463 | return; |
| 1414 | ns_triplets = do_nst ? XML_TRUE : XML_FALSE; | 1464 | parser->m_ns_triplets = do_nst ? XML_TRUE : XML_FALSE; |
| 1415 | } | 1465 | } |
| 1416 | 1466 | ||
| 1417 | void XMLCALL | 1467 | void XMLCALL |
| @@ -1419,10 +1469,10 @@ XML_SetUserData(XML_Parser parser, void *p) | |||
| 1419 | { | 1469 | { |
| 1420 | if (parser == NULL) | 1470 | if (parser == NULL) |
| 1421 | return; | 1471 | return; |
| 1422 | if (handlerArg == userData) | 1472 | if (parser->m_handlerArg == parser->m_userData) |
| 1423 | handlerArg = userData = p; | 1473 | parser->m_handlerArg = parser->m_userData = p; |
| 1424 | else | 1474 | else |
| 1425 | userData = p; | 1475 | parser->m_userData = p; |
| 1426 | } | 1476 | } |
| 1427 | 1477 | ||
| 1428 | enum XML_Status XMLCALL | 1478 | enum XML_Status XMLCALL |
| @@ -1431,13 +1481,13 @@ XML_SetBase(XML_Parser parser, const XML_Char *p) | |||
| 1431 | if (parser == NULL) | 1481 | if (parser == NULL) |
| 1432 | return XML_STATUS_ERROR; | 1482 | return XML_STATUS_ERROR; |
| 1433 | if (p) { | 1483 | if (p) { |
| 1434 | p = poolCopyString(&_dtd->pool, p); | 1484 | p = poolCopyString(&parser->m_dtd->pool, p); |
| 1435 | if (!p) | 1485 | if (!p) |
| 1436 | return XML_STATUS_ERROR; | 1486 | return XML_STATUS_ERROR; |
| 1437 | curBase = p; | 1487 | parser->m_curBase = p; |
| 1438 | } | 1488 | } |
| 1439 | else | 1489 | else |
| 1440 | curBase = NULL; | 1490 | parser->m_curBase = NULL; |
| 1441 | return XML_STATUS_OK; | 1491 | return XML_STATUS_OK; |
| 1442 | } | 1492 | } |
| 1443 | 1493 | ||
| @@ -1446,7 +1496,7 @@ XML_GetBase(XML_Parser parser) | |||
| 1446 | { | 1496 | { |
| 1447 | if (parser == NULL) | 1497 | if (parser == NULL) |
| 1448 | return NULL; | 1498 | return NULL; |
| 1449 | return curBase; | 1499 | return parser->m_curBase; |
| 1450 | } | 1500 | } |
| 1451 | 1501 | ||
| 1452 | int XMLCALL | 1502 | int XMLCALL |
| @@ -1454,7 +1504,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser) | |||
| 1454 | { | 1504 | { |
| 1455 | if (parser == NULL) | 1505 | if (parser == NULL) |
| 1456 | return -1; | 1506 | return -1; |
| 1457 | return nSpecifiedAtts; | 1507 | return parser->m_nSpecifiedAtts; |
| 1458 | } | 1508 | } |
| 1459 | 1509 | ||
| 1460 | int XMLCALL | 1510 | int XMLCALL |
| @@ -1462,7 +1512,7 @@ XML_GetIdAttributeIndex(XML_Parser parser) | |||
| 1462 | { | 1512 | { |
| 1463 | if (parser == NULL) | 1513 | if (parser == NULL) |
| 1464 | return -1; | 1514 | return -1; |
| 1465 | return idAttIndex; | 1515 | return parser->m_idAttIndex; |
| 1466 | } | 1516 | } |
| 1467 | 1517 | ||
| 1468 | #ifdef XML_ATTR_INFO | 1518 | #ifdef XML_ATTR_INFO |
| @@ -1471,7 +1521,7 @@ XML_GetAttributeInfo(XML_Parser parser) | |||
| 1471 | { | 1521 | { |
| 1472 | if (parser == NULL) | 1522 | if (parser == NULL) |
| 1473 | return NULL; | 1523 | return NULL; |
| 1474 | return attInfo; | 1524 | return parser->m_attInfo; |
| 1475 | } | 1525 | } |
| 1476 | #endif | 1526 | #endif |
| 1477 | 1527 | ||
| @@ -1482,22 +1532,22 @@ XML_SetElementHandler(XML_Parser parser, | |||
| 1482 | { | 1532 | { |
| 1483 | if (parser == NULL) | 1533 | if (parser == NULL) |
| 1484 | return; | 1534 | return; |
| 1485 | startElementHandler = start; | 1535 | parser->m_startElementHandler = start; |
| 1486 | endElementHandler = end; | 1536 | parser->m_endElementHandler = end; |
| 1487 | } | 1537 | } |
| 1488 | 1538 | ||
| 1489 | void XMLCALL | 1539 | void XMLCALL |
| 1490 | XML_SetStartElementHandler(XML_Parser parser, | 1540 | XML_SetStartElementHandler(XML_Parser parser, |
| 1491 | XML_StartElementHandler start) { | 1541 | XML_StartElementHandler start) { |
| 1492 | if (parser != NULL) | 1542 | if (parser != NULL) |
| 1493 | startElementHandler = start; | 1543 | parser->m_startElementHandler = start; |
| 1494 | } | 1544 | } |
| 1495 | 1545 | ||
| 1496 | void XMLCALL | 1546 | void XMLCALL |
| 1497 | XML_SetEndElementHandler(XML_Parser parser, | 1547 | XML_SetEndElementHandler(XML_Parser parser, |
| 1498 | XML_EndElementHandler end) { | 1548 | XML_EndElementHandler end) { |
| 1499 | if (parser != NULL) | 1549 | if (parser != NULL) |
| 1500 | endElementHandler = end; | 1550 | parser->m_endElementHandler = end; |
| 1501 | } | 1551 | } |
| 1502 | 1552 | ||
| 1503 | void XMLCALL | 1553 | void XMLCALL |
| @@ -1505,7 +1555,7 @@ XML_SetCharacterDataHandler(XML_Parser parser, | |||
| 1505 | XML_CharacterDataHandler handler) | 1555 | XML_CharacterDataHandler handler) |
| 1506 | { | 1556 | { |
| 1507 | if (parser != NULL) | 1557 | if (parser != NULL) |
| 1508 | characterDataHandler = handler; | 1558 | parser->m_characterDataHandler = handler; |
| 1509 | } | 1559 | } |
| 1510 | 1560 | ||
| 1511 | void XMLCALL | 1561 | void XMLCALL |
| @@ -1513,7 +1563,7 @@ XML_SetProcessingInstructionHandler(XML_Parser parser, | |||
| 1513 | XML_ProcessingInstructionHandler handler) | 1563 | XML_ProcessingInstructionHandler handler) |
| 1514 | { | 1564 | { |
| 1515 | if (parser != NULL) | 1565 | if (parser != NULL) |
| 1516 | processingInstructionHandler = handler; | 1566 | parser->m_processingInstructionHandler = handler; |
| 1517 | } | 1567 | } |
| 1518 | 1568 | ||
| 1519 | void XMLCALL | 1569 | void XMLCALL |
| @@ -1521,7 +1571,7 @@ XML_SetCommentHandler(XML_Parser parser, | |||
| 1521 | XML_CommentHandler handler) | 1571 | XML_CommentHandler handler) |
| 1522 | { | 1572 | { |
| 1523 | if (parser != NULL) | 1573 | if (parser != NULL) |
| 1524 | commentHandler = handler; | 1574 | parser->m_commentHandler = handler; |
| 1525 | } | 1575 | } |
| 1526 | 1576 | ||
| 1527 | void XMLCALL | 1577 | void XMLCALL |
| @@ -1531,22 +1581,22 @@ XML_SetCdataSectionHandler(XML_Parser parser, | |||
| 1531 | { | 1581 | { |
| 1532 | if (parser == NULL) | 1582 | if (parser == NULL) |
| 1533 | return; | 1583 | return; |
| 1534 | startCdataSectionHandler = start; | 1584 | parser->m_startCdataSectionHandler = start; |
| 1535 | endCdataSectionHandler = end; | 1585 | parser->m_endCdataSectionHandler = end; |
| 1536 | } | 1586 | } |
| 1537 | 1587 | ||
| 1538 | void XMLCALL | 1588 | void XMLCALL |
| 1539 | XML_SetStartCdataSectionHandler(XML_Parser parser, | 1589 | XML_SetStartCdataSectionHandler(XML_Parser parser, |
| 1540 | XML_StartCdataSectionHandler start) { | 1590 | XML_StartCdataSectionHandler start) { |
| 1541 | if (parser != NULL) | 1591 | if (parser != NULL) |
| 1542 | startCdataSectionHandler = start; | 1592 | parser->m_startCdataSectionHandler = start; |
| 1543 | } | 1593 | } |
| 1544 | 1594 | ||
| 1545 | void XMLCALL | 1595 | void XMLCALL |
| 1546 | XML_SetEndCdataSectionHandler(XML_Parser parser, | 1596 | XML_SetEndCdataSectionHandler(XML_Parser parser, |
| 1547 | XML_EndCdataSectionHandler end) { | 1597 | XML_EndCdataSectionHandler end) { |
| 1548 | if (parser != NULL) | 1598 | if (parser != NULL) |
| 1549 | endCdataSectionHandler = end; | 1599 | parser->m_endCdataSectionHandler = end; |
| 1550 | } | 1600 | } |
| 1551 | 1601 | ||
| 1552 | void XMLCALL | 1602 | void XMLCALL |
| @@ -1555,8 +1605,8 @@ XML_SetDefaultHandler(XML_Parser parser, | |||
| 1555 | { | 1605 | { |
| 1556 | if (parser == NULL) | 1606 | if (parser == NULL) |
| 1557 | return; | 1607 | return; |
| 1558 | defaultHandler = handler; | 1608 | parser->m_defaultHandler = handler; |
| 1559 | defaultExpandInternalEntities = XML_FALSE; | 1609 | parser->m_defaultExpandInternalEntities = XML_FALSE; |
| 1560 | } | 1610 | } |
| 1561 | 1611 | ||
| 1562 | void XMLCALL | 1612 | void XMLCALL |
| @@ -1565,8 +1615,8 @@ XML_SetDefaultHandlerExpand(XML_Parser parser, | |||
| 1565 | { | 1615 | { |
| 1566 | if (parser == NULL) | 1616 | if (parser == NULL) |
| 1567 | return; | 1617 | return; |
| 1568 | defaultHandler = handler; | 1618 | parser->m_defaultHandler = handler; |
| 1569 | defaultExpandInternalEntities = XML_TRUE; | 1619 | parser->m_defaultExpandInternalEntities = XML_TRUE; |
| 1570 | } | 1620 | } |
| 1571 | 1621 | ||
| 1572 | void XMLCALL | 1622 | void XMLCALL |
| @@ -1576,22 +1626,22 @@ XML_SetDoctypeDeclHandler(XML_Parser parser, | |||
| 1576 | { | 1626 | { |
| 1577 | if (parser == NULL) | 1627 | if (parser == NULL) |
| 1578 | return; | 1628 | return; |
| 1579 | startDoctypeDeclHandler = start; | 1629 | parser->m_startDoctypeDeclHandler = start; |
| 1580 | endDoctypeDeclHandler = end; | 1630 | parser->m_endDoctypeDeclHandler = end; |
| 1581 | } | 1631 | } |
| 1582 | 1632 | ||
| 1583 | void XMLCALL | 1633 | void XMLCALL |
| 1584 | XML_SetStartDoctypeDeclHandler(XML_Parser parser, | 1634 | XML_SetStartDoctypeDeclHandler(XML_Parser parser, |
| 1585 | XML_StartDoctypeDeclHandler start) { | 1635 | XML_StartDoctypeDeclHandler start) { |
| 1586 | if (parser != NULL) | 1636 | if (parser != NULL) |
| 1587 | startDoctypeDeclHandler = start; | 1637 | parser->m_startDoctypeDeclHandler = start; |
| 1588 | } | 1638 | } |
| 1589 | 1639 | ||
| 1590 | void XMLCALL | 1640 | void XMLCALL |
| 1591 | XML_SetEndDoctypeDeclHandler(XML_Parser parser, | 1641 | XML_SetEndDoctypeDeclHandler(XML_Parser parser, |
| 1592 | XML_EndDoctypeDeclHandler end) { | 1642 | XML_EndDoctypeDeclHandler end) { |
| 1593 | if (parser != NULL) | 1643 | if (parser != NULL) |
| 1594 | endDoctypeDeclHandler = end; | 1644 | parser->m_endDoctypeDeclHandler = end; |
| 1595 | } | 1645 | } |
| 1596 | 1646 | ||
| 1597 | void XMLCALL | 1647 | void XMLCALL |
| @@ -1599,7 +1649,7 @@ XML_SetUnparsedEntityDeclHandler(XML_Parser parser, | |||
| 1599 | XML_UnparsedEntityDeclHandler handler) | 1649 | XML_UnparsedEntityDeclHandler handler) |
| 1600 | { | 1650 | { |
| 1601 | if (parser != NULL) | 1651 | if (parser != NULL) |
| 1602 | unparsedEntityDeclHandler = handler; | 1652 | parser->m_unparsedEntityDeclHandler = handler; |
| 1603 | } | 1653 | } |
| 1604 | 1654 | ||
| 1605 | void XMLCALL | 1655 | void XMLCALL |
| @@ -1607,7 +1657,7 @@ XML_SetNotationDeclHandler(XML_Parser parser, | |||
| 1607 | XML_NotationDeclHandler handler) | 1657 | XML_NotationDeclHandler handler) |
| 1608 | { | 1658 | { |
| 1609 | if (parser != NULL) | 1659 | if (parser != NULL) |
| 1610 | notationDeclHandler = handler; | 1660 | parser->m_notationDeclHandler = handler; |
| 1611 | } | 1661 | } |
| 1612 | 1662 | ||
| 1613 | void XMLCALL | 1663 | void XMLCALL |
| @@ -1617,22 +1667,22 @@ XML_SetNamespaceDeclHandler(XML_Parser parser, | |||
| 1617 | { | 1667 | { |
| 1618 | if (parser == NULL) | 1668 | if (parser == NULL) |
| 1619 | return; | 1669 | return; |
| 1620 | startNamespaceDeclHandler = start; | 1670 | parser->m_startNamespaceDeclHandler = start; |
| 1621 | endNamespaceDeclHandler = end; | 1671 | parser->m_endNamespaceDeclHandler = end; |
| 1622 | } | 1672 | } |
| 1623 | 1673 | ||
| 1624 | void XMLCALL | 1674 | void XMLCALL |
| 1625 | XML_SetStartNamespaceDeclHandler(XML_Parser parser, | 1675 | XML_SetStartNamespaceDeclHandler(XML_Parser parser, |
| 1626 | XML_StartNamespaceDeclHandler start) { | 1676 | XML_StartNamespaceDeclHandler start) { |
| 1627 | if (parser != NULL) | 1677 | if (parser != NULL) |
| 1628 | startNamespaceDeclHandler = start; | 1678 | parser->m_startNamespaceDeclHandler = start; |
| 1629 | } | 1679 | } |
| 1630 | 1680 | ||
| 1631 | void XMLCALL | 1681 | void XMLCALL |
| 1632 | XML_SetEndNamespaceDeclHandler(XML_Parser parser, | 1682 | XML_SetEndNamespaceDeclHandler(XML_Parser parser, |
| 1633 | XML_EndNamespaceDeclHandler end) { | 1683 | XML_EndNamespaceDeclHandler end) { |
| 1634 | if (parser != NULL) | 1684 | if (parser != NULL) |
| 1635 | endNamespaceDeclHandler = end; | 1685 | parser->m_endNamespaceDeclHandler = end; |
| 1636 | } | 1686 | } |
| 1637 | 1687 | ||
| 1638 | void XMLCALL | 1688 | void XMLCALL |
| @@ -1640,7 +1690,7 @@ XML_SetNotStandaloneHandler(XML_Parser parser, | |||
| 1640 | XML_NotStandaloneHandler handler) | 1690 | XML_NotStandaloneHandler handler) |
| 1641 | { | 1691 | { |
| 1642 | if (parser != NULL) | 1692 | if (parser != NULL) |
| 1643 | notStandaloneHandler = handler; | 1693 | parser->m_notStandaloneHandler = handler; |
| 1644 | } | 1694 | } |
| 1645 | 1695 | ||
| 1646 | void XMLCALL | 1696 | void XMLCALL |
| @@ -1648,7 +1698,7 @@ XML_SetExternalEntityRefHandler(XML_Parser parser, | |||
| 1648 | XML_ExternalEntityRefHandler handler) | 1698 | XML_ExternalEntityRefHandler handler) |
| 1649 | { | 1699 | { |
| 1650 | if (parser != NULL) | 1700 | if (parser != NULL) |
| 1651 | externalEntityRefHandler = handler; | 1701 | parser->m_externalEntityRefHandler = handler; |
| 1652 | } | 1702 | } |
| 1653 | 1703 | ||
| 1654 | void XMLCALL | 1704 | void XMLCALL |
| @@ -1657,9 +1707,9 @@ XML_SetExternalEntityRefHandlerArg(XML_Parser parser, void *arg) | |||
| 1657 | if (parser == NULL) | 1707 | if (parser == NULL) |
| 1658 | return; | 1708 | return; |
| 1659 | if (arg) | 1709 | if (arg) |
| 1660 | externalEntityRefHandlerArg = (XML_Parser)arg; | 1710 | parser->m_externalEntityRefHandlerArg = (XML_Parser)arg; |
| 1661 | else | 1711 | else |
| 1662 | externalEntityRefHandlerArg = parser; | 1712 | parser->m_externalEntityRefHandlerArg = parser; |
| 1663 | } | 1713 | } |
| 1664 | 1714 | ||
| 1665 | void XMLCALL | 1715 | void XMLCALL |
| @@ -1667,7 +1717,7 @@ XML_SetSkippedEntityHandler(XML_Parser parser, | |||
| 1667 | XML_SkippedEntityHandler handler) | 1717 | XML_SkippedEntityHandler handler) |
| 1668 | { | 1718 | { |
| 1669 | if (parser != NULL) | 1719 | if (parser != NULL) |
| 1670 | skippedEntityHandler = handler; | 1720 | parser->m_skippedEntityHandler = handler; |
| 1671 | } | 1721 | } |
| 1672 | 1722 | ||
| 1673 | void XMLCALL | 1723 | void XMLCALL |
| @@ -1677,8 +1727,8 @@ XML_SetUnknownEncodingHandler(XML_Parser parser, | |||
| 1677 | { | 1727 | { |
| 1678 | if (parser == NULL) | 1728 | if (parser == NULL) |
| 1679 | return; | 1729 | return; |
| 1680 | unknownEncodingHandler = handler; | 1730 | parser->m_unknownEncodingHandler = handler; |
| 1681 | unknownEncodingHandlerData = data; | 1731 | parser->m_unknownEncodingHandlerData = data; |
| 1682 | } | 1732 | } |
| 1683 | 1733 | ||
| 1684 | void XMLCALL | 1734 | void XMLCALL |
| @@ -1686,7 +1736,7 @@ XML_SetElementDeclHandler(XML_Parser parser, | |||
| 1686 | XML_ElementDeclHandler eldecl) | 1736 | XML_ElementDeclHandler eldecl) |
| 1687 | { | 1737 | { |
| 1688 | if (parser != NULL) | 1738 | if (parser != NULL) |
| 1689 | elementDeclHandler = eldecl; | 1739 | parser->m_elementDeclHandler = eldecl; |
| 1690 | } | 1740 | } |
| 1691 | 1741 | ||
| 1692 | void XMLCALL | 1742 | void XMLCALL |
| @@ -1694,7 +1744,7 @@ XML_SetAttlistDeclHandler(XML_Parser parser, | |||
| 1694 | XML_AttlistDeclHandler attdecl) | 1744 | XML_AttlistDeclHandler attdecl) |
| 1695 | { | 1745 | { |
| 1696 | if (parser != NULL) | 1746 | if (parser != NULL) |
| 1697 | attlistDeclHandler = attdecl; | 1747 | parser->m_attlistDeclHandler = attdecl; |
| 1698 | } | 1748 | } |
| 1699 | 1749 | ||
| 1700 | void XMLCALL | 1750 | void XMLCALL |
| @@ -1702,14 +1752,14 @@ XML_SetEntityDeclHandler(XML_Parser parser, | |||
| 1702 | XML_EntityDeclHandler handler) | 1752 | XML_EntityDeclHandler handler) |
| 1703 | { | 1753 | { |
| 1704 | if (parser != NULL) | 1754 | if (parser != NULL) |
| 1705 | entityDeclHandler = handler; | 1755 | parser->m_entityDeclHandler = handler; |
| 1706 | } | 1756 | } |
| 1707 | 1757 | ||
| 1708 | void XMLCALL | 1758 | void XMLCALL |
| 1709 | XML_SetXmlDeclHandler(XML_Parser parser, | 1759 | XML_SetXmlDeclHandler(XML_Parser parser, |
| 1710 | XML_XmlDeclHandler handler) { | 1760 | XML_XmlDeclHandler handler) { |
| 1711 | if (parser != NULL) | 1761 | if (parser != NULL) |
| 1712 | xmlDeclHandler = handler; | 1762 | parser->m_xmlDeclHandler = handler; |
| 1713 | } | 1763 | } |
| 1714 | 1764 | ||
| 1715 | int XMLCALL | 1765 | int XMLCALL |
| @@ -1719,10 +1769,10 @@ XML_SetParamEntityParsing(XML_Parser parser, | |||
| 1719 | if (parser == NULL) | 1769 | if (parser == NULL) |
| 1720 | return 0; | 1770 | return 0; |
| 1721 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ | 1771 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
| 1722 | if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) | 1772 | if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 1723 | return 0; | 1773 | return 0; |
| 1724 | #ifdef XML_DTD | 1774 | #ifdef XML_DTD |
| 1725 | paramEntityParsing = peParsing; | 1775 | parser->m_paramEntityParsing = peParsing; |
| 1726 | return 1; | 1776 | return 1; |
| 1727 | #else | 1777 | #else |
| 1728 | return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; | 1778 | return peParsing == XML_PARAM_ENTITY_PARSING_NEVER; |
| @@ -1738,9 +1788,9 @@ XML_SetHashSalt(XML_Parser parser, | |||
| 1738 | if (parser->m_parentParser) | 1788 | if (parser->m_parentParser) |
| 1739 | return XML_SetHashSalt(parser->m_parentParser, hash_salt); | 1789 | return XML_SetHashSalt(parser->m_parentParser, hash_salt); |
| 1740 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ | 1790 | /* block after XML_Parse()/XML_ParseBuffer() has been called */ |
| 1741 | if (ps_parsing == XML_PARSING || ps_parsing == XML_SUSPENDED) | 1791 | if (parser->m_parsingStatus.parsing == XML_PARSING || parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 1742 | return 0; | 1792 | return 0; |
| 1743 | hash_secret_salt = hash_salt; | 1793 | parser->m_hash_secret_salt = hash_salt; |
| 1744 | return 1; | 1794 | return 1; |
| 1745 | } | 1795 | } |
| 1746 | 1796 | ||
| @@ -1748,88 +1798,103 @@ enum XML_Status XMLCALL | |||
| 1748 | XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) | 1798 | XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) |
| 1749 | { | 1799 | { |
| 1750 | if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) { | 1800 | if ((parser == NULL) || (len < 0) || ((s == NULL) && (len != 0))) { |
| 1751 | errorCode = XML_ERROR_INVALID_ARGUMENT; | 1801 | if (parser != NULL) |
| 1802 | parser->m_errorCode = XML_ERROR_INVALID_ARGUMENT; | ||
| 1752 | return XML_STATUS_ERROR; | 1803 | return XML_STATUS_ERROR; |
| 1753 | } | 1804 | } |
| 1754 | switch (ps_parsing) { | 1805 | switch (parser->m_parsingStatus.parsing) { |
| 1755 | case XML_SUSPENDED: | 1806 | case XML_SUSPENDED: |
| 1756 | errorCode = XML_ERROR_SUSPENDED; | 1807 | parser->m_errorCode = XML_ERROR_SUSPENDED; |
| 1757 | return XML_STATUS_ERROR; | 1808 | return XML_STATUS_ERROR; |
| 1758 | case XML_FINISHED: | 1809 | case XML_FINISHED: |
| 1759 | errorCode = XML_ERROR_FINISHED; | 1810 | parser->m_errorCode = XML_ERROR_FINISHED; |
| 1760 | return XML_STATUS_ERROR; | 1811 | return XML_STATUS_ERROR; |
| 1761 | case XML_INITIALIZED: | 1812 | case XML_INITIALIZED: |
| 1762 | if (parentParser == NULL && !startParsing(parser)) { | 1813 | if (parser->m_parentParser == NULL && !startParsing(parser)) { |
| 1763 | errorCode = XML_ERROR_NO_MEMORY; | 1814 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1764 | return XML_STATUS_ERROR; | 1815 | return XML_STATUS_ERROR; |
| 1765 | } | 1816 | } |
| 1817 | /* fall through */ | ||
| 1766 | default: | 1818 | default: |
| 1767 | ps_parsing = XML_PARSING; | 1819 | parser->m_parsingStatus.parsing = XML_PARSING; |
| 1768 | } | 1820 | } |
| 1769 | 1821 | ||
| 1770 | if (len == 0) { | 1822 | if (len == 0) { |
| 1771 | ps_finalBuffer = (XML_Bool)isFinal; | 1823 | parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; |
| 1772 | if (!isFinal) | 1824 | if (!isFinal) |
| 1773 | return XML_STATUS_OK; | 1825 | return XML_STATUS_OK; |
| 1774 | positionPtr = bufferPtr; | 1826 | parser->m_positionPtr = parser->m_bufferPtr; |
| 1775 | parseEndPtr = bufferEnd; | 1827 | parser->m_parseEndPtr = parser->m_bufferEnd; |
| 1776 | 1828 | ||
| 1777 | /* If data are left over from last buffer, and we now know that these | 1829 | /* If data are left over from last buffer, and we now know that these |
| 1778 | data are the final chunk of input, then we have to check them again | 1830 | data are the final chunk of input, then we have to check them again |
| 1779 | to detect errors based on that fact. | 1831 | to detect errors based on that fact. |
| 1780 | */ | 1832 | */ |
| 1781 | errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | 1833 | parser->m_errorCode = parser->m_processor(parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr); |
| 1782 | 1834 | ||
| 1783 | if (errorCode == XML_ERROR_NONE) { | 1835 | if (parser->m_errorCode == XML_ERROR_NONE) { |
| 1784 | switch (ps_parsing) { | 1836 | switch (parser->m_parsingStatus.parsing) { |
| 1785 | case XML_SUSPENDED: | 1837 | case XML_SUSPENDED: |
| 1786 | XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | 1838 | /* It is hard to be certain, but it seems that this case |
| 1787 | positionPtr = bufferPtr; | 1839 | * cannot occur. This code is cleaning up a previous parse |
| 1840 | * with no new data (since len == 0). Changing the parsing | ||
| 1841 | * state requires getting to execute a handler function, and | ||
| 1842 | * there doesn't seem to be an opportunity for that while in | ||
| 1843 | * this circumstance. | ||
| 1844 | * | ||
| 1845 | * Given the uncertainty, we retain the code but exclude it | ||
| 1846 | * from coverage tests. | ||
| 1847 | * | ||
| 1848 | * LCOV_EXCL_START | ||
| 1849 | */ | ||
| 1850 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); | ||
| 1851 | parser->m_positionPtr = parser->m_bufferPtr; | ||
| 1788 | return XML_STATUS_SUSPENDED; | 1852 | return XML_STATUS_SUSPENDED; |
| 1853 | /* LCOV_EXCL_STOP */ | ||
| 1789 | case XML_INITIALIZED: | 1854 | case XML_INITIALIZED: |
| 1790 | case XML_PARSING: | 1855 | case XML_PARSING: |
| 1791 | ps_parsing = XML_FINISHED; | 1856 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 1792 | /* fall through */ | 1857 | /* fall through */ |
| 1793 | default: | 1858 | default: |
| 1794 | return XML_STATUS_OK; | 1859 | return XML_STATUS_OK; |
| 1795 | } | 1860 | } |
| 1796 | } | 1861 | } |
| 1797 | eventEndPtr = eventPtr; | 1862 | parser->m_eventEndPtr = parser->m_eventPtr; |
| 1798 | processor = errorProcessor; | 1863 | parser->m_processor = errorProcessor; |
| 1799 | return XML_STATUS_ERROR; | 1864 | return XML_STATUS_ERROR; |
| 1800 | } | 1865 | } |
| 1801 | #ifndef XML_CONTEXT_BYTES | 1866 | #ifndef XML_CONTEXT_BYTES |
| 1802 | else if (bufferPtr == bufferEnd) { | 1867 | else if (parser->m_bufferPtr == parser->m_bufferEnd) { |
| 1803 | const char *end; | 1868 | const char *end; |
| 1804 | int nLeftOver; | 1869 | int nLeftOver; |
| 1805 | enum XML_Status result; | 1870 | enum XML_Status result; |
| 1806 | /* Detect overflow (a+b > MAX <==> b > MAX-a) */ | 1871 | /* Detect overflow (a+b > MAX <==> b > MAX-a) */ |
| 1807 | if (len > ((XML_Size)-1) / 2 - parseEndByteIndex) { | 1872 | if (len > ((XML_Size)-1) / 2 - parser->m_parseEndByteIndex) { |
| 1808 | errorCode = XML_ERROR_NO_MEMORY; | 1873 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1809 | eventPtr = eventEndPtr = NULL; | 1874 | parser->m_eventPtr = parser->m_eventEndPtr = NULL; |
| 1810 | processor = errorProcessor; | 1875 | parser->m_processor = errorProcessor; |
| 1811 | return XML_STATUS_ERROR; | 1876 | return XML_STATUS_ERROR; |
| 1812 | } | 1877 | } |
| 1813 | parseEndByteIndex += len; | 1878 | parser->m_parseEndByteIndex += len; |
| 1814 | positionPtr = s; | 1879 | parser->m_positionPtr = s; |
| 1815 | ps_finalBuffer = (XML_Bool)isFinal; | 1880 | parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; |
| 1816 | 1881 | ||
| 1817 | errorCode = processor(parser, s, parseEndPtr = s + len, &end); | 1882 | parser->m_errorCode = parser->m_processor(parser, s, parser->m_parseEndPtr = s + len, &end); |
| 1818 | 1883 | ||
| 1819 | if (errorCode != XML_ERROR_NONE) { | 1884 | if (parser->m_errorCode != XML_ERROR_NONE) { |
| 1820 | eventEndPtr = eventPtr; | 1885 | parser->m_eventEndPtr = parser->m_eventPtr; |
| 1821 | processor = errorProcessor; | 1886 | parser->m_processor = errorProcessor; |
| 1822 | return XML_STATUS_ERROR; | 1887 | return XML_STATUS_ERROR; |
| 1823 | } | 1888 | } |
| 1824 | else { | 1889 | else { |
| 1825 | switch (ps_parsing) { | 1890 | switch (parser->m_parsingStatus.parsing) { |
| 1826 | case XML_SUSPENDED: | 1891 | case XML_SUSPENDED: |
| 1827 | result = XML_STATUS_SUSPENDED; | 1892 | result = XML_STATUS_SUSPENDED; |
| 1828 | break; | 1893 | break; |
| 1829 | case XML_INITIALIZED: | 1894 | case XML_INITIALIZED: |
| 1830 | case XML_PARSING: | 1895 | case XML_PARSING: |
| 1831 | if (isFinal) { | 1896 | if (isFinal) { |
| 1832 | ps_parsing = XML_FINISHED; | 1897 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 1833 | return XML_STATUS_OK; | 1898 | return XML_STATUS_OK; |
| 1834 | } | 1899 | } |
| 1835 | /* fall through */ | 1900 | /* fall through */ |
| @@ -1838,35 +1903,33 @@ XML_Parse(XML_Parser parser, const char *s, int len, int isFinal) | |||
| 1838 | } | 1903 | } |
| 1839 | } | 1904 | } |
| 1840 | 1905 | ||
| 1841 | XmlUpdatePosition(encoding, positionPtr, end, &position); | 1906 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, end, &parser->m_position); |
| 1842 | nLeftOver = s + len - end; | 1907 | nLeftOver = s + len - end; |
| 1843 | if (nLeftOver) { | 1908 | if (nLeftOver) { |
| 1844 | if (buffer == NULL || nLeftOver > bufferLim - buffer) { | 1909 | if (parser->m_buffer == NULL || nLeftOver > parser->m_bufferLim - parser->m_buffer) { |
| 1845 | /* avoid _signed_ integer overflow */ | 1910 | /* avoid _signed_ integer overflow */ |
| 1846 | char *temp = NULL; | 1911 | char *temp = NULL; |
| 1847 | const int bytesToAllocate = (int)((unsigned)len * 2U); | 1912 | const int bytesToAllocate = (int)((unsigned)len * 2U); |
| 1848 | if (bytesToAllocate > 0) { | 1913 | if (bytesToAllocate > 0) { |
| 1849 | temp = (buffer == NULL | 1914 | temp = (char *)REALLOC(parser, parser->m_buffer, bytesToAllocate); |
| 1850 | ? (char *)MALLOC(bytesToAllocate) | ||
| 1851 | : (char *)REALLOC(buffer, bytesToAllocate)); | ||
| 1852 | } | 1915 | } |
| 1853 | if (temp == NULL) { | 1916 | if (temp == NULL) { |
| 1854 | errorCode = XML_ERROR_NO_MEMORY; | 1917 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1855 | eventPtr = eventEndPtr = NULL; | 1918 | parser->m_eventPtr = parser->m_eventEndPtr = NULL; |
| 1856 | processor = errorProcessor; | 1919 | parser->m_processor = errorProcessor; |
| 1857 | return XML_STATUS_ERROR; | 1920 | return XML_STATUS_ERROR; |
| 1858 | } | 1921 | } |
| 1859 | buffer = temp; | 1922 | parser->m_buffer = temp; |
| 1860 | bufferLim = buffer + bytesToAllocate; | 1923 | parser->m_bufferLim = parser->m_buffer + bytesToAllocate; |
| 1861 | } | 1924 | } |
| 1862 | memcpy(buffer, end, nLeftOver); | 1925 | memcpy(parser->m_buffer, end, nLeftOver); |
| 1863 | } | 1926 | } |
| 1864 | bufferPtr = buffer; | 1927 | parser->m_bufferPtr = parser->m_buffer; |
| 1865 | bufferEnd = buffer + nLeftOver; | 1928 | parser->m_bufferEnd = parser->m_buffer + nLeftOver; |
| 1866 | positionPtr = bufferPtr; | 1929 | parser->m_positionPtr = parser->m_bufferPtr; |
| 1867 | parseEndPtr = bufferEnd; | 1930 | parser->m_parseEndPtr = parser->m_bufferEnd; |
| 1868 | eventPtr = bufferPtr; | 1931 | parser->m_eventPtr = parser->m_bufferPtr; |
| 1869 | eventEndPtr = bufferPtr; | 1932 | parser->m_eventEndPtr = parser->m_bufferPtr; |
| 1870 | return result; | 1933 | return result; |
| 1871 | } | 1934 | } |
| 1872 | #endif /* not defined XML_CONTEXT_BYTES */ | 1935 | #endif /* not defined XML_CONTEXT_BYTES */ |
| @@ -1889,53 +1952,54 @@ XML_ParseBuffer(XML_Parser parser, int len, int isFinal) | |||
| 1889 | 1952 | ||
| 1890 | if (parser == NULL) | 1953 | if (parser == NULL) |
| 1891 | return XML_STATUS_ERROR; | 1954 | return XML_STATUS_ERROR; |
| 1892 | switch (ps_parsing) { | 1955 | switch (parser->m_parsingStatus.parsing) { |
| 1893 | case XML_SUSPENDED: | 1956 | case XML_SUSPENDED: |
| 1894 | errorCode = XML_ERROR_SUSPENDED; | 1957 | parser->m_errorCode = XML_ERROR_SUSPENDED; |
| 1895 | return XML_STATUS_ERROR; | 1958 | return XML_STATUS_ERROR; |
| 1896 | case XML_FINISHED: | 1959 | case XML_FINISHED: |
| 1897 | errorCode = XML_ERROR_FINISHED; | 1960 | parser->m_errorCode = XML_ERROR_FINISHED; |
| 1898 | return XML_STATUS_ERROR; | 1961 | return XML_STATUS_ERROR; |
| 1899 | case XML_INITIALIZED: | 1962 | case XML_INITIALIZED: |
| 1900 | if (parentParser == NULL && !startParsing(parser)) { | 1963 | if (parser->m_parentParser == NULL && !startParsing(parser)) { |
| 1901 | errorCode = XML_ERROR_NO_MEMORY; | 1964 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1902 | return XML_STATUS_ERROR; | 1965 | return XML_STATUS_ERROR; |
| 1903 | } | 1966 | } |
| 1967 | /* fall through */ | ||
| 1904 | default: | 1968 | default: |
| 1905 | ps_parsing = XML_PARSING; | 1969 | parser->m_parsingStatus.parsing = XML_PARSING; |
| 1906 | } | 1970 | } |
| 1907 | 1971 | ||
| 1908 | start = bufferPtr; | 1972 | start = parser->m_bufferPtr; |
| 1909 | positionPtr = start; | 1973 | parser->m_positionPtr = start; |
| 1910 | bufferEnd += len; | 1974 | parser->m_bufferEnd += len; |
| 1911 | parseEndPtr = bufferEnd; | 1975 | parser->m_parseEndPtr = parser->m_bufferEnd; |
| 1912 | parseEndByteIndex += len; | 1976 | parser->m_parseEndByteIndex += len; |
| 1913 | ps_finalBuffer = (XML_Bool)isFinal; | 1977 | parser->m_parsingStatus.finalBuffer = (XML_Bool)isFinal; |
| 1914 | 1978 | ||
| 1915 | errorCode = processor(parser, start, parseEndPtr, &bufferPtr); | 1979 | parser->m_errorCode = parser->m_processor(parser, start, parser->m_parseEndPtr, &parser->m_bufferPtr); |
| 1916 | 1980 | ||
| 1917 | if (errorCode != XML_ERROR_NONE) { | 1981 | if (parser->m_errorCode != XML_ERROR_NONE) { |
| 1918 | eventEndPtr = eventPtr; | 1982 | parser->m_eventEndPtr = parser->m_eventPtr; |
| 1919 | processor = errorProcessor; | 1983 | parser->m_processor = errorProcessor; |
| 1920 | return XML_STATUS_ERROR; | 1984 | return XML_STATUS_ERROR; |
| 1921 | } | 1985 | } |
| 1922 | else { | 1986 | else { |
| 1923 | switch (ps_parsing) { | 1987 | switch (parser->m_parsingStatus.parsing) { |
| 1924 | case XML_SUSPENDED: | 1988 | case XML_SUSPENDED: |
| 1925 | result = XML_STATUS_SUSPENDED; | 1989 | result = XML_STATUS_SUSPENDED; |
| 1926 | break; | 1990 | break; |
| 1927 | case XML_INITIALIZED: | 1991 | case XML_INITIALIZED: |
| 1928 | case XML_PARSING: | 1992 | case XML_PARSING: |
| 1929 | if (isFinal) { | 1993 | if (isFinal) { |
| 1930 | ps_parsing = XML_FINISHED; | 1994 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 1931 | return result; | 1995 | return result; |
| 1932 | } | 1996 | } |
| 1933 | default: ; /* should not happen */ | 1997 | default: ; /* should not happen */ |
| 1934 | } | 1998 | } |
| 1935 | } | 1999 | } |
| 1936 | 2000 | ||
| 1937 | XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | 2001 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); |
| 1938 | positionPtr = bufferPtr; | 2002 | parser->m_positionPtr = parser->m_bufferPtr; |
| 1939 | return result; | 2003 | return result; |
| 1940 | } | 2004 | } |
| 1941 | 2005 | ||
| @@ -1945,52 +2009,59 @@ XML_GetBuffer(XML_Parser parser, int len) | |||
| 1945 | if (parser == NULL) | 2009 | if (parser == NULL) |
| 1946 | return NULL; | 2010 | return NULL; |
| 1947 | if (len < 0) { | 2011 | if (len < 0) { |
| 1948 | errorCode = XML_ERROR_NO_MEMORY; | 2012 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1949 | return NULL; | 2013 | return NULL; |
| 1950 | } | 2014 | } |
| 1951 | switch (ps_parsing) { | 2015 | switch (parser->m_parsingStatus.parsing) { |
| 1952 | case XML_SUSPENDED: | 2016 | case XML_SUSPENDED: |
| 1953 | errorCode = XML_ERROR_SUSPENDED; | 2017 | parser->m_errorCode = XML_ERROR_SUSPENDED; |
| 1954 | return NULL; | 2018 | return NULL; |
| 1955 | case XML_FINISHED: | 2019 | case XML_FINISHED: |
| 1956 | errorCode = XML_ERROR_FINISHED; | 2020 | parser->m_errorCode = XML_ERROR_FINISHED; |
| 1957 | return NULL; | 2021 | return NULL; |
| 1958 | default: ; | 2022 | default: ; |
| 1959 | } | 2023 | } |
| 1960 | 2024 | ||
| 1961 | if (len > bufferLim - bufferEnd) { | 2025 | if (len > EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferEnd)) { |
| 1962 | #ifdef XML_CONTEXT_BYTES | 2026 | #ifdef XML_CONTEXT_BYTES |
| 1963 | int keep; | 2027 | int keep; |
| 1964 | #endif /* defined XML_CONTEXT_BYTES */ | 2028 | #endif /* defined XML_CONTEXT_BYTES */ |
| 1965 | /* Do not invoke signed arithmetic overflow: */ | 2029 | /* Do not invoke signed arithmetic overflow: */ |
| 1966 | int neededSize = (int) ((unsigned)len + (unsigned)(bufferEnd - bufferPtr)); | 2030 | int neededSize = (int) ((unsigned)len + |
| 2031 | (unsigned)EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, | ||
| 2032 | parser->m_bufferPtr)); | ||
| 1967 | if (neededSize < 0) { | 2033 | if (neededSize < 0) { |
| 1968 | errorCode = XML_ERROR_NO_MEMORY; | 2034 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 1969 | return NULL; | 2035 | return NULL; |
| 1970 | } | 2036 | } |
| 1971 | #ifdef XML_CONTEXT_BYTES | 2037 | #ifdef XML_CONTEXT_BYTES |
| 1972 | keep = (int)(bufferPtr - buffer); | 2038 | keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); |
| 1973 | if (keep > XML_CONTEXT_BYTES) | 2039 | if (keep > XML_CONTEXT_BYTES) |
| 1974 | keep = XML_CONTEXT_BYTES; | 2040 | keep = XML_CONTEXT_BYTES; |
| 1975 | neededSize += keep; | 2041 | neededSize += keep; |
| 1976 | #endif /* defined XML_CONTEXT_BYTES */ | 2042 | #endif /* defined XML_CONTEXT_BYTES */ |
| 1977 | if (neededSize <= bufferLim - buffer) { | 2043 | if (neededSize <= EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_buffer)) { |
| 1978 | #ifdef XML_CONTEXT_BYTES | 2044 | #ifdef XML_CONTEXT_BYTES |
| 1979 | if (keep < bufferPtr - buffer) { | 2045 | if (keep < EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer)) { |
| 1980 | int offset = (int)(bufferPtr - buffer) - keep; | 2046 | int offset = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer) - keep; |
| 1981 | memmove(buffer, &buffer[offset], bufferEnd - bufferPtr + keep); | 2047 | /* The buffer pointers cannot be NULL here; we have at least some bytes in the buffer */ |
| 1982 | bufferEnd -= offset; | 2048 | memmove(parser->m_buffer, &parser->m_buffer[offset], parser->m_bufferEnd - parser->m_bufferPtr + keep); |
| 1983 | bufferPtr -= offset; | 2049 | parser->m_bufferEnd -= offset; |
| 2050 | parser->m_bufferPtr -= offset; | ||
| 1984 | } | 2051 | } |
| 1985 | #else | 2052 | #else |
| 1986 | memmove(buffer, bufferPtr, bufferEnd - bufferPtr); | 2053 | if (parser->m_buffer && parser->m_bufferPtr) { |
| 1987 | bufferEnd = buffer + (bufferEnd - bufferPtr); | 2054 | memmove(parser->m_buffer, parser->m_bufferPtr, |
| 1988 | bufferPtr = buffer; | 2055 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)); |
| 2056 | parser->m_bufferEnd = parser->m_buffer + | ||
| 2057 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); | ||
| 2058 | parser->m_bufferPtr = parser->m_buffer; | ||
| 2059 | } | ||
| 1989 | #endif /* not defined XML_CONTEXT_BYTES */ | 2060 | #endif /* not defined XML_CONTEXT_BYTES */ |
| 1990 | } | 2061 | } |
| 1991 | else { | 2062 | else { |
| 1992 | char *newBuf; | 2063 | char *newBuf; |
| 1993 | int bufferSize = (int)(bufferLim - bufferPtr); | 2064 | int bufferSize = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferLim, parser->m_bufferPtr); |
| 1994 | if (bufferSize == 0) | 2065 | if (bufferSize == 0) |
| 1995 | bufferSize = INIT_BUFFER_SIZE; | 2066 | bufferSize = INIT_BUFFER_SIZE; |
| 1996 | do { | 2067 | do { |
| @@ -1998,43 +2069,52 @@ XML_GetBuffer(XML_Parser parser, int len) | |||
| 1998 | bufferSize = (int) (2U * (unsigned) bufferSize); | 2069 | bufferSize = (int) (2U * (unsigned) bufferSize); |
| 1999 | } while (bufferSize < neededSize && bufferSize > 0); | 2070 | } while (bufferSize < neededSize && bufferSize > 0); |
| 2000 | if (bufferSize <= 0) { | 2071 | if (bufferSize <= 0) { |
| 2001 | errorCode = XML_ERROR_NO_MEMORY; | 2072 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 2002 | return NULL; | 2073 | return NULL; |
| 2003 | } | 2074 | } |
| 2004 | newBuf = (char *)MALLOC(bufferSize); | 2075 | newBuf = (char *)MALLOC(parser, bufferSize); |
| 2005 | if (newBuf == 0) { | 2076 | if (newBuf == 0) { |
| 2006 | errorCode = XML_ERROR_NO_MEMORY; | 2077 | parser->m_errorCode = XML_ERROR_NO_MEMORY; |
| 2007 | return NULL; | 2078 | return NULL; |
| 2008 | } | 2079 | } |
| 2009 | bufferLim = newBuf + bufferSize; | 2080 | parser->m_bufferLim = newBuf + bufferSize; |
| 2010 | #ifdef XML_CONTEXT_BYTES | 2081 | #ifdef XML_CONTEXT_BYTES |
| 2011 | if (bufferPtr) { | 2082 | if (parser->m_bufferPtr) { |
| 2012 | int keep = (int)(bufferPtr - buffer); | 2083 | int keep = (int)EXPAT_SAFE_PTR_DIFF(parser->m_bufferPtr, parser->m_buffer); |
| 2013 | if (keep > XML_CONTEXT_BYTES) | 2084 | if (keep > XML_CONTEXT_BYTES) |
| 2014 | keep = XML_CONTEXT_BYTES; | 2085 | keep = XML_CONTEXT_BYTES; |
| 2015 | memcpy(newBuf, &bufferPtr[-keep], bufferEnd - bufferPtr + keep); | 2086 | memcpy(newBuf, &parser->m_bufferPtr[-keep], |
| 2016 | FREE(buffer); | 2087 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep); |
| 2017 | buffer = newBuf; | 2088 | FREE(parser, parser->m_buffer); |
| 2018 | bufferEnd = buffer + (bufferEnd - bufferPtr) + keep; | 2089 | parser->m_buffer = newBuf; |
| 2019 | bufferPtr = buffer + keep; | 2090 | parser->m_bufferEnd = parser->m_buffer + |
| 2091 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr) + keep; | ||
| 2092 | parser->m_bufferPtr = parser->m_buffer + keep; | ||
| 2020 | } | 2093 | } |
| 2021 | else { | 2094 | else { |
| 2022 | bufferEnd = newBuf + (bufferEnd - bufferPtr); | 2095 | /* This must be a brand new buffer with no data in it yet */ |
| 2023 | bufferPtr = buffer = newBuf; | 2096 | parser->m_bufferEnd = newBuf; |
| 2097 | parser->m_bufferPtr = parser->m_buffer = newBuf; | ||
| 2024 | } | 2098 | } |
| 2025 | #else | 2099 | #else |
| 2026 | if (bufferPtr) { | 2100 | if (parser->m_bufferPtr) { |
| 2027 | memcpy(newBuf, bufferPtr, bufferEnd - bufferPtr); | 2101 | memcpy(newBuf, parser->m_bufferPtr, |
| 2028 | FREE(buffer); | 2102 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr)); |
| 2103 | FREE(parser, parser->m_buffer); | ||
| 2104 | parser->m_bufferEnd = newBuf + | ||
| 2105 | EXPAT_SAFE_PTR_DIFF(parser->m_bufferEnd, parser->m_bufferPtr); | ||
| 2106 | } | ||
| 2107 | else { | ||
| 2108 | /* This must be a brand new buffer with no data in it yet */ | ||
| 2109 | parser->m_bufferEnd = newBuf; | ||
| 2029 | } | 2110 | } |
| 2030 | bufferEnd = newBuf + (bufferEnd - bufferPtr); | 2111 | parser->m_bufferPtr = parser->m_buffer = newBuf; |
| 2031 | bufferPtr = buffer = newBuf; | ||
| 2032 | #endif /* not defined XML_CONTEXT_BYTES */ | 2112 | #endif /* not defined XML_CONTEXT_BYTES */ |
| 2033 | } | 2113 | } |
| 2034 | eventPtr = eventEndPtr = NULL; | 2114 | parser->m_eventPtr = parser->m_eventEndPtr = NULL; |
| 2035 | positionPtr = NULL; | 2115 | parser->m_positionPtr = NULL; |
| 2036 | } | 2116 | } |
| 2037 | return bufferEnd; | 2117 | return parser->m_bufferEnd; |
| 2038 | } | 2118 | } |
| 2039 | 2119 | ||
| 2040 | enum XML_Status XMLCALL | 2120 | enum XML_Status XMLCALL |
| @@ -2042,29 +2122,29 @@ XML_StopParser(XML_Parser parser, XML_Bool resumable) | |||
| 2042 | { | 2122 | { |
| 2043 | if (parser == NULL) | 2123 | if (parser == NULL) |
| 2044 | return XML_STATUS_ERROR; | 2124 | return XML_STATUS_ERROR; |
| 2045 | switch (ps_parsing) { | 2125 | switch (parser->m_parsingStatus.parsing) { |
| 2046 | case XML_SUSPENDED: | 2126 | case XML_SUSPENDED: |
| 2047 | if (resumable) { | 2127 | if (resumable) { |
| 2048 | errorCode = XML_ERROR_SUSPENDED; | 2128 | parser->m_errorCode = XML_ERROR_SUSPENDED; |
| 2049 | return XML_STATUS_ERROR; | 2129 | return XML_STATUS_ERROR; |
| 2050 | } | 2130 | } |
| 2051 | ps_parsing = XML_FINISHED; | 2131 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 2052 | break; | 2132 | break; |
| 2053 | case XML_FINISHED: | 2133 | case XML_FINISHED: |
| 2054 | errorCode = XML_ERROR_FINISHED; | 2134 | parser->m_errorCode = XML_ERROR_FINISHED; |
| 2055 | return XML_STATUS_ERROR; | 2135 | return XML_STATUS_ERROR; |
| 2056 | default: | 2136 | default: |
| 2057 | if (resumable) { | 2137 | if (resumable) { |
| 2058 | #ifdef XML_DTD | 2138 | #ifdef XML_DTD |
| 2059 | if (isParamEntity) { | 2139 | if (parser->m_isParamEntity) { |
| 2060 | errorCode = XML_ERROR_SUSPEND_PE; | 2140 | parser->m_errorCode = XML_ERROR_SUSPEND_PE; |
| 2061 | return XML_STATUS_ERROR; | 2141 | return XML_STATUS_ERROR; |
| 2062 | } | 2142 | } |
| 2063 | #endif | 2143 | #endif |
| 2064 | ps_parsing = XML_SUSPENDED; | 2144 | parser->m_parsingStatus.parsing = XML_SUSPENDED; |
| 2065 | } | 2145 | } |
| 2066 | else | 2146 | else |
| 2067 | ps_parsing = XML_FINISHED; | 2147 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 2068 | } | 2148 | } |
| 2069 | return XML_STATUS_OK; | 2149 | return XML_STATUS_OK; |
| 2070 | } | 2150 | } |
| @@ -2076,36 +2156,36 @@ XML_ResumeParser(XML_Parser parser) | |||
| 2076 | 2156 | ||
| 2077 | if (parser == NULL) | 2157 | if (parser == NULL) |
| 2078 | return XML_STATUS_ERROR; | 2158 | return XML_STATUS_ERROR; |
| 2079 | if (ps_parsing != XML_SUSPENDED) { | 2159 | if (parser->m_parsingStatus.parsing != XML_SUSPENDED) { |
| 2080 | errorCode = XML_ERROR_NOT_SUSPENDED; | 2160 | parser->m_errorCode = XML_ERROR_NOT_SUSPENDED; |
| 2081 | return XML_STATUS_ERROR; | 2161 | return XML_STATUS_ERROR; |
| 2082 | } | 2162 | } |
| 2083 | ps_parsing = XML_PARSING; | 2163 | parser->m_parsingStatus.parsing = XML_PARSING; |
| 2084 | 2164 | ||
| 2085 | errorCode = processor(parser, bufferPtr, parseEndPtr, &bufferPtr); | 2165 | parser->m_errorCode = parser->m_processor(parser, parser->m_bufferPtr, parser->m_parseEndPtr, &parser->m_bufferPtr); |
| 2086 | 2166 | ||
| 2087 | if (errorCode != XML_ERROR_NONE) { | 2167 | if (parser->m_errorCode != XML_ERROR_NONE) { |
| 2088 | eventEndPtr = eventPtr; | 2168 | parser->m_eventEndPtr = parser->m_eventPtr; |
| 2089 | processor = errorProcessor; | 2169 | parser->m_processor = errorProcessor; |
| 2090 | return XML_STATUS_ERROR; | 2170 | return XML_STATUS_ERROR; |
| 2091 | } | 2171 | } |
| 2092 | else { | 2172 | else { |
| 2093 | switch (ps_parsing) { | 2173 | switch (parser->m_parsingStatus.parsing) { |
| 2094 | case XML_SUSPENDED: | 2174 | case XML_SUSPENDED: |
| 2095 | result = XML_STATUS_SUSPENDED; | 2175 | result = XML_STATUS_SUSPENDED; |
| 2096 | break; | 2176 | break; |
| 2097 | case XML_INITIALIZED: | 2177 | case XML_INITIALIZED: |
| 2098 | case XML_PARSING: | 2178 | case XML_PARSING: |
| 2099 | if (ps_finalBuffer) { | 2179 | if (parser->m_parsingStatus.finalBuffer) { |
| 2100 | ps_parsing = XML_FINISHED; | 2180 | parser->m_parsingStatus.parsing = XML_FINISHED; |
| 2101 | return result; | 2181 | return result; |
| 2102 | } | 2182 | } |
| 2103 | default: ; | 2183 | default: ; |
| 2104 | } | 2184 | } |
| 2105 | } | 2185 | } |
| 2106 | 2186 | ||
| 2107 | XmlUpdatePosition(encoding, positionPtr, bufferPtr, &position); | 2187 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_bufferPtr, &parser->m_position); |
| 2108 | positionPtr = bufferPtr; | 2188 | parser->m_positionPtr = parser->m_bufferPtr; |
| 2109 | return result; | 2189 | return result; |
| 2110 | } | 2190 | } |
| 2111 | 2191 | ||
| @@ -2123,7 +2203,7 @@ XML_GetErrorCode(XML_Parser parser) | |||
| 2123 | { | 2203 | { |
| 2124 | if (parser == NULL) | 2204 | if (parser == NULL) |
| 2125 | return XML_ERROR_INVALID_ARGUMENT; | 2205 | return XML_ERROR_INVALID_ARGUMENT; |
| 2126 | return errorCode; | 2206 | return parser->m_errorCode; |
| 2127 | } | 2207 | } |
| 2128 | 2208 | ||
| 2129 | XML_Index XMLCALL | 2209 | XML_Index XMLCALL |
| @@ -2131,8 +2211,8 @@ XML_GetCurrentByteIndex(XML_Parser parser) | |||
| 2131 | { | 2211 | { |
| 2132 | if (parser == NULL) | 2212 | if (parser == NULL) |
| 2133 | return -1; | 2213 | return -1; |
| 2134 | if (eventPtr) | 2214 | if (parser->m_eventPtr) |
| 2135 | return (XML_Index)(parseEndByteIndex - (parseEndPtr - eventPtr)); | 2215 | return (XML_Index)(parser->m_parseEndByteIndex - (parser->m_parseEndPtr - parser->m_eventPtr)); |
| 2136 | return -1; | 2216 | return -1; |
| 2137 | } | 2217 | } |
| 2138 | 2218 | ||
| @@ -2141,8 +2221,8 @@ XML_GetCurrentByteCount(XML_Parser parser) | |||
| 2141 | { | 2221 | { |
| 2142 | if (parser == NULL) | 2222 | if (parser == NULL) |
| 2143 | return 0; | 2223 | return 0; |
| 2144 | if (eventEndPtr && eventPtr) | 2224 | if (parser->m_eventEndPtr && parser->m_eventPtr) |
| 2145 | return (int)(eventEndPtr - eventPtr); | 2225 | return (int)(parser->m_eventEndPtr - parser->m_eventPtr); |
| 2146 | return 0; | 2226 | return 0; |
| 2147 | } | 2227 | } |
| 2148 | 2228 | ||
| @@ -2152,12 +2232,12 @@ XML_GetInputContext(XML_Parser parser, int *offset, int *size) | |||
| 2152 | #ifdef XML_CONTEXT_BYTES | 2232 | #ifdef XML_CONTEXT_BYTES |
| 2153 | if (parser == NULL) | 2233 | if (parser == NULL) |
| 2154 | return NULL; | 2234 | return NULL; |
| 2155 | if (eventPtr && buffer) { | 2235 | if (parser->m_eventPtr && parser->m_buffer) { |
| 2156 | if (offset != NULL) | 2236 | if (offset != NULL) |
| 2157 | *offset = (int)(eventPtr - buffer); | 2237 | *offset = (int)(parser->m_eventPtr - parser->m_buffer); |
| 2158 | if (size != NULL) | 2238 | if (size != NULL) |
| 2159 | *size = (int)(bufferEnd - buffer); | 2239 | *size = (int)(parser->m_bufferEnd - parser->m_buffer); |
| 2160 | return buffer; | 2240 | return parser->m_buffer; |
| 2161 | } | 2241 | } |
| 2162 | #else | 2242 | #else |
| 2163 | (void)parser; | 2243 | (void)parser; |
| @@ -2172,11 +2252,11 @@ XML_GetCurrentLineNumber(XML_Parser parser) | |||
| 2172 | { | 2252 | { |
| 2173 | if (parser == NULL) | 2253 | if (parser == NULL) |
| 2174 | return 0; | 2254 | return 0; |
| 2175 | if (eventPtr && eventPtr >= positionPtr) { | 2255 | if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { |
| 2176 | XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); | 2256 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_eventPtr, &parser->m_position); |
| 2177 | positionPtr = eventPtr; | 2257 | parser->m_positionPtr = parser->m_eventPtr; |
| 2178 | } | 2258 | } |
| 2179 | return position.lineNumber + 1; | 2259 | return parser->m_position.lineNumber + 1; |
| 2180 | } | 2260 | } |
| 2181 | 2261 | ||
| 2182 | XML_Size XMLCALL | 2262 | XML_Size XMLCALL |
| @@ -2184,18 +2264,18 @@ XML_GetCurrentColumnNumber(XML_Parser parser) | |||
| 2184 | { | 2264 | { |
| 2185 | if (parser == NULL) | 2265 | if (parser == NULL) |
| 2186 | return 0; | 2266 | return 0; |
| 2187 | if (eventPtr && eventPtr >= positionPtr) { | 2267 | if (parser->m_eventPtr && parser->m_eventPtr >= parser->m_positionPtr) { |
| 2188 | XmlUpdatePosition(encoding, positionPtr, eventPtr, &position); | 2268 | XmlUpdatePosition(parser->m_encoding, parser->m_positionPtr, parser->m_eventPtr, &parser->m_position); |
| 2189 | positionPtr = eventPtr; | 2269 | parser->m_positionPtr = parser->m_eventPtr; |
| 2190 | } | 2270 | } |
| 2191 | return position.columnNumber; | 2271 | return parser->m_position.columnNumber; |
| 2192 | } | 2272 | } |
| 2193 | 2273 | ||
| 2194 | void XMLCALL | 2274 | void XMLCALL |
| 2195 | XML_FreeContentModel(XML_Parser parser, XML_Content *model) | 2275 | XML_FreeContentModel(XML_Parser parser, XML_Content *model) |
| 2196 | { | 2276 | { |
| 2197 | if (parser != NULL) | 2277 | if (parser != NULL) |
| 2198 | FREE(model); | 2278 | FREE(parser, model); |
| 2199 | } | 2279 | } |
| 2200 | 2280 | ||
| 2201 | void * XMLCALL | 2281 | void * XMLCALL |
| @@ -2203,7 +2283,7 @@ XML_MemMalloc(XML_Parser parser, size_t size) | |||
| 2203 | { | 2283 | { |
| 2204 | if (parser == NULL) | 2284 | if (parser == NULL) |
| 2205 | return NULL; | 2285 | return NULL; |
| 2206 | return MALLOC(size); | 2286 | return MALLOC(parser, size); |
| 2207 | } | 2287 | } |
| 2208 | 2288 | ||
| 2209 | void * XMLCALL | 2289 | void * XMLCALL |
| @@ -2211,14 +2291,14 @@ XML_MemRealloc(XML_Parser parser, void *ptr, size_t size) | |||
| 2211 | { | 2291 | { |
| 2212 | if (parser == NULL) | 2292 | if (parser == NULL) |
| 2213 | return NULL; | 2293 | return NULL; |
| 2214 | return REALLOC(ptr, size); | 2294 | return REALLOC(parser, ptr, size); |
| 2215 | } | 2295 | } |
| 2216 | 2296 | ||
| 2217 | void XMLCALL | 2297 | void XMLCALL |
| 2218 | XML_MemFree(XML_Parser parser, void *ptr) | 2298 | XML_MemFree(XML_Parser parser, void *ptr) |
| 2219 | { | 2299 | { |
| 2220 | if (parser != NULL) | 2300 | if (parser != NULL) |
| 2221 | FREE(ptr); | 2301 | FREE(parser, ptr); |
| 2222 | } | 2302 | } |
| 2223 | 2303 | ||
| 2224 | void XMLCALL | 2304 | void XMLCALL |
| @@ -2226,65 +2306,110 @@ XML_DefaultCurrent(XML_Parser parser) | |||
| 2226 | { | 2306 | { |
| 2227 | if (parser == NULL) | 2307 | if (parser == NULL) |
| 2228 | return; | 2308 | return; |
| 2229 | if (defaultHandler) { | 2309 | if (parser->m_defaultHandler) { |
| 2230 | if (openInternalEntities) | 2310 | if (parser->m_openInternalEntities) |
| 2231 | reportDefault(parser, | 2311 | reportDefault(parser, |
| 2232 | internalEncoding, | 2312 | parser->m_internalEncoding, |
| 2233 | openInternalEntities->internalEventPtr, | 2313 | parser->m_openInternalEntities->internalEventPtr, |
| 2234 | openInternalEntities->internalEventEndPtr); | 2314 | parser->m_openInternalEntities->internalEventEndPtr); |
| 2235 | else | 2315 | else |
| 2236 | reportDefault(parser, encoding, eventPtr, eventEndPtr); | 2316 | reportDefault(parser, parser->m_encoding, parser->m_eventPtr, parser->m_eventEndPtr); |
| 2237 | } | 2317 | } |
| 2238 | } | 2318 | } |
| 2239 | 2319 | ||
| 2240 | const XML_LChar * XMLCALL | 2320 | const XML_LChar * XMLCALL |
| 2241 | XML_ErrorString(enum XML_Error code) | 2321 | XML_ErrorString(enum XML_Error code) |
| 2242 | { | 2322 | { |
| 2243 | static const XML_LChar* const message[] = { | 2323 | switch (code) { |
| 2244 | 0, | 2324 | case XML_ERROR_NONE: |
| 2245 | XML_L("out of memory"), | 2325 | return NULL; |
| 2246 | XML_L("syntax error"), | 2326 | case XML_ERROR_NO_MEMORY: |
| 2247 | XML_L("no element found"), | 2327 | return XML_L("out of memory"); |
| 2248 | XML_L("not well-formed (invalid token)"), | 2328 | case XML_ERROR_SYNTAX: |
| 2249 | XML_L("unclosed token"), | 2329 | return XML_L("syntax error"); |
| 2250 | XML_L("partial character"), | 2330 | case XML_ERROR_NO_ELEMENTS: |
| 2251 | XML_L("mismatched tag"), | 2331 | return XML_L("no element found"); |
| 2252 | XML_L("duplicate attribute"), | 2332 | case XML_ERROR_INVALID_TOKEN: |
| 2253 | XML_L("junk after document element"), | 2333 | return XML_L("not well-formed (invalid token)"); |
| 2254 | XML_L("illegal parameter entity reference"), | 2334 | case XML_ERROR_UNCLOSED_TOKEN: |
| 2255 | XML_L("undefined entity"), | 2335 | return XML_L("unclosed token"); |
| 2256 | XML_L("recursive entity reference"), | 2336 | case XML_ERROR_PARTIAL_CHAR: |
| 2257 | XML_L("asynchronous entity"), | 2337 | return XML_L("partial character"); |
| 2258 | XML_L("reference to invalid character number"), | 2338 | case XML_ERROR_TAG_MISMATCH: |
| 2259 | XML_L("reference to binary entity"), | 2339 | return XML_L("mismatched tag"); |
| 2260 | XML_L("reference to external entity in attribute"), | 2340 | case XML_ERROR_DUPLICATE_ATTRIBUTE: |
| 2261 | XML_L("XML or text declaration not at start of entity"), | 2341 | return XML_L("duplicate attribute"); |
| 2262 | XML_L("unknown encoding"), | 2342 | case XML_ERROR_JUNK_AFTER_DOC_ELEMENT: |
| 2263 | XML_L("encoding specified in XML declaration is incorrect"), | 2343 | return XML_L("junk after document element"); |
| 2264 | XML_L("unclosed CDATA section"), | 2344 | case XML_ERROR_PARAM_ENTITY_REF: |
| 2265 | XML_L("error in processing external entity reference"), | 2345 | return XML_L("illegal parameter entity reference"); |
| 2266 | XML_L("document is not standalone"), | 2346 | case XML_ERROR_UNDEFINED_ENTITY: |
| 2267 | XML_L("unexpected parser state - please send a bug report"), | 2347 | return XML_L("undefined entity"); |
| 2268 | XML_L("entity declared in parameter entity"), | 2348 | case XML_ERROR_RECURSIVE_ENTITY_REF: |
| 2269 | XML_L("requested feature requires XML_DTD support in Expat"), | 2349 | return XML_L("recursive entity reference"); |
| 2270 | XML_L("cannot change setting once parsing has begun"), | 2350 | case XML_ERROR_ASYNC_ENTITY: |
| 2271 | XML_L("unbound prefix"), | 2351 | return XML_L("asynchronous entity"); |
| 2272 | XML_L("must not undeclare prefix"), | 2352 | case XML_ERROR_BAD_CHAR_REF: |
| 2273 | XML_L("incomplete markup in parameter entity"), | 2353 | return XML_L("reference to invalid character number"); |
| 2274 | XML_L("XML declaration not well-formed"), | 2354 | case XML_ERROR_BINARY_ENTITY_REF: |
| 2275 | XML_L("text declaration not well-formed"), | 2355 | return XML_L("reference to binary entity"); |
| 2276 | XML_L("illegal character(s) in public id"), | 2356 | case XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF: |
| 2277 | XML_L("parser suspended"), | 2357 | return XML_L("reference to external entity in attribute"); |
| 2278 | XML_L("parser not suspended"), | 2358 | case XML_ERROR_MISPLACED_XML_PI: |
| 2279 | XML_L("parsing aborted"), | 2359 | return XML_L("XML or text declaration not at start of entity"); |
| 2280 | XML_L("parsing finished"), | 2360 | case XML_ERROR_UNKNOWN_ENCODING: |
| 2281 | XML_L("cannot suspend in external parameter entity"), | 2361 | return XML_L("unknown encoding"); |
| 2282 | XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"), | 2362 | case XML_ERROR_INCORRECT_ENCODING: |
| 2283 | XML_L("reserved prefix (xmlns) must not be declared or undeclared"), | 2363 | return XML_L("encoding specified in XML declaration is incorrect"); |
| 2284 | XML_L("prefix must not be bound to one of the reserved namespace names") | 2364 | case XML_ERROR_UNCLOSED_CDATA_SECTION: |
| 2285 | }; | 2365 | return XML_L("unclosed CDATA section"); |
| 2286 | if (code > 0 && code < sizeof(message)/sizeof(message[0])) | 2366 | case XML_ERROR_EXTERNAL_ENTITY_HANDLING: |
| 2287 | return message[code]; | 2367 | return XML_L("error in processing external entity reference"); |
| 2368 | case XML_ERROR_NOT_STANDALONE: | ||
| 2369 | return XML_L("document is not standalone"); | ||
| 2370 | case XML_ERROR_UNEXPECTED_STATE: | ||
| 2371 | return XML_L("unexpected parser state - please send a bug report"); | ||
| 2372 | case XML_ERROR_ENTITY_DECLARED_IN_PE: | ||
| 2373 | return XML_L("entity declared in parameter entity"); | ||
| 2374 | case XML_ERROR_FEATURE_REQUIRES_XML_DTD: | ||
| 2375 | return XML_L("requested feature requires XML_DTD support in Expat"); | ||
| 2376 | case XML_ERROR_CANT_CHANGE_FEATURE_ONCE_PARSING: | ||
| 2377 | return XML_L("cannot change setting once parsing has begun"); | ||
| 2378 | /* Added in 1.95.7. */ | ||
| 2379 | case XML_ERROR_UNBOUND_PREFIX: | ||
| 2380 | return XML_L("unbound prefix"); | ||
| 2381 | /* Added in 1.95.8. */ | ||
| 2382 | case XML_ERROR_UNDECLARING_PREFIX: | ||
| 2383 | return XML_L("must not undeclare prefix"); | ||
| 2384 | case XML_ERROR_INCOMPLETE_PE: | ||
| 2385 | return XML_L("incomplete markup in parameter entity"); | ||
| 2386 | case XML_ERROR_XML_DECL: | ||
| 2387 | return XML_L("XML declaration not well-formed"); | ||
| 2388 | case XML_ERROR_TEXT_DECL: | ||
| 2389 | return XML_L("text declaration not well-formed"); | ||
| 2390 | case XML_ERROR_PUBLICID: | ||
| 2391 | return XML_L("illegal character(s) in public id"); | ||
| 2392 | case XML_ERROR_SUSPENDED: | ||
| 2393 | return XML_L("parser suspended"); | ||
| 2394 | case XML_ERROR_NOT_SUSPENDED: | ||
| 2395 | return XML_L("parser not suspended"); | ||
| 2396 | case XML_ERROR_ABORTED: | ||
| 2397 | return XML_L("parsing aborted"); | ||
| 2398 | case XML_ERROR_FINISHED: | ||
| 2399 | return XML_L("parsing finished"); | ||
| 2400 | case XML_ERROR_SUSPEND_PE: | ||
| 2401 | return XML_L("cannot suspend in external parameter entity"); | ||
| 2402 | /* Added in 2.0.0. */ | ||
| 2403 | case XML_ERROR_RESERVED_PREFIX_XML: | ||
| 2404 | return XML_L("reserved prefix (xml) must not be undeclared or bound to another namespace name"); | ||
| 2405 | case XML_ERROR_RESERVED_PREFIX_XMLNS: | ||
| 2406 | return XML_L("reserved prefix (xmlns) must not be declared or undeclared"); | ||
| 2407 | case XML_ERROR_RESERVED_NAMESPACE_URI: | ||
| 2408 | return XML_L("prefix must not be bound to one of the reserved namespace names"); | ||
| 2409 | /* Added in 2.2.5. */ | ||
| 2410 | case XML_ERROR_INVALID_ARGUMENT: /* Constant added in 2.2.1, already */ | ||
| 2411 | return XML_L("invalid argument"); | ||
| 2412 | } | ||
| 2288 | return NULL; | 2413 | return NULL; |
| 2289 | } | 2414 | } |
| 2290 | 2415 | ||
| @@ -2367,12 +2492,12 @@ XML_GetFeatureList(void) | |||
| 2367 | static XML_Bool | 2492 | static XML_Bool |
| 2368 | storeRawNames(XML_Parser parser) | 2493 | storeRawNames(XML_Parser parser) |
| 2369 | { | 2494 | { |
| 2370 | TAG *tag = tagStack; | 2495 | TAG *tag = parser->m_tagStack; |
| 2371 | while (tag) { | 2496 | while (tag) { |
| 2372 | int bufSize; | 2497 | int bufSize; |
| 2373 | int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); | 2498 | int nameLen = sizeof(XML_Char) * (tag->name.strLen + 1); |
| 2374 | char *rawNameBuf = tag->buf + nameLen; | 2499 | char *rawNameBuf = tag->buf + nameLen; |
| 2375 | /* Stop if already stored. Since tagStack is a stack, we can stop | 2500 | /* Stop if already stored. Since m_tagStack is a stack, we can stop |
| 2376 | at the first entry that has already been copied; everything | 2501 | at the first entry that has already been copied; everything |
| 2377 | below it in the stack is already been accounted for in a | 2502 | below it in the stack is already been accounted for in a |
| 2378 | previous call to this function. | 2503 | previous call to this function. |
| @@ -2384,7 +2509,7 @@ storeRawNames(XML_Parser parser) | |||
| 2384 | */ | 2509 | */ |
| 2385 | bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); | 2510 | bufSize = nameLen + ROUND_UP(tag->rawNameLength, sizeof(XML_Char)); |
| 2386 | if (bufSize > tag->bufEnd - tag->buf) { | 2511 | if (bufSize > tag->bufEnd - tag->buf) { |
| 2387 | char *temp = (char *)REALLOC(tag->buf, bufSize); | 2512 | char *temp = (char *)REALLOC(parser, tag->buf, bufSize); |
| 2388 | if (temp == NULL) | 2513 | if (temp == NULL) |
| 2389 | return XML_FALSE; | 2514 | return XML_FALSE; |
| 2390 | /* if tag->name.str points to tag->buf (only when namespace | 2515 | /* if tag->name.str points to tag->buf (only when namespace |
| @@ -2415,8 +2540,8 @@ contentProcessor(XML_Parser parser, | |||
| 2415 | const char *end, | 2540 | const char *end, |
| 2416 | const char **endPtr) | 2541 | const char **endPtr) |
| 2417 | { | 2542 | { |
| 2418 | enum XML_Error result = doContent(parser, 0, encoding, start, end, | 2543 | enum XML_Error result = doContent(parser, 0, parser->m_encoding, start, end, |
| 2419 | endPtr, (XML_Bool)!ps_finalBuffer); | 2544 | endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 2420 | if (result == XML_ERROR_NONE) { | 2545 | if (result == XML_ERROR_NONE) { |
| 2421 | if (!storeRawNames(parser)) | 2546 | if (!storeRawNames(parser)) |
| 2422 | return XML_ERROR_NO_MEMORY; | 2547 | return XML_ERROR_NO_MEMORY; |
| @@ -2433,7 +2558,7 @@ externalEntityInitProcessor(XML_Parser parser, | |||
| 2433 | enum XML_Error result = initializeEncoding(parser); | 2558 | enum XML_Error result = initializeEncoding(parser); |
| 2434 | if (result != XML_ERROR_NONE) | 2559 | if (result != XML_ERROR_NONE) |
| 2435 | return result; | 2560 | return result; |
| 2436 | processor = externalEntityInitProcessor2; | 2561 | parser->m_processor = externalEntityInitProcessor2; |
| 2437 | return externalEntityInitProcessor2(parser, start, end, endPtr); | 2562 | return externalEntityInitProcessor2(parser, start, end, endPtr); |
| 2438 | } | 2563 | } |
| 2439 | 2564 | ||
| @@ -2444,7 +2569,7 @@ externalEntityInitProcessor2(XML_Parser parser, | |||
| 2444 | const char **endPtr) | 2569 | const char **endPtr) |
| 2445 | { | 2570 | { |
| 2446 | const char *next = start; /* XmlContentTok doesn't always set the last arg */ | 2571 | const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 2447 | int tok = XmlContentTok(encoding, start, end, &next); | 2572 | int tok = XmlContentTok(parser->m_encoding, start, end, &next); |
| 2448 | switch (tok) { | 2573 | switch (tok) { |
| 2449 | case XML_TOK_BOM: | 2574 | case XML_TOK_BOM: |
| 2450 | /* If we are at the end of the buffer, this would cause the next stage, | 2575 | /* If we are at the end of the buffer, this would cause the next stage, |
| @@ -2452,28 +2577,28 @@ externalEntityInitProcessor2(XML_Parser parser, | |||
| 2452 | doContent (by detecting XML_TOK_NONE) without processing any xml text | 2577 | doContent (by detecting XML_TOK_NONE) without processing any xml text |
| 2453 | declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. | 2578 | declaration - causing the error XML_ERROR_MISPLACED_XML_PI in doContent. |
| 2454 | */ | 2579 | */ |
| 2455 | if (next == end && !ps_finalBuffer) { | 2580 | if (next == end && !parser->m_parsingStatus.finalBuffer) { |
| 2456 | *endPtr = next; | 2581 | *endPtr = next; |
| 2457 | return XML_ERROR_NONE; | 2582 | return XML_ERROR_NONE; |
| 2458 | } | 2583 | } |
| 2459 | start = next; | 2584 | start = next; |
| 2460 | break; | 2585 | break; |
| 2461 | case XML_TOK_PARTIAL: | 2586 | case XML_TOK_PARTIAL: |
| 2462 | if (!ps_finalBuffer) { | 2587 | if (!parser->m_parsingStatus.finalBuffer) { |
| 2463 | *endPtr = start; | 2588 | *endPtr = start; |
| 2464 | return XML_ERROR_NONE; | 2589 | return XML_ERROR_NONE; |
| 2465 | } | 2590 | } |
| 2466 | eventPtr = start; | 2591 | parser->m_eventPtr = start; |
| 2467 | return XML_ERROR_UNCLOSED_TOKEN; | 2592 | return XML_ERROR_UNCLOSED_TOKEN; |
| 2468 | case XML_TOK_PARTIAL_CHAR: | 2593 | case XML_TOK_PARTIAL_CHAR: |
| 2469 | if (!ps_finalBuffer) { | 2594 | if (!parser->m_parsingStatus.finalBuffer) { |
| 2470 | *endPtr = start; | 2595 | *endPtr = start; |
| 2471 | return XML_ERROR_NONE; | 2596 | return XML_ERROR_NONE; |
| 2472 | } | 2597 | } |
| 2473 | eventPtr = start; | 2598 | parser->m_eventPtr = start; |
| 2474 | return XML_ERROR_PARTIAL_CHAR; | 2599 | return XML_ERROR_PARTIAL_CHAR; |
| 2475 | } | 2600 | } |
| 2476 | processor = externalEntityInitProcessor3; | 2601 | parser->m_processor = externalEntityInitProcessor3; |
| 2477 | return externalEntityInitProcessor3(parser, start, end, endPtr); | 2602 | return externalEntityInitProcessor3(parser, start, end, endPtr); |
| 2478 | } | 2603 | } |
| 2479 | 2604 | ||
| @@ -2485,9 +2610,9 @@ externalEntityInitProcessor3(XML_Parser parser, | |||
| 2485 | { | 2610 | { |
| 2486 | int tok; | 2611 | int tok; |
| 2487 | const char *next = start; /* XmlContentTok doesn't always set the last arg */ | 2612 | const char *next = start; /* XmlContentTok doesn't always set the last arg */ |
| 2488 | eventPtr = start; | 2613 | parser->m_eventPtr = start; |
| 2489 | tok = XmlContentTok(encoding, start, end, &next); | 2614 | tok = XmlContentTok(parser->m_encoding, start, end, &next); |
| 2490 | eventEndPtr = next; | 2615 | parser->m_eventEndPtr = next; |
| 2491 | 2616 | ||
| 2492 | switch (tok) { | 2617 | switch (tok) { |
| 2493 | case XML_TOK_XML_DECL: | 2618 | case XML_TOK_XML_DECL: |
| @@ -2496,7 +2621,7 @@ externalEntityInitProcessor3(XML_Parser parser, | |||
| 2496 | result = processXmlDecl(parser, 1, start, next); | 2621 | result = processXmlDecl(parser, 1, start, next); |
| 2497 | if (result != XML_ERROR_NONE) | 2622 | if (result != XML_ERROR_NONE) |
| 2498 | return result; | 2623 | return result; |
| 2499 | switch (ps_parsing) { | 2624 | switch (parser->m_parsingStatus.parsing) { |
| 2500 | case XML_SUSPENDED: | 2625 | case XML_SUSPENDED: |
| 2501 | *endPtr = next; | 2626 | *endPtr = next; |
| 2502 | return XML_ERROR_NONE; | 2627 | return XML_ERROR_NONE; |
| @@ -2508,20 +2633,20 @@ externalEntityInitProcessor3(XML_Parser parser, | |||
| 2508 | } | 2633 | } |
| 2509 | break; | 2634 | break; |
| 2510 | case XML_TOK_PARTIAL: | 2635 | case XML_TOK_PARTIAL: |
| 2511 | if (!ps_finalBuffer) { | 2636 | if (!parser->m_parsingStatus.finalBuffer) { |
| 2512 | *endPtr = start; | 2637 | *endPtr = start; |
| 2513 | return XML_ERROR_NONE; | 2638 | return XML_ERROR_NONE; |
| 2514 | } | 2639 | } |
| 2515 | return XML_ERROR_UNCLOSED_TOKEN; | 2640 | return XML_ERROR_UNCLOSED_TOKEN; |
| 2516 | case XML_TOK_PARTIAL_CHAR: | 2641 | case XML_TOK_PARTIAL_CHAR: |
| 2517 | if (!ps_finalBuffer) { | 2642 | if (!parser->m_parsingStatus.finalBuffer) { |
| 2518 | *endPtr = start; | 2643 | *endPtr = start; |
| 2519 | return XML_ERROR_NONE; | 2644 | return XML_ERROR_NONE; |
| 2520 | } | 2645 | } |
| 2521 | return XML_ERROR_PARTIAL_CHAR; | 2646 | return XML_ERROR_PARTIAL_CHAR; |
| 2522 | } | 2647 | } |
| 2523 | processor = externalEntityContentProcessor; | 2648 | parser->m_processor = externalEntityContentProcessor; |
| 2524 | tagLevel = 1; | 2649 | parser->m_tagLevel = 1; |
| 2525 | return externalEntityContentProcessor(parser, start, end, endPtr); | 2650 | return externalEntityContentProcessor(parser, start, end, endPtr); |
| 2526 | } | 2651 | } |
| 2527 | 2652 | ||
| @@ -2531,8 +2656,8 @@ externalEntityContentProcessor(XML_Parser parser, | |||
| 2531 | const char *end, | 2656 | const char *end, |
| 2532 | const char **endPtr) | 2657 | const char **endPtr) |
| 2533 | { | 2658 | { |
| 2534 | enum XML_Error result = doContent(parser, 1, encoding, start, end, | 2659 | enum XML_Error result = doContent(parser, 1, parser->m_encoding, start, end, |
| 2535 | endPtr, (XML_Bool)!ps_finalBuffer); | 2660 | endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 2536 | if (result == XML_ERROR_NONE) { | 2661 | if (result == XML_ERROR_NONE) { |
| 2537 | if (!storeRawNames(parser)) | 2662 | if (!storeRawNames(parser)) |
| 2538 | return XML_ERROR_NO_MEMORY; | 2663 | return XML_ERROR_NO_MEMORY; |
| @@ -2550,17 +2675,17 @@ doContent(XML_Parser parser, | |||
| 2550 | XML_Bool haveMore) | 2675 | XML_Bool haveMore) |
| 2551 | { | 2676 | { |
| 2552 | /* save one level of indirection */ | 2677 | /* save one level of indirection */ |
| 2553 | DTD * const dtd = _dtd; | 2678 | DTD * const dtd = parser->m_dtd; |
| 2554 | 2679 | ||
| 2555 | const char **eventPP; | 2680 | const char **eventPP; |
| 2556 | const char **eventEndPP; | 2681 | const char **eventEndPP; |
| 2557 | if (enc == encoding) { | 2682 | if (enc == parser->m_encoding) { |
| 2558 | eventPP = &eventPtr; | 2683 | eventPP = &parser->m_eventPtr; |
| 2559 | eventEndPP = &eventEndPtr; | 2684 | eventEndPP = &parser->m_eventEndPtr; |
| 2560 | } | 2685 | } |
| 2561 | else { | 2686 | else { |
| 2562 | eventPP = &(openInternalEntities->internalEventPtr); | 2687 | eventPP = &(parser->m_openInternalEntities->internalEventPtr); |
| 2563 | eventEndPP = &(openInternalEntities->internalEventEndPtr); | 2688 | eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); |
| 2564 | } | 2689 | } |
| 2565 | *eventPP = s; | 2690 | *eventPP = s; |
| 2566 | 2691 | ||
| @@ -2575,18 +2700,18 @@ doContent(XML_Parser parser, | |||
| 2575 | return XML_ERROR_NONE; | 2700 | return XML_ERROR_NONE; |
| 2576 | } | 2701 | } |
| 2577 | *eventEndPP = end; | 2702 | *eventEndPP = end; |
| 2578 | if (characterDataHandler) { | 2703 | if (parser->m_characterDataHandler) { |
| 2579 | XML_Char c = 0xA; | 2704 | XML_Char c = 0xA; |
| 2580 | characterDataHandler(handlerArg, &c, 1); | 2705 | parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); |
| 2581 | } | 2706 | } |
| 2582 | else if (defaultHandler) | 2707 | else if (parser->m_defaultHandler) |
| 2583 | reportDefault(parser, enc, s, end); | 2708 | reportDefault(parser, enc, s, end); |
| 2584 | /* We are at the end of the final buffer, should we check for | 2709 | /* We are at the end of the final buffer, should we check for |
| 2585 | XML_SUSPENDED, XML_FINISHED? | 2710 | XML_SUSPENDED, XML_FINISHED? |
| 2586 | */ | 2711 | */ |
| 2587 | if (startTagLevel == 0) | 2712 | if (startTagLevel == 0) |
| 2588 | return XML_ERROR_NO_ELEMENTS; | 2713 | return XML_ERROR_NO_ELEMENTS; |
| 2589 | if (tagLevel != startTagLevel) | 2714 | if (parser->m_tagLevel != startTagLevel) |
| 2590 | return XML_ERROR_ASYNC_ENTITY; | 2715 | return XML_ERROR_ASYNC_ENTITY; |
| 2591 | *nextPtr = end; | 2716 | *nextPtr = end; |
| 2592 | return XML_ERROR_NONE; | 2717 | return XML_ERROR_NONE; |
| @@ -2596,7 +2721,7 @@ doContent(XML_Parser parser, | |||
| 2596 | return XML_ERROR_NONE; | 2721 | return XML_ERROR_NONE; |
| 2597 | } | 2722 | } |
| 2598 | if (startTagLevel > 0) { | 2723 | if (startTagLevel > 0) { |
| 2599 | if (tagLevel != startTagLevel) | 2724 | if (parser->m_tagLevel != startTagLevel) |
| 2600 | return XML_ERROR_ASYNC_ENTITY; | 2725 | return XML_ERROR_ASYNC_ENTITY; |
| 2601 | *nextPtr = s; | 2726 | *nextPtr = s; |
| 2602 | return XML_ERROR_NONE; | 2727 | return XML_ERROR_NONE; |
| @@ -2625,9 +2750,9 @@ doContent(XML_Parser parser, | |||
| 2625 | s + enc->minBytesPerChar, | 2750 | s + enc->minBytesPerChar, |
| 2626 | next - enc->minBytesPerChar); | 2751 | next - enc->minBytesPerChar); |
| 2627 | if (ch) { | 2752 | if (ch) { |
| 2628 | if (characterDataHandler) | 2753 | if (parser->m_characterDataHandler) |
| 2629 | characterDataHandler(handlerArg, &ch, 1); | 2754 | parser->m_characterDataHandler(parser->m_handlerArg, &ch, 1); |
| 2630 | else if (defaultHandler) | 2755 | else if (parser->m_defaultHandler) |
| 2631 | reportDefault(parser, enc, s, next); | 2756 | reportDefault(parser, enc, s, next); |
| 2632 | break; | 2757 | break; |
| 2633 | } | 2758 | } |
| @@ -2649,9 +2774,9 @@ doContent(XML_Parser parser, | |||
| 2649 | return XML_ERROR_ENTITY_DECLARED_IN_PE; | 2774 | return XML_ERROR_ENTITY_DECLARED_IN_PE; |
| 2650 | } | 2775 | } |
| 2651 | else if (!entity) { | 2776 | else if (!entity) { |
| 2652 | if (skippedEntityHandler) | 2777 | if (parser->m_skippedEntityHandler) |
| 2653 | skippedEntityHandler(handlerArg, name, 0); | 2778 | parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); |
| 2654 | else if (defaultHandler) | 2779 | else if (parser->m_defaultHandler) |
| 2655 | reportDefault(parser, enc, s, next); | 2780 | reportDefault(parser, enc, s, next); |
| 2656 | break; | 2781 | break; |
| 2657 | } | 2782 | } |
| @@ -2661,10 +2786,10 @@ doContent(XML_Parser parser, | |||
| 2661 | return XML_ERROR_BINARY_ENTITY_REF; | 2786 | return XML_ERROR_BINARY_ENTITY_REF; |
| 2662 | if (entity->textPtr) { | 2787 | if (entity->textPtr) { |
| 2663 | enum XML_Error result; | 2788 | enum XML_Error result; |
| 2664 | if (!defaultExpandInternalEntities) { | 2789 | if (!parser->m_defaultExpandInternalEntities) { |
| 2665 | if (skippedEntityHandler) | 2790 | if (parser->m_skippedEntityHandler) |
| 2666 | skippedEntityHandler(handlerArg, entity->name, 0); | 2791 | parser->m_skippedEntityHandler(parser->m_handlerArg, entity->name, 0); |
| 2667 | else if (defaultHandler) | 2792 | else if (parser->m_defaultHandler) |
| 2668 | reportDefault(parser, enc, s, next); | 2793 | reportDefault(parser, enc, s, next); |
| 2669 | break; | 2794 | break; |
| 2670 | } | 2795 | } |
| @@ -2672,22 +2797,22 @@ doContent(XML_Parser parser, | |||
| 2672 | if (result != XML_ERROR_NONE) | 2797 | if (result != XML_ERROR_NONE) |
| 2673 | return result; | 2798 | return result; |
| 2674 | } | 2799 | } |
| 2675 | else if (externalEntityRefHandler) { | 2800 | else if (parser->m_externalEntityRefHandler) { |
| 2676 | const XML_Char *context; | 2801 | const XML_Char *context; |
| 2677 | entity->open = XML_TRUE; | 2802 | entity->open = XML_TRUE; |
| 2678 | context = getContext(parser); | 2803 | context = getContext(parser); |
| 2679 | entity->open = XML_FALSE; | 2804 | entity->open = XML_FALSE; |
| 2680 | if (!context) | 2805 | if (!context) |
| 2681 | return XML_ERROR_NO_MEMORY; | 2806 | return XML_ERROR_NO_MEMORY; |
| 2682 | if (!externalEntityRefHandler(externalEntityRefHandlerArg, | 2807 | if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, |
| 2683 | context, | 2808 | context, |
| 2684 | entity->base, | 2809 | entity->base, |
| 2685 | entity->systemId, | 2810 | entity->systemId, |
| 2686 | entity->publicId)) | 2811 | entity->publicId)) |
| 2687 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; | 2812 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
| 2688 | poolDiscard(&tempPool); | 2813 | poolDiscard(&parser->m_tempPool); |
| 2689 | } | 2814 | } |
| 2690 | else if (defaultHandler) | 2815 | else if (parser->m_defaultHandler) |
| 2691 | reportDefault(parser, enc, s, next); | 2816 | reportDefault(parser, enc, s, next); |
| 2692 | break; | 2817 | break; |
| 2693 | } | 2818 | } |
| @@ -2698,29 +2823,29 @@ doContent(XML_Parser parser, | |||
| 2698 | TAG *tag; | 2823 | TAG *tag; |
| 2699 | enum XML_Error result; | 2824 | enum XML_Error result; |
| 2700 | XML_Char *toPtr; | 2825 | XML_Char *toPtr; |
| 2701 | if (freeTagList) { | 2826 | if (parser->m_freeTagList) { |
| 2702 | tag = freeTagList; | 2827 | tag = parser->m_freeTagList; |
| 2703 | freeTagList = freeTagList->parent; | 2828 | parser->m_freeTagList = parser->m_freeTagList->parent; |
| 2704 | } | 2829 | } |
| 2705 | else { | 2830 | else { |
| 2706 | tag = (TAG *)MALLOC(sizeof(TAG)); | 2831 | tag = (TAG *)MALLOC(parser, sizeof(TAG)); |
| 2707 | if (!tag) | 2832 | if (!tag) |
| 2708 | return XML_ERROR_NO_MEMORY; | 2833 | return XML_ERROR_NO_MEMORY; |
| 2709 | tag->buf = (char *)MALLOC(INIT_TAG_BUF_SIZE); | 2834 | tag->buf = (char *)MALLOC(parser, INIT_TAG_BUF_SIZE); |
| 2710 | if (!tag->buf) { | 2835 | if (!tag->buf) { |
| 2711 | FREE(tag); | 2836 | FREE(parser, tag); |
| 2712 | return XML_ERROR_NO_MEMORY; | 2837 | return XML_ERROR_NO_MEMORY; |
| 2713 | } | 2838 | } |
| 2714 | tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; | 2839 | tag->bufEnd = tag->buf + INIT_TAG_BUF_SIZE; |
| 2715 | } | 2840 | } |
| 2716 | tag->bindings = NULL; | 2841 | tag->bindings = NULL; |
| 2717 | tag->parent = tagStack; | 2842 | tag->parent = parser->m_tagStack; |
| 2718 | tagStack = tag; | 2843 | parser->m_tagStack = tag; |
| 2719 | tag->name.localPart = NULL; | 2844 | tag->name.localPart = NULL; |
| 2720 | tag->name.prefix = NULL; | 2845 | tag->name.prefix = NULL; |
| 2721 | tag->rawName = s + enc->minBytesPerChar; | 2846 | tag->rawName = s + enc->minBytesPerChar; |
| 2722 | tag->rawNameLength = XmlNameLength(enc, tag->rawName); | 2847 | tag->rawNameLength = XmlNameLength(enc, tag->rawName); |
| 2723 | ++tagLevel; | 2848 | ++parser->m_tagLevel; |
| 2724 | { | 2849 | { |
| 2725 | const char *rawNameEnd = tag->rawName + tag->rawNameLength; | 2850 | const char *rawNameEnd = tag->rawName + tag->rawNameLength; |
| 2726 | const char *fromPtr = tag->rawName; | 2851 | const char *fromPtr = tag->rawName; |
| @@ -2738,7 +2863,7 @@ doContent(XML_Parser parser, | |||
| 2738 | } | 2863 | } |
| 2739 | bufSize = (int)(tag->bufEnd - tag->buf) << 1; | 2864 | bufSize = (int)(tag->bufEnd - tag->buf) << 1; |
| 2740 | { | 2865 | { |
| 2741 | char *temp = (char *)REALLOC(tag->buf, bufSize); | 2866 | char *temp = (char *)REALLOC(parser, tag->buf, bufSize); |
| 2742 | if (temp == NULL) | 2867 | if (temp == NULL) |
| 2743 | return XML_ERROR_NO_MEMORY; | 2868 | return XML_ERROR_NO_MEMORY; |
| 2744 | tag->buf = temp; | 2869 | tag->buf = temp; |
| @@ -2752,12 +2877,12 @@ doContent(XML_Parser parser, | |||
| 2752 | result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); | 2877 | result = storeAtts(parser, enc, s, &(tag->name), &(tag->bindings)); |
| 2753 | if (result) | 2878 | if (result) |
| 2754 | return result; | 2879 | return result; |
| 2755 | if (startElementHandler) | 2880 | if (parser->m_startElementHandler) |
| 2756 | startElementHandler(handlerArg, tag->name.str, | 2881 | parser->m_startElementHandler(parser->m_handlerArg, tag->name.str, |
| 2757 | (const XML_Char **)atts); | 2882 | (const XML_Char **)parser->m_atts); |
| 2758 | else if (defaultHandler) | 2883 | else if (parser->m_defaultHandler) |
| 2759 | reportDefault(parser, enc, s, next); | 2884 | reportDefault(parser, enc, s, next); |
| 2760 | poolClear(&tempPool); | 2885 | poolClear(&parser->m_tempPool); |
| 2761 | break; | 2886 | break; |
| 2762 | } | 2887 | } |
| 2763 | case XML_TOK_EMPTY_ELEMENT_NO_ATTS: | 2888 | case XML_TOK_EMPTY_ELEMENT_NO_ATTS: |
| @@ -2769,45 +2894,49 @@ doContent(XML_Parser parser, | |||
| 2769 | BINDING *bindings = NULL; | 2894 | BINDING *bindings = NULL; |
| 2770 | XML_Bool noElmHandlers = XML_TRUE; | 2895 | XML_Bool noElmHandlers = XML_TRUE; |
| 2771 | TAG_NAME name; | 2896 | TAG_NAME name; |
| 2772 | name.str = poolStoreString(&tempPool, enc, rawName, | 2897 | name.str = poolStoreString(&parser->m_tempPool, enc, rawName, |
| 2773 | rawName + XmlNameLength(enc, rawName)); | 2898 | rawName + XmlNameLength(enc, rawName)); |
| 2774 | if (!name.str) | 2899 | if (!name.str) |
| 2775 | return XML_ERROR_NO_MEMORY; | 2900 | return XML_ERROR_NO_MEMORY; |
| 2776 | poolFinish(&tempPool); | 2901 | poolFinish(&parser->m_tempPool); |
| 2777 | result = storeAtts(parser, enc, s, &name, &bindings); | 2902 | result = storeAtts(parser, enc, s, &name, &bindings); |
| 2778 | if (result != XML_ERROR_NONE) { | 2903 | if (result != XML_ERROR_NONE) { |
| 2779 | freeBindings(parser, bindings); | 2904 | freeBindings(parser, bindings); |
| 2780 | return result; | 2905 | return result; |
| 2781 | } | 2906 | } |
| 2782 | poolFinish(&tempPool); | 2907 | poolFinish(&parser->m_tempPool); |
| 2783 | if (startElementHandler) { | 2908 | if (parser->m_startElementHandler) { |
| 2784 | startElementHandler(handlerArg, name.str, (const XML_Char **)atts); | 2909 | parser->m_startElementHandler(parser->m_handlerArg, name.str, (const XML_Char **)parser->m_atts); |
| 2785 | noElmHandlers = XML_FALSE; | 2910 | noElmHandlers = XML_FALSE; |
| 2786 | } | 2911 | } |
| 2787 | if (endElementHandler) { | 2912 | if (parser->m_endElementHandler) { |
| 2788 | if (startElementHandler) | 2913 | if (parser->m_startElementHandler) |
| 2789 | *eventPP = *eventEndPP; | 2914 | *eventPP = *eventEndPP; |
| 2790 | endElementHandler(handlerArg, name.str); | 2915 | parser->m_endElementHandler(parser->m_handlerArg, name.str); |
| 2791 | noElmHandlers = XML_FALSE; | 2916 | noElmHandlers = XML_FALSE; |
| 2792 | } | 2917 | } |
| 2793 | if (noElmHandlers && defaultHandler) | 2918 | if (noElmHandlers && parser->m_defaultHandler) |
| 2794 | reportDefault(parser, enc, s, next); | 2919 | reportDefault(parser, enc, s, next); |
| 2795 | poolClear(&tempPool); | 2920 | poolClear(&parser->m_tempPool); |
| 2796 | freeBindings(parser, bindings); | 2921 | freeBindings(parser, bindings); |
| 2797 | } | 2922 | } |
| 2798 | if (tagLevel == 0) | 2923 | if ((parser->m_tagLevel == 0) && (parser->m_parsingStatus.parsing != XML_FINISHED)) { |
| 2799 | return epilogProcessor(parser, next, end, nextPtr); | 2924 | if (parser->m_parsingStatus.parsing == XML_SUSPENDED) |
| 2925 | parser->m_processor = epilogProcessor; | ||
| 2926 | else | ||
| 2927 | return epilogProcessor(parser, next, end, nextPtr); | ||
| 2928 | } | ||
| 2800 | break; | 2929 | break; |
| 2801 | case XML_TOK_END_TAG: | 2930 | case XML_TOK_END_TAG: |
| 2802 | if (tagLevel == startTagLevel) | 2931 | if (parser->m_tagLevel == startTagLevel) |
| 2803 | return XML_ERROR_ASYNC_ENTITY; | 2932 | return XML_ERROR_ASYNC_ENTITY; |
| 2804 | else { | 2933 | else { |
| 2805 | int len; | 2934 | int len; |
| 2806 | const char *rawName; | 2935 | const char *rawName; |
| 2807 | TAG *tag = tagStack; | 2936 | TAG *tag = parser->m_tagStack; |
| 2808 | tagStack = tag->parent; | 2937 | parser->m_tagStack = tag->parent; |
| 2809 | tag->parent = freeTagList; | 2938 | tag->parent = parser->m_freeTagList; |
| 2810 | freeTagList = tag; | 2939 | parser->m_freeTagList = tag; |
| 2811 | rawName = s + enc->minBytesPerChar*2; | 2940 | rawName = s + enc->minBytesPerChar*2; |
| 2812 | len = XmlNameLength(enc, rawName); | 2941 | len = XmlNameLength(enc, rawName); |
| 2813 | if (len != tag->rawNameLength | 2942 | if (len != tag->rawNameLength |
| @@ -2815,13 +2944,13 @@ doContent(XML_Parser parser, | |||
| 2815 | *eventPP = rawName; | 2944 | *eventPP = rawName; |
| 2816 | return XML_ERROR_TAG_MISMATCH; | 2945 | return XML_ERROR_TAG_MISMATCH; |
| 2817 | } | 2946 | } |
| 2818 | --tagLevel; | 2947 | --parser->m_tagLevel; |
| 2819 | if (endElementHandler) { | 2948 | if (parser->m_endElementHandler) { |
| 2820 | const XML_Char *localPart; | 2949 | const XML_Char *localPart; |
| 2821 | const XML_Char *prefix; | 2950 | const XML_Char *prefix; |
| 2822 | XML_Char *uri; | 2951 | XML_Char *uri; |
| 2823 | localPart = tag->name.localPart; | 2952 | localPart = tag->name.localPart; |
| 2824 | if (ns && localPart) { | 2953 | if (parser->m_ns && localPart) { |
| 2825 | /* localPart and prefix may have been overwritten in | 2954 | /* localPart and prefix may have been overwritten in |
| 2826 | tag->name.str, since this points to the binding->uri | 2955 | tag->name.str, since this points to the binding->uri |
| 2827 | buffer which gets re-used; so we have to add them again | 2956 | buffer which gets re-used; so we have to add them again |
| @@ -2830,26 +2959,26 @@ doContent(XML_Parser parser, | |||
| 2830 | /* don't need to check for space - already done in storeAtts() */ | 2959 | /* don't need to check for space - already done in storeAtts() */ |
| 2831 | while (*localPart) *uri++ = *localPart++; | 2960 | while (*localPart) *uri++ = *localPart++; |
| 2832 | prefix = (XML_Char *)tag->name.prefix; | 2961 | prefix = (XML_Char *)tag->name.prefix; |
| 2833 | if (ns_triplets && prefix) { | 2962 | if (parser->m_ns_triplets && prefix) { |
| 2834 | *uri++ = namespaceSeparator; | 2963 | *uri++ = parser->m_namespaceSeparator; |
| 2835 | while (*prefix) *uri++ = *prefix++; | 2964 | while (*prefix) *uri++ = *prefix++; |
| 2836 | } | 2965 | } |
| 2837 | *uri = XML_T('\0'); | 2966 | *uri = XML_T('\0'); |
| 2838 | } | 2967 | } |
| 2839 | endElementHandler(handlerArg, tag->name.str); | 2968 | parser->m_endElementHandler(parser->m_handlerArg, tag->name.str); |
| 2840 | } | 2969 | } |
| 2841 | else if (defaultHandler) | 2970 | else if (parser->m_defaultHandler) |
| 2842 | reportDefault(parser, enc, s, next); | 2971 | reportDefault(parser, enc, s, next); |
| 2843 | while (tag->bindings) { | 2972 | while (tag->bindings) { |
| 2844 | BINDING *b = tag->bindings; | 2973 | BINDING *b = tag->bindings; |
| 2845 | if (endNamespaceDeclHandler) | 2974 | if (parser->m_endNamespaceDeclHandler) |
| 2846 | endNamespaceDeclHandler(handlerArg, b->prefix->name); | 2975 | parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name); |
| 2847 | tag->bindings = tag->bindings->nextTagBinding; | 2976 | tag->bindings = tag->bindings->nextTagBinding; |
| 2848 | b->nextTagBinding = freeBindingList; | 2977 | b->nextTagBinding = parser->m_freeBindingList; |
| 2849 | freeBindingList = b; | 2978 | parser->m_freeBindingList = b; |
| 2850 | b->prefix->binding = b->prevPrefixBinding; | 2979 | b->prefix->binding = b->prevPrefixBinding; |
| 2851 | } | 2980 | } |
| 2852 | if (tagLevel == 0) | 2981 | if (parser->m_tagLevel == 0) |
| 2853 | return epilogProcessor(parser, next, end, nextPtr); | 2982 | return epilogProcessor(parser, next, end, nextPtr); |
| 2854 | } | 2983 | } |
| 2855 | break; | 2984 | break; |
| @@ -2858,30 +2987,30 @@ doContent(XML_Parser parser, | |||
| 2858 | int n = XmlCharRefNumber(enc, s); | 2987 | int n = XmlCharRefNumber(enc, s); |
| 2859 | if (n < 0) | 2988 | if (n < 0) |
| 2860 | return XML_ERROR_BAD_CHAR_REF; | 2989 | return XML_ERROR_BAD_CHAR_REF; |
| 2861 | if (characterDataHandler) { | 2990 | if (parser->m_characterDataHandler) { |
| 2862 | XML_Char buf[XML_ENCODE_MAX]; | 2991 | XML_Char buf[XML_ENCODE_MAX]; |
| 2863 | characterDataHandler(handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); | 2992 | parser->m_characterDataHandler(parser->m_handlerArg, buf, XmlEncode(n, (ICHAR *)buf)); |
| 2864 | } | 2993 | } |
| 2865 | else if (defaultHandler) | 2994 | else if (parser->m_defaultHandler) |
| 2866 | reportDefault(parser, enc, s, next); | 2995 | reportDefault(parser, enc, s, next); |
| 2867 | } | 2996 | } |
| 2868 | break; | 2997 | break; |
| 2869 | case XML_TOK_XML_DECL: | 2998 | case XML_TOK_XML_DECL: |
| 2870 | return XML_ERROR_MISPLACED_XML_PI; | 2999 | return XML_ERROR_MISPLACED_XML_PI; |
| 2871 | case XML_TOK_DATA_NEWLINE: | 3000 | case XML_TOK_DATA_NEWLINE: |
| 2872 | if (characterDataHandler) { | 3001 | if (parser->m_characterDataHandler) { |
| 2873 | XML_Char c = 0xA; | 3002 | XML_Char c = 0xA; |
| 2874 | characterDataHandler(handlerArg, &c, 1); | 3003 | parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); |
| 2875 | } | 3004 | } |
| 2876 | else if (defaultHandler) | 3005 | else if (parser->m_defaultHandler) |
| 2877 | reportDefault(parser, enc, s, next); | 3006 | reportDefault(parser, enc, s, next); |
| 2878 | break; | 3007 | break; |
| 2879 | case XML_TOK_CDATA_SECT_OPEN: | 3008 | case XML_TOK_CDATA_SECT_OPEN: |
| 2880 | { | 3009 | { |
| 2881 | enum XML_Error result; | 3010 | enum XML_Error result; |
| 2882 | if (startCdataSectionHandler) | 3011 | if (parser->m_startCdataSectionHandler) |
| 2883 | startCdataSectionHandler(handlerArg); | 3012 | parser->m_startCdataSectionHandler(parser->m_handlerArg); |
| 2884 | #if 0 | 3013 | /* BEGIN disabled code */ |
| 2885 | /* Suppose you doing a transformation on a document that involves | 3014 | /* Suppose you doing a transformation on a document that involves |
| 2886 | changing only the character data. You set up a defaultHandler | 3015 | changing only the character data. You set up a defaultHandler |
| 2887 | and a characterDataHandler. The defaultHandler simply copies | 3016 | and a characterDataHandler. The defaultHandler simply copies |
| @@ -2894,16 +3023,16 @@ doContent(XML_Parser parser, | |||
| 2894 | However, now we have a start/endCdataSectionHandler, so it seems | 3023 | However, now we have a start/endCdataSectionHandler, so it seems |
| 2895 | easier to let the user deal with this. | 3024 | easier to let the user deal with this. |
| 2896 | */ | 3025 | */ |
| 2897 | else if (characterDataHandler) | 3026 | else if (0 && parser->m_characterDataHandler) |
| 2898 | characterDataHandler(handlerArg, dataBuf, 0); | 3027 | parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 0); |
| 2899 | #endif | 3028 | /* END disabled code */ |
| 2900 | else if (defaultHandler) | 3029 | else if (parser->m_defaultHandler) |
| 2901 | reportDefault(parser, enc, s, next); | 3030 | reportDefault(parser, enc, s, next); |
| 2902 | result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); | 3031 | result = doCdataSection(parser, enc, &next, end, nextPtr, haveMore); |
| 2903 | if (result != XML_ERROR_NONE) | 3032 | if (result != XML_ERROR_NONE) |
| 2904 | return result; | 3033 | return result; |
| 2905 | else if (!next) { | 3034 | else if (!next) { |
| 2906 | processor = cdataSectionProcessor; | 3035 | parser->m_processor = cdataSectionProcessor; |
| 2907 | return result; | 3036 | return result; |
| 2908 | } | 3037 | } |
| 2909 | } | 3038 | } |
| @@ -2913,19 +3042,19 @@ doContent(XML_Parser parser, | |||
| 2913 | *nextPtr = s; | 3042 | *nextPtr = s; |
| 2914 | return XML_ERROR_NONE; | 3043 | return XML_ERROR_NONE; |
| 2915 | } | 3044 | } |
| 2916 | if (characterDataHandler) { | 3045 | if (parser->m_characterDataHandler) { |
| 2917 | if (MUST_CONVERT(enc, s)) { | 3046 | if (MUST_CONVERT(enc, s)) { |
| 2918 | ICHAR *dataPtr = (ICHAR *)dataBuf; | 3047 | ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; |
| 2919 | XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | 3048 | XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); |
| 2920 | characterDataHandler(handlerArg, dataBuf, | 3049 | parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, |
| 2921 | (int)(dataPtr - (ICHAR *)dataBuf)); | 3050 | (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); |
| 2922 | } | 3051 | } |
| 2923 | else | 3052 | else |
| 2924 | characterDataHandler(handlerArg, | 3053 | parser->m_characterDataHandler(parser->m_handlerArg, |
| 2925 | (XML_Char *)s, | 3054 | (XML_Char *)s, |
| 2926 | (int)((XML_Char *)end - (XML_Char *)s)); | 3055 | (int)((XML_Char *)end - (XML_Char *)s)); |
| 2927 | } | 3056 | } |
| 2928 | else if (defaultHandler) | 3057 | else if (parser->m_defaultHandler) |
| 2929 | reportDefault(parser, enc, s, end); | 3058 | reportDefault(parser, enc, s, end); |
| 2930 | /* We are at the end of the final buffer, should we check for | 3059 | /* We are at the end of the final buffer, should we check for |
| 2931 | XML_SUSPENDED, XML_FINISHED? | 3060 | XML_SUSPENDED, XML_FINISHED? |
| @@ -2934,7 +3063,7 @@ doContent(XML_Parser parser, | |||
| 2934 | *eventPP = end; | 3063 | *eventPP = end; |
| 2935 | return XML_ERROR_NO_ELEMENTS; | 3064 | return XML_ERROR_NO_ELEMENTS; |
| 2936 | } | 3065 | } |
| 2937 | if (tagLevel != startTagLevel) { | 3066 | if (parser->m_tagLevel != startTagLevel) { |
| 2938 | *eventPP = end; | 3067 | *eventPP = end; |
| 2939 | return XML_ERROR_ASYNC_ENTITY; | 3068 | return XML_ERROR_ASYNC_ENTITY; |
| 2940 | } | 3069 | } |
| @@ -2942,26 +3071,26 @@ doContent(XML_Parser parser, | |||
| 2942 | return XML_ERROR_NONE; | 3071 | return XML_ERROR_NONE; |
| 2943 | case XML_TOK_DATA_CHARS: | 3072 | case XML_TOK_DATA_CHARS: |
| 2944 | { | 3073 | { |
| 2945 | XML_CharacterDataHandler charDataHandler = characterDataHandler; | 3074 | XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; |
| 2946 | if (charDataHandler) { | 3075 | if (charDataHandler) { |
| 2947 | if (MUST_CONVERT(enc, s)) { | 3076 | if (MUST_CONVERT(enc, s)) { |
| 2948 | for (;;) { | 3077 | for (;;) { |
| 2949 | ICHAR *dataPtr = (ICHAR *)dataBuf; | 3078 | ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; |
| 2950 | const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); | 3079 | const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); |
| 2951 | *eventEndPP = s; | 3080 | *eventEndPP = s; |
| 2952 | charDataHandler(handlerArg, dataBuf, | 3081 | charDataHandler(parser->m_handlerArg, parser->m_dataBuf, |
| 2953 | (int)(dataPtr - (ICHAR *)dataBuf)); | 3082 | (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); |
| 2954 | if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) | 3083 | if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) |
| 2955 | break; | 3084 | break; |
| 2956 | *eventPP = s; | 3085 | *eventPP = s; |
| 2957 | } | 3086 | } |
| 2958 | } | 3087 | } |
| 2959 | else | 3088 | else |
| 2960 | charDataHandler(handlerArg, | 3089 | charDataHandler(parser->m_handlerArg, |
| 2961 | (XML_Char *)s, | 3090 | (XML_Char *)s, |
| 2962 | (int)((XML_Char *)next - (XML_Char *)s)); | 3091 | (int)((XML_Char *)next - (XML_Char *)s)); |
| 2963 | } | 3092 | } |
| 2964 | else if (defaultHandler) | 3093 | else if (parser->m_defaultHandler) |
| 2965 | reportDefault(parser, enc, s, next); | 3094 | reportDefault(parser, enc, s, next); |
| 2966 | } | 3095 | } |
| 2967 | break; | 3096 | break; |
| @@ -2974,12 +3103,20 @@ doContent(XML_Parser parser, | |||
| 2974 | return XML_ERROR_NO_MEMORY; | 3103 | return XML_ERROR_NO_MEMORY; |
| 2975 | break; | 3104 | break; |
| 2976 | default: | 3105 | default: |
| 2977 | if (defaultHandler) | 3106 | /* All of the tokens produced by XmlContentTok() have their own |
| 3107 | * explicit cases, so this default is not strictly necessary. | ||
| 3108 | * However it is a useful safety net, so we retain the code and | ||
| 3109 | * simply exclude it from the coverage tests. | ||
| 3110 | * | ||
| 3111 | * LCOV_EXCL_START | ||
| 3112 | */ | ||
| 3113 | if (parser->m_defaultHandler) | ||
| 2978 | reportDefault(parser, enc, s, next); | 3114 | reportDefault(parser, enc, s, next); |
| 2979 | break; | 3115 | break; |
| 3116 | /* LCOV_EXCL_STOP */ | ||
| 2980 | } | 3117 | } |
| 2981 | *eventPP = s = next; | 3118 | *eventPP = s = next; |
| 2982 | switch (ps_parsing) { | 3119 | switch (parser->m_parsingStatus.parsing) { |
| 2983 | case XML_SUSPENDED: | 3120 | case XML_SUSPENDED: |
| 2984 | *nextPtr = next; | 3121 | *nextPtr = next; |
| 2985 | return XML_ERROR_NONE; | 3122 | return XML_ERROR_NONE; |
| @@ -2992,7 +3129,7 @@ doContent(XML_Parser parser, | |||
| 2992 | } | 3129 | } |
| 2993 | 3130 | ||
| 2994 | /* This function does not call free() on the allocated memory, merely | 3131 | /* This function does not call free() on the allocated memory, merely |
| 2995 | * moving it to the parser's freeBindingList where it can be freed or | 3132 | * moving it to the parser's m_freeBindingList where it can be freed or |
| 2996 | * reused as appropriate. | 3133 | * reused as appropriate. |
| 2997 | */ | 3134 | */ |
| 2998 | static void | 3135 | static void |
| @@ -3001,15 +3138,15 @@ freeBindings(XML_Parser parser, BINDING *bindings) | |||
| 3001 | while (bindings) { | 3138 | while (bindings) { |
| 3002 | BINDING *b = bindings; | 3139 | BINDING *b = bindings; |
| 3003 | 3140 | ||
| 3004 | /* startNamespaceDeclHandler will have been called for this | 3141 | /* m_startNamespaceDeclHandler will have been called for this |
| 3005 | * binding in addBindings(), so call the end handler now. | 3142 | * binding in addBindings(), so call the end handler now. |
| 3006 | */ | 3143 | */ |
| 3007 | if (endNamespaceDeclHandler) | 3144 | if (parser->m_endNamespaceDeclHandler) |
| 3008 | endNamespaceDeclHandler(handlerArg, b->prefix->name); | 3145 | parser->m_endNamespaceDeclHandler(parser->m_handlerArg, b->prefix->name); |
| 3009 | 3146 | ||
| 3010 | bindings = bindings->nextTagBinding; | 3147 | bindings = bindings->nextTagBinding; |
| 3011 | b->nextTagBinding = freeBindingList; | 3148 | b->nextTagBinding = parser->m_freeBindingList; |
| 3012 | freeBindingList = b; | 3149 | parser->m_freeBindingList = b; |
| 3013 | b->prefix->binding = b->prevPrefixBinding; | 3150 | b->prefix->binding = b->prevPrefixBinding; |
| 3014 | } | 3151 | } |
| 3015 | } | 3152 | } |
| @@ -3029,7 +3166,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3029 | const char *attStr, TAG_NAME *tagNamePtr, | 3166 | const char *attStr, TAG_NAME *tagNamePtr, |
| 3030 | BINDING **bindingsPtr) | 3167 | BINDING **bindingsPtr) |
| 3031 | { | 3168 | { |
| 3032 | DTD * const dtd = _dtd; /* save one level of indirection */ | 3169 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 3033 | ELEMENT_TYPE *elementType; | 3170 | ELEMENT_TYPE *elementType; |
| 3034 | int nDefaultAtts; | 3171 | int nDefaultAtts; |
| 3035 | const XML_Char **appAtts; /* the attribute list for the application */ | 3172 | const XML_Char **appAtts; /* the attribute list for the application */ |
| @@ -3052,39 +3189,43 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3052 | sizeof(ELEMENT_TYPE)); | 3189 | sizeof(ELEMENT_TYPE)); |
| 3053 | if (!elementType) | 3190 | if (!elementType) |
| 3054 | return XML_ERROR_NO_MEMORY; | 3191 | return XML_ERROR_NO_MEMORY; |
| 3055 | if (ns && !setElementTypePrefix(parser, elementType)) | 3192 | if (parser->m_ns && !setElementTypePrefix(parser, elementType)) |
| 3056 | return XML_ERROR_NO_MEMORY; | 3193 | return XML_ERROR_NO_MEMORY; |
| 3057 | } | 3194 | } |
| 3058 | nDefaultAtts = elementType->nDefaultAtts; | 3195 | nDefaultAtts = elementType->nDefaultAtts; |
| 3059 | 3196 | ||
| 3060 | /* get the attributes from the tokenizer */ | 3197 | /* get the attributes from the tokenizer */ |
| 3061 | n = XmlGetAttributes(enc, attStr, attsSize, atts); | 3198 | n = XmlGetAttributes(enc, attStr, parser->m_attsSize, parser->m_atts); |
| 3062 | if (n + nDefaultAtts > attsSize) { | 3199 | if (n + nDefaultAtts > parser->m_attsSize) { |
| 3063 | int oldAttsSize = attsSize; | 3200 | int oldAttsSize = parser->m_attsSize; |
| 3064 | ATTRIBUTE *temp; | 3201 | ATTRIBUTE *temp; |
| 3065 | #ifdef XML_ATTR_INFO | 3202 | #ifdef XML_ATTR_INFO |
| 3066 | XML_AttrInfo *temp2; | 3203 | XML_AttrInfo *temp2; |
| 3067 | #endif | 3204 | #endif |
| 3068 | attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; | 3205 | parser->m_attsSize = n + nDefaultAtts + INIT_ATTS_SIZE; |
| 3069 | temp = (ATTRIBUTE *)REALLOC((void *)atts, attsSize * sizeof(ATTRIBUTE)); | 3206 | temp = (ATTRIBUTE *)REALLOC(parser, (void *)parser->m_atts, parser->m_attsSize * sizeof(ATTRIBUTE)); |
| 3070 | if (temp == NULL) | 3207 | if (temp == NULL) { |
| 3208 | parser->m_attsSize = oldAttsSize; | ||
| 3071 | return XML_ERROR_NO_MEMORY; | 3209 | return XML_ERROR_NO_MEMORY; |
| 3072 | atts = temp; | 3210 | } |
| 3211 | parser->m_atts = temp; | ||
| 3073 | #ifdef XML_ATTR_INFO | 3212 | #ifdef XML_ATTR_INFO |
| 3074 | temp2 = (XML_AttrInfo *)REALLOC((void *)attInfo, attsSize * sizeof(XML_AttrInfo)); | 3213 | temp2 = (XML_AttrInfo *)REALLOC(parser, (void *)parser->m_attInfo, parser->m_attsSize * sizeof(XML_AttrInfo)); |
| 3075 | if (temp2 == NULL) | 3214 | if (temp2 == NULL) { |
| 3215 | parser->m_attsSize = oldAttsSize; | ||
| 3076 | return XML_ERROR_NO_MEMORY; | 3216 | return XML_ERROR_NO_MEMORY; |
| 3077 | attInfo = temp2; | 3217 | } |
| 3218 | parser->m_attInfo = temp2; | ||
| 3078 | #endif | 3219 | #endif |
| 3079 | if (n > oldAttsSize) | 3220 | if (n > oldAttsSize) |
| 3080 | XmlGetAttributes(enc, attStr, n, atts); | 3221 | XmlGetAttributes(enc, attStr, n, parser->m_atts); |
| 3081 | } | 3222 | } |
| 3082 | 3223 | ||
| 3083 | appAtts = (const XML_Char **)atts; | 3224 | appAtts = (const XML_Char **)parser->m_atts; |
| 3084 | for (i = 0; i < n; i++) { | 3225 | for (i = 0; i < n; i++) { |
| 3085 | ATTRIBUTE *currAtt = &atts[i]; | 3226 | ATTRIBUTE *currAtt = &parser->m_atts[i]; |
| 3086 | #ifdef XML_ATTR_INFO | 3227 | #ifdef XML_ATTR_INFO |
| 3087 | XML_AttrInfo *currAttInfo = &attInfo[i]; | 3228 | XML_AttrInfo *currAttInfo = &parser->m_attInfo[i]; |
| 3088 | #endif | 3229 | #endif |
| 3089 | /* add the name and value to the attribute list */ | 3230 | /* add the name and value to the attribute list */ |
| 3090 | ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, | 3231 | ATTRIBUTE_ID *attId = getAttributeId(parser, enc, currAtt->name, |
| @@ -3093,25 +3234,25 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3093 | if (!attId) | 3234 | if (!attId) |
| 3094 | return XML_ERROR_NO_MEMORY; | 3235 | return XML_ERROR_NO_MEMORY; |
| 3095 | #ifdef XML_ATTR_INFO | 3236 | #ifdef XML_ATTR_INFO |
| 3096 | currAttInfo->nameStart = parseEndByteIndex - (parseEndPtr - currAtt->name); | 3237 | currAttInfo->nameStart = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->name); |
| 3097 | currAttInfo->nameEnd = currAttInfo->nameStart + | 3238 | currAttInfo->nameEnd = currAttInfo->nameStart + |
| 3098 | XmlNameLength(enc, currAtt->name); | 3239 | XmlNameLength(enc, currAtt->name); |
| 3099 | currAttInfo->valueStart = parseEndByteIndex - | 3240 | currAttInfo->valueStart = parser->m_parseEndByteIndex - |
| 3100 | (parseEndPtr - currAtt->valuePtr); | 3241 | (parser->m_parseEndPtr - currAtt->valuePtr); |
| 3101 | currAttInfo->valueEnd = parseEndByteIndex - (parseEndPtr - currAtt->valueEnd); | 3242 | currAttInfo->valueEnd = parser->m_parseEndByteIndex - (parser->m_parseEndPtr - currAtt->valueEnd); |
| 3102 | #endif | 3243 | #endif |
| 3103 | /* Detect duplicate attributes by their QNames. This does not work when | 3244 | /* Detect duplicate attributes by their QNames. This does not work when |
| 3104 | namespace processing is turned on and different prefixes for the same | 3245 | namespace processing is turned on and different prefixes for the same |
| 3105 | namespace are used. For this case we have a check further down. | 3246 | namespace are used. For this case we have a check further down. |
| 3106 | */ | 3247 | */ |
| 3107 | if ((attId->name)[-1]) { | 3248 | if ((attId->name)[-1]) { |
| 3108 | if (enc == encoding) | 3249 | if (enc == parser->m_encoding) |
| 3109 | eventPtr = atts[i].name; | 3250 | parser->m_eventPtr = parser->m_atts[i].name; |
| 3110 | return XML_ERROR_DUPLICATE_ATTRIBUTE; | 3251 | return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 3111 | } | 3252 | } |
| 3112 | (attId->name)[-1] = 1; | 3253 | (attId->name)[-1] = 1; |
| 3113 | appAtts[attIndex++] = attId->name; | 3254 | appAtts[attIndex++] = attId->name; |
| 3114 | if (!atts[i].normalized) { | 3255 | if (!parser->m_atts[i].normalized) { |
| 3115 | enum XML_Error result; | 3256 | enum XML_Error result; |
| 3116 | XML_Bool isCdata = XML_TRUE; | 3257 | XML_Bool isCdata = XML_TRUE; |
| 3117 | 3258 | ||
| @@ -3128,20 +3269,20 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3128 | 3269 | ||
| 3129 | /* normalize the attribute value */ | 3270 | /* normalize the attribute value */ |
| 3130 | result = storeAttributeValue(parser, enc, isCdata, | 3271 | result = storeAttributeValue(parser, enc, isCdata, |
| 3131 | atts[i].valuePtr, atts[i].valueEnd, | 3272 | parser->m_atts[i].valuePtr, parser->m_atts[i].valueEnd, |
| 3132 | &tempPool); | 3273 | &parser->m_tempPool); |
| 3133 | if (result) | 3274 | if (result) |
| 3134 | return result; | 3275 | return result; |
| 3135 | appAtts[attIndex] = poolStart(&tempPool); | 3276 | appAtts[attIndex] = poolStart(&parser->m_tempPool); |
| 3136 | poolFinish(&tempPool); | 3277 | poolFinish(&parser->m_tempPool); |
| 3137 | } | 3278 | } |
| 3138 | else { | 3279 | else { |
| 3139 | /* the value did not need normalizing */ | 3280 | /* the value did not need normalizing */ |
| 3140 | appAtts[attIndex] = poolStoreString(&tempPool, enc, atts[i].valuePtr, | 3281 | appAtts[attIndex] = poolStoreString(&parser->m_tempPool, enc, parser->m_atts[i].valuePtr, |
| 3141 | atts[i].valueEnd); | 3282 | parser->m_atts[i].valueEnd); |
| 3142 | if (appAtts[attIndex] == 0) | 3283 | if (appAtts[attIndex] == 0) |
| 3143 | return XML_ERROR_NO_MEMORY; | 3284 | return XML_ERROR_NO_MEMORY; |
| 3144 | poolFinish(&tempPool); | 3285 | poolFinish(&parser->m_tempPool); |
| 3145 | } | 3286 | } |
| 3146 | /* handle prefixed attribute names */ | 3287 | /* handle prefixed attribute names */ |
| 3147 | if (attId->prefix) { | 3288 | if (attId->prefix) { |
| @@ -3165,16 +3306,16 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3165 | } | 3306 | } |
| 3166 | 3307 | ||
| 3167 | /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ | 3308 | /* set-up for XML_GetSpecifiedAttributeCount and XML_GetIdAttributeIndex */ |
| 3168 | nSpecifiedAtts = attIndex; | 3309 | parser->m_nSpecifiedAtts = attIndex; |
| 3169 | if (elementType->idAtt && (elementType->idAtt->name)[-1]) { | 3310 | if (elementType->idAtt && (elementType->idAtt->name)[-1]) { |
| 3170 | for (i = 0; i < attIndex; i += 2) | 3311 | for (i = 0; i < attIndex; i += 2) |
| 3171 | if (appAtts[i] == elementType->idAtt->name) { | 3312 | if (appAtts[i] == elementType->idAtt->name) { |
| 3172 | idAttIndex = i; | 3313 | parser->m_idAttIndex = i; |
| 3173 | break; | 3314 | break; |
| 3174 | } | 3315 | } |
| 3175 | } | 3316 | } |
| 3176 | else | 3317 | else |
| 3177 | idAttIndex = -1; | 3318 | parser->m_idAttIndex = -1; |
| 3178 | 3319 | ||
| 3179 | /* do attribute defaulting */ | 3320 | /* do attribute defaulting */ |
| 3180 | for (i = 0; i < nDefaultAtts; i++) { | 3321 | for (i = 0; i < nDefaultAtts; i++) { |
| @@ -3208,29 +3349,33 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3208 | i = 0; | 3349 | i = 0; |
| 3209 | if (nPrefixes) { | 3350 | if (nPrefixes) { |
| 3210 | int j; /* hash table index */ | 3351 | int j; /* hash table index */ |
| 3211 | unsigned long version = nsAttsVersion; | 3352 | unsigned long version = parser->m_nsAttsVersion; |
| 3212 | int nsAttsSize = (int)1 << nsAttsPower; | 3353 | int nsAttsSize = (int)1 << parser->m_nsAttsPower; |
| 3354 | unsigned char oldNsAttsPower = parser->m_nsAttsPower; | ||
| 3213 | /* size of hash table must be at least 2 * (# of prefixed attributes) */ | 3355 | /* size of hash table must be at least 2 * (# of prefixed attributes) */ |
| 3214 | if ((nPrefixes << 1) >> nsAttsPower) { /* true for nsAttsPower = 0 */ | 3356 | if ((nPrefixes << 1) >> parser->m_nsAttsPower) { /* true for m_nsAttsPower = 0 */ |
| 3215 | NS_ATT *temp; | 3357 | NS_ATT *temp; |
| 3216 | /* hash table size must also be a power of 2 and >= 8 */ | 3358 | /* hash table size must also be a power of 2 and >= 8 */ |
| 3217 | while (nPrefixes >> nsAttsPower++); | 3359 | while (nPrefixes >> parser->m_nsAttsPower++); |
| 3218 | if (nsAttsPower < 3) | 3360 | if (parser->m_nsAttsPower < 3) |
| 3219 | nsAttsPower = 3; | 3361 | parser->m_nsAttsPower = 3; |
| 3220 | nsAttsSize = (int)1 << nsAttsPower; | 3362 | nsAttsSize = (int)1 << parser->m_nsAttsPower; |
| 3221 | temp = (NS_ATT *)REALLOC(nsAtts, nsAttsSize * sizeof(NS_ATT)); | 3363 | temp = (NS_ATT *)REALLOC(parser, parser->m_nsAtts, nsAttsSize * sizeof(NS_ATT)); |
| 3222 | if (!temp) | 3364 | if (!temp) { |
| 3365 | /* Restore actual size of memory in m_nsAtts */ | ||
| 3366 | parser->m_nsAttsPower = oldNsAttsPower; | ||
| 3223 | return XML_ERROR_NO_MEMORY; | 3367 | return XML_ERROR_NO_MEMORY; |
| 3224 | nsAtts = temp; | 3368 | } |
| 3225 | version = 0; /* force re-initialization of nsAtts hash table */ | 3369 | parser->m_nsAtts = temp; |
| 3370 | version = 0; /* force re-initialization of m_nsAtts hash table */ | ||
| 3226 | } | 3371 | } |
| 3227 | /* using a version flag saves us from initializing nsAtts every time */ | 3372 | /* using a version flag saves us from initializing m_nsAtts every time */ |
| 3228 | if (!version) { /* initialize version flags when version wraps around */ | 3373 | if (!version) { /* initialize version flags when version wraps around */ |
| 3229 | version = INIT_ATTS_VERSION; | 3374 | version = INIT_ATTS_VERSION; |
| 3230 | for (j = nsAttsSize; j != 0; ) | 3375 | for (j = nsAttsSize; j != 0; ) |
| 3231 | nsAtts[--j].version = version; | 3376 | parser->m_nsAtts[--j].version = version; |
| 3232 | } | 3377 | } |
| 3233 | nsAttsVersion = --version; | 3378 | parser->m_nsAttsVersion = --version; |
| 3234 | 3379 | ||
| 3235 | /* expand prefixed names and check for duplicates */ | 3380 | /* expand prefixed names and check for duplicates */ |
| 3236 | for (; i < attIndex; i += 2) { | 3381 | for (; i < attIndex; i += 2) { |
| @@ -3247,15 +3392,32 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3247 | 3392 | ||
| 3248 | ((XML_Char *)s)[-1] = 0; /* clear flag */ | 3393 | ((XML_Char *)s)[-1] = 0; /* clear flag */ |
| 3249 | id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); | 3394 | id = (ATTRIBUTE_ID *)lookup(parser, &dtd->attributeIds, s, 0); |
| 3250 | if (!id || !id->prefix) | 3395 | if (!id || !id->prefix) { |
| 3251 | return XML_ERROR_NO_MEMORY; | 3396 | /* This code is walking through the appAtts array, dealing |
| 3397 | * with (in this case) a prefixed attribute name. To be in | ||
| 3398 | * the array, the attribute must have already been bound, so | ||
| 3399 | * has to have passed through the hash table lookup once | ||
| 3400 | * already. That implies that an entry for it already | ||
| 3401 | * exists, so the lookup above will return a pointer to | ||
| 3402 | * already allocated memory. There is no opportunaity for | ||
| 3403 | * the allocator to fail, so the condition above cannot be | ||
| 3404 | * fulfilled. | ||
| 3405 | * | ||
| 3406 | * Since it is difficult to be certain that the above | ||
| 3407 | * analysis is complete, we retain the test and merely | ||
| 3408 | * remove the code from coverage tests. | ||
| 3409 | */ | ||
| 3410 | return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */ | ||
| 3411 | } | ||
| 3252 | b = id->prefix->binding; | 3412 | b = id->prefix->binding; |
| 3253 | if (!b) | 3413 | if (!b) { |
| 3254 | return XML_ERROR_UNBOUND_PREFIX; | 3414 | //return XML_ERROR_UNBOUND_PREFIX; |
| 3415 | continue; | ||
| 3416 | } | ||
| 3255 | 3417 | ||
| 3256 | for (j = 0; j < b->uriLen; j++) { | 3418 | for (j = 0; j < b->uriLen; j++) { |
| 3257 | const XML_Char c = b->uri[j]; | 3419 | const XML_Char c = b->uri[j]; |
| 3258 | if (!poolAppendChar(&tempPool, c)) | 3420 | if (!poolAppendChar(&parser->m_tempPool, c)) |
| 3259 | return XML_ERROR_NO_MEMORY; | 3421 | return XML_ERROR_NO_MEMORY; |
| 3260 | } | 3422 | } |
| 3261 | 3423 | ||
| @@ -3267,7 +3429,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3267 | sip24_update(&sip_state, s, keylen(s) * sizeof(XML_Char)); | 3429 | sip24_update(&sip_state, s, keylen(s) * sizeof(XML_Char)); |
| 3268 | 3430 | ||
| 3269 | do { /* copies null terminator */ | 3431 | do { /* copies null terminator */ |
| 3270 | if (!poolAppendChar(&tempPool, *s)) | 3432 | if (!poolAppendChar(&parser->m_tempPool, *s)) |
| 3271 | return XML_ERROR_NO_MEMORY; | 3433 | return XML_ERROR_NO_MEMORY; |
| 3272 | } while (*s++); | 3434 | } while (*s++); |
| 3273 | 3435 | ||
| @@ -3279,40 +3441,40 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3279 | unsigned char step = 0; | 3441 | unsigned char step = 0; |
| 3280 | unsigned long mask = nsAttsSize - 1; | 3442 | unsigned long mask = nsAttsSize - 1; |
| 3281 | j = uriHash & mask; /* index into hash table */ | 3443 | j = uriHash & mask; /* index into hash table */ |
| 3282 | while (nsAtts[j].version == version) { | 3444 | while (parser->m_nsAtts[j].version == version) { |
| 3283 | /* for speed we compare stored hash values first */ | 3445 | /* for speed we compare stored hash values first */ |
| 3284 | if (uriHash == nsAtts[j].hash) { | 3446 | if (uriHash == parser->m_nsAtts[j].hash) { |
| 3285 | const XML_Char *s1 = poolStart(&tempPool); | 3447 | const XML_Char *s1 = poolStart(&parser->m_tempPool); |
| 3286 | const XML_Char *s2 = nsAtts[j].uriName; | 3448 | const XML_Char *s2 = parser->m_nsAtts[j].uriName; |
| 3287 | /* s1 is null terminated, but not s2 */ | 3449 | /* s1 is null terminated, but not s2 */ |
| 3288 | for (; *s1 == *s2 && *s1 != 0; s1++, s2++); | 3450 | for (; *s1 == *s2 && *s1 != 0; s1++, s2++); |
| 3289 | if (*s1 == 0) | 3451 | if (*s1 == 0) |
| 3290 | return XML_ERROR_DUPLICATE_ATTRIBUTE; | 3452 | return XML_ERROR_DUPLICATE_ATTRIBUTE; |
| 3291 | } | 3453 | } |
| 3292 | if (!step) | 3454 | if (!step) |
| 3293 | step = PROBE_STEP(uriHash, mask, nsAttsPower); | 3455 | step = PROBE_STEP(uriHash, mask, parser->m_nsAttsPower); |
| 3294 | j < step ? (j += nsAttsSize - step) : (j -= step); | 3456 | j < step ? (j += nsAttsSize - step) : (j -= step); |
| 3295 | } | 3457 | } |
| 3296 | } | 3458 | } |
| 3297 | 3459 | ||
| 3298 | if (ns_triplets) { /* append namespace separator and prefix */ | 3460 | if (parser->m_ns_triplets) { /* append namespace separator and prefix */ |
| 3299 | tempPool.ptr[-1] = namespaceSeparator; | 3461 | parser->m_tempPool.ptr[-1] = parser->m_namespaceSeparator; |
| 3300 | s = b->prefix->name; | 3462 | s = b->prefix->name; |
| 3301 | do { | 3463 | do { |
| 3302 | if (!poolAppendChar(&tempPool, *s)) | 3464 | if (!poolAppendChar(&parser->m_tempPool, *s)) |
| 3303 | return XML_ERROR_NO_MEMORY; | 3465 | return XML_ERROR_NO_MEMORY; |
| 3304 | } while (*s++); | 3466 | } while (*s++); |
| 3305 | } | 3467 | } |
| 3306 | 3468 | ||
| 3307 | /* store expanded name in attribute list */ | 3469 | /* store expanded name in attribute list */ |
| 3308 | s = poolStart(&tempPool); | 3470 | s = poolStart(&parser->m_tempPool); |
| 3309 | poolFinish(&tempPool); | 3471 | poolFinish(&parser->m_tempPool); |
| 3310 | appAtts[i] = s; | 3472 | appAtts[i] = s; |
| 3311 | 3473 | ||
| 3312 | /* fill empty slot with new version, uriName and hash value */ | 3474 | /* fill empty slot with new version, uriName and hash value */ |
| 3313 | nsAtts[j].version = version; | 3475 | parser->m_nsAtts[j].version = version; |
| 3314 | nsAtts[j].hash = uriHash; | 3476 | parser->m_nsAtts[j].hash = uriHash; |
| 3315 | nsAtts[j].uriName = s; | 3477 | parser->m_nsAtts[j].uriName = s; |
| 3316 | 3478 | ||
| 3317 | if (!--nPrefixes) { | 3479 | if (!--nPrefixes) { |
| 3318 | i += 2; | 3480 | i += 2; |
| @@ -3329,11 +3491,11 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3329 | for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) | 3491 | for (binding = *bindingsPtr; binding; binding = binding->nextTagBinding) |
| 3330 | binding->attId->name[-1] = 0; | 3492 | binding->attId->name[-1] = 0; |
| 3331 | 3493 | ||
| 3332 | if (!ns) | 3494 | if (!parser->m_ns) |
| 3333 | return XML_ERROR_NONE; | 3495 | return XML_ERROR_NONE; |
| 3334 | 3496 | ||
| 3335 | /* expand the element type name */ | 3497 | /* expand the element type name */ |
| 3336 | if (elementType->prefix) { | 3498 | if (elementType->prefix && elementType->prefix->binding) { |
| 3337 | binding = elementType->prefix->binding; | 3499 | binding = elementType->prefix->binding; |
| 3338 | if (!binding) | 3500 | if (!binding) |
| 3339 | return XML_ERROR_UNBOUND_PREFIX; | 3501 | return XML_ERROR_UNBOUND_PREFIX; |
| @@ -3348,7 +3510,7 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3348 | else | 3510 | else |
| 3349 | return XML_ERROR_NONE; | 3511 | return XML_ERROR_NONE; |
| 3350 | prefixLen = 0; | 3512 | prefixLen = 0; |
| 3351 | if (ns_triplets && binding->prefix->name) { | 3513 | if (parser->m_ns_triplets && binding->prefix->name) { |
| 3352 | for (; binding->prefix->name[prefixLen++];) | 3514 | for (; binding->prefix->name[prefixLen++];) |
| 3353 | ; /* prefixLen includes null terminator */ | 3515 | ; /* prefixLen includes null terminator */ |
| 3354 | } | 3516 | } |
| @@ -3361,24 +3523,24 @@ storeAtts(XML_Parser parser, const ENCODING *enc, | |||
| 3361 | n = i + binding->uriLen + prefixLen; | 3523 | n = i + binding->uriLen + prefixLen; |
| 3362 | if (n > binding->uriAlloc) { | 3524 | if (n > binding->uriAlloc) { |
| 3363 | TAG *p; | 3525 | TAG *p; |
| 3364 | uri = (XML_Char *)MALLOC((n + EXPAND_SPARE) * sizeof(XML_Char)); | 3526 | uri = (XML_Char *)MALLOC(parser, (n + EXPAND_SPARE) * sizeof(XML_Char)); |
| 3365 | if (!uri) | 3527 | if (!uri) |
| 3366 | return XML_ERROR_NO_MEMORY; | 3528 | return XML_ERROR_NO_MEMORY; |
| 3367 | binding->uriAlloc = n + EXPAND_SPARE; | 3529 | binding->uriAlloc = n + EXPAND_SPARE; |
| 3368 | memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); | 3530 | memcpy(uri, binding->uri, binding->uriLen * sizeof(XML_Char)); |
| 3369 | for (p = tagStack; p; p = p->parent) | 3531 | for (p = parser->m_tagStack; p; p = p->parent) |
| 3370 | if (p->name.str == binding->uri) | 3532 | if (p->name.str == binding->uri) |
| 3371 | p->name.str = uri; | 3533 | p->name.str = uri; |
| 3372 | FREE(binding->uri); | 3534 | FREE(parser, binding->uri); |
| 3373 | binding->uri = uri; | 3535 | binding->uri = uri; |
| 3374 | } | 3536 | } |
| 3375 | /* if namespaceSeparator != '\0' then uri includes it already */ | 3537 | /* if m_namespaceSeparator != '\0' then uri includes it already */ |
| 3376 | uri = binding->uri + binding->uriLen; | 3538 | uri = binding->uri + binding->uriLen; |
| 3377 | memcpy(uri, localPart, i * sizeof(XML_Char)); | 3539 | memcpy(uri, localPart, i * sizeof(XML_Char)); |
| 3378 | /* we always have a namespace separator between localPart and prefix */ | 3540 | /* we always have a namespace separator between localPart and prefix */ |
| 3379 | if (prefixLen) { | 3541 | if (prefixLen) { |
| 3380 | uri += i - 1; | 3542 | uri += i - 1; |
| 3381 | *uri = namespaceSeparator; /* replace null terminator */ | 3543 | *uri = parser->m_namespaceSeparator; /* replace null terminator */ |
| 3382 | memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); | 3544 | memcpy(uri + 1, binding->prefix->name, prefixLen * sizeof(XML_Char)); |
| 3383 | } | 3545 | } |
| 3384 | tagNamePtr->str = binding->uri; | 3546 | tagNamePtr->str = binding->uri; |
| @@ -3429,10 +3591,10 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, | |||
| 3429 | && prefix->name[2] == XML_T(ASCII_l)) { | 3591 | && prefix->name[2] == XML_T(ASCII_l)) { |
| 3430 | 3592 | ||
| 3431 | /* Not allowed to bind xmlns */ | 3593 | /* Not allowed to bind xmlns */ |
| 3432 | if (prefix->name[3] == XML_T(ASCII_n) | 3594 | /*if (prefix->name[3] == XML_T(ASCII_n) |
| 3433 | && prefix->name[4] == XML_T(ASCII_s) | 3595 | && prefix->name[4] == XML_T(ASCII_s) |
| 3434 | && prefix->name[5] == XML_T('\0')) | 3596 | && prefix->name[5] == XML_T('\0')) |
| 3435 | return XML_ERROR_RESERVED_PREFIX_XMLNS; | 3597 | return XML_ERROR_RESERVED_PREFIX_XMLNS;*/ |
| 3436 | 3598 | ||
| 3437 | if (prefix->name[3] == XML_T('\0')) | 3599 | if (prefix->name[3] == XML_T('\0')) |
| 3438 | mustBeXML = XML_TRUE; | 3600 | mustBeXML = XML_TRUE; |
| @@ -3449,55 +3611,55 @@ addBinding(XML_Parser parser, PREFIX *prefix, const ATTRIBUTE_ID *attId, | |||
| 3449 | isXML = isXML && len == xmlLen; | 3611 | isXML = isXML && len == xmlLen; |
| 3450 | isXMLNS = isXMLNS && len == xmlnsLen; | 3612 | isXMLNS = isXMLNS && len == xmlnsLen; |
| 3451 | 3613 | ||
| 3452 | if (mustBeXML != isXML) | 3614 | /*if (mustBeXML != isXML) |
| 3453 | return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML | 3615 | return mustBeXML ? XML_ERROR_RESERVED_PREFIX_XML |
| 3454 | : XML_ERROR_RESERVED_NAMESPACE_URI; | 3616 | : XML_ERROR_RESERVED_NAMESPACE_URI;*/ |
| 3455 | 3617 | ||
| 3456 | if (isXMLNS) | 3618 | /*if (isXMLNS) |
| 3457 | return XML_ERROR_RESERVED_NAMESPACE_URI; | 3619 | return XML_ERROR_RESERVED_NAMESPACE_URI;*/ |
| 3458 | 3620 | ||
| 3459 | if (namespaceSeparator) | 3621 | if (parser->m_namespaceSeparator) |
| 3460 | len++; | 3622 | len++; |
| 3461 | if (freeBindingList) { | 3623 | if (parser->m_freeBindingList) { |
| 3462 | b = freeBindingList; | 3624 | b = parser->m_freeBindingList; |
| 3463 | if (len > b->uriAlloc) { | 3625 | if (len > b->uriAlloc) { |
| 3464 | XML_Char *temp = (XML_Char *)REALLOC(b->uri, | 3626 | XML_Char *temp = (XML_Char *)REALLOC(parser, b->uri, |
| 3465 | sizeof(XML_Char) * (len + EXPAND_SPARE)); | 3627 | sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 3466 | if (temp == NULL) | 3628 | if (temp == NULL) |
| 3467 | return XML_ERROR_NO_MEMORY; | 3629 | return XML_ERROR_NO_MEMORY; |
| 3468 | b->uri = temp; | 3630 | b->uri = temp; |
| 3469 | b->uriAlloc = len + EXPAND_SPARE; | 3631 | b->uriAlloc = len + EXPAND_SPARE; |
| 3470 | } | 3632 | } |
| 3471 | freeBindingList = b->nextTagBinding; | 3633 | parser->m_freeBindingList = b->nextTagBinding; |
| 3472 | } | 3634 | } |
| 3473 | else { | 3635 | else { |
| 3474 | b = (BINDING *)MALLOC(sizeof(BINDING)); | 3636 | b = (BINDING *)MALLOC(parser, sizeof(BINDING)); |
| 3475 | if (!b) | 3637 | if (!b) |
| 3476 | return XML_ERROR_NO_MEMORY; | 3638 | return XML_ERROR_NO_MEMORY; |
| 3477 | b->uri = (XML_Char *)MALLOC(sizeof(XML_Char) * (len + EXPAND_SPARE)); | 3639 | b->uri = (XML_Char *)MALLOC(parser, sizeof(XML_Char) * (len + EXPAND_SPARE)); |
| 3478 | if (!b->uri) { | 3640 | if (!b->uri) { |
| 3479 | FREE(b); | 3641 | FREE(parser, b); |
| 3480 | return XML_ERROR_NO_MEMORY; | 3642 | return XML_ERROR_NO_MEMORY; |
| 3481 | } | 3643 | } |
| 3482 | b->uriAlloc = len + EXPAND_SPARE; | 3644 | b->uriAlloc = len + EXPAND_SPARE; |
| 3483 | } | 3645 | } |
| 3484 | b->uriLen = len; | 3646 | b->uriLen = len; |
| 3485 | memcpy(b->uri, uri, len * sizeof(XML_Char)); | 3647 | memcpy(b->uri, uri, len * sizeof(XML_Char)); |
| 3486 | if (namespaceSeparator) | 3648 | if (parser->m_namespaceSeparator) |
| 3487 | b->uri[len - 1] = namespaceSeparator; | 3649 | b->uri[len - 1] = parser->m_namespaceSeparator; |
| 3488 | b->prefix = prefix; | 3650 | b->prefix = prefix; |
| 3489 | b->attId = attId; | 3651 | b->attId = attId; |
| 3490 | b->prevPrefixBinding = prefix->binding; | 3652 | b->prevPrefixBinding = prefix->binding; |
| 3491 | /* NULL binding when default namespace undeclared */ | 3653 | /* NULL binding when default namespace undeclared */ |
| 3492 | if (*uri == XML_T('\0') && prefix == &_dtd->defaultPrefix) | 3654 | if (*uri == XML_T('\0') && prefix == &parser->m_dtd->defaultPrefix) |
| 3493 | prefix->binding = NULL; | 3655 | prefix->binding = NULL; |
| 3494 | else | 3656 | else |
| 3495 | prefix->binding = b; | 3657 | prefix->binding = b; |
| 3496 | b->nextTagBinding = *bindingsPtr; | 3658 | b->nextTagBinding = *bindingsPtr; |
| 3497 | *bindingsPtr = b; | 3659 | *bindingsPtr = b; |
| 3498 | /* if attId == NULL then we are not starting a namespace scope */ | 3660 | /* if attId == NULL then we are not starting a namespace scope */ |
| 3499 | if (attId && startNamespaceDeclHandler) | 3661 | if (attId && parser->m_startNamespaceDeclHandler) |
| 3500 | startNamespaceDeclHandler(handlerArg, prefix->name, | 3662 | parser->m_startNamespaceDeclHandler(parser->m_handlerArg, prefix->name, |
| 3501 | prefix->binding ? uri : 0); | 3663 | prefix->binding ? uri : 0); |
| 3502 | return XML_ERROR_NONE; | 3664 | return XML_ERROR_NONE; |
| 3503 | } | 3665 | } |
| @@ -3511,17 +3673,17 @@ cdataSectionProcessor(XML_Parser parser, | |||
| 3511 | const char *end, | 3673 | const char *end, |
| 3512 | const char **endPtr) | 3674 | const char **endPtr) |
| 3513 | { | 3675 | { |
| 3514 | enum XML_Error result = doCdataSection(parser, encoding, &start, end, | 3676 | enum XML_Error result = doCdataSection(parser, parser->m_encoding, &start, end, |
| 3515 | endPtr, (XML_Bool)!ps_finalBuffer); | 3677 | endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 3516 | if (result != XML_ERROR_NONE) | 3678 | if (result != XML_ERROR_NONE) |
| 3517 | return result; | 3679 | return result; |
| 3518 | if (start) { | 3680 | if (start) { |
| 3519 | if (parentParser) { /* we are parsing an external entity */ | 3681 | if (parser->m_parentParser) { /* we are parsing an external entity */ |
| 3520 | processor = externalEntityContentProcessor; | 3682 | parser->m_processor = externalEntityContentProcessor; |
| 3521 | return externalEntityContentProcessor(parser, start, end, endPtr); | 3683 | return externalEntityContentProcessor(parser, start, end, endPtr); |
| 3522 | } | 3684 | } |
| 3523 | else { | 3685 | else { |
| 3524 | processor = contentProcessor; | 3686 | parser->m_processor = contentProcessor; |
| 3525 | return contentProcessor(parser, start, end, endPtr); | 3687 | return contentProcessor(parser, start, end, endPtr); |
| 3526 | } | 3688 | } |
| 3527 | } | 3689 | } |
| @@ -3542,14 +3704,14 @@ doCdataSection(XML_Parser parser, | |||
| 3542 | const char *s = *startPtr; | 3704 | const char *s = *startPtr; |
| 3543 | const char **eventPP; | 3705 | const char **eventPP; |
| 3544 | const char **eventEndPP; | 3706 | const char **eventEndPP; |
| 3545 | if (enc == encoding) { | 3707 | if (enc == parser->m_encoding) { |
| 3546 | eventPP = &eventPtr; | 3708 | eventPP = &parser->m_eventPtr; |
| 3547 | *eventPP = s; | 3709 | *eventPP = s; |
| 3548 | eventEndPP = &eventEndPtr; | 3710 | eventEndPP = &parser->m_eventEndPtr; |
| 3549 | } | 3711 | } |
| 3550 | else { | 3712 | else { |
| 3551 | eventPP = &(openInternalEntities->internalEventPtr); | 3713 | eventPP = &(parser->m_openInternalEntities->internalEventPtr); |
| 3552 | eventEndPP = &(openInternalEntities->internalEventEndPtr); | 3714 | eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); |
| 3553 | } | 3715 | } |
| 3554 | *eventPP = s; | 3716 | *eventPP = s; |
| 3555 | *startPtr = NULL; | 3717 | *startPtr = NULL; |
| @@ -3560,51 +3722,51 @@ doCdataSection(XML_Parser parser, | |||
| 3560 | *eventEndPP = next; | 3722 | *eventEndPP = next; |
| 3561 | switch (tok) { | 3723 | switch (tok) { |
| 3562 | case XML_TOK_CDATA_SECT_CLOSE: | 3724 | case XML_TOK_CDATA_SECT_CLOSE: |
| 3563 | if (endCdataSectionHandler) | 3725 | if (parser->m_endCdataSectionHandler) |
| 3564 | endCdataSectionHandler(handlerArg); | 3726 | parser->m_endCdataSectionHandler(parser->m_handlerArg); |
| 3565 | #if 0 | 3727 | /* BEGIN disabled code */ |
| 3566 | /* see comment under XML_TOK_CDATA_SECT_OPEN */ | 3728 | /* see comment under XML_TOK_CDATA_SECT_OPEN */ |
| 3567 | else if (characterDataHandler) | 3729 | else if (0 && parser->m_characterDataHandler) |
| 3568 | characterDataHandler(handlerArg, dataBuf, 0); | 3730 | parser->m_characterDataHandler(parser->m_handlerArg, parser->m_dataBuf, 0); |
| 3569 | #endif | 3731 | /* END disabled code */ |
| 3570 | else if (defaultHandler) | 3732 | else if (parser->m_defaultHandler) |
| 3571 | reportDefault(parser, enc, s, next); | 3733 | reportDefault(parser, enc, s, next); |
| 3572 | *startPtr = next; | 3734 | *startPtr = next; |
| 3573 | *nextPtr = next; | 3735 | *nextPtr = next; |
| 3574 | if (ps_parsing == XML_FINISHED) | 3736 | if (parser->m_parsingStatus.parsing == XML_FINISHED) |
| 3575 | return XML_ERROR_ABORTED; | 3737 | return XML_ERROR_ABORTED; |
| 3576 | else | 3738 | else |
| 3577 | return XML_ERROR_NONE; | 3739 | return XML_ERROR_NONE; |
| 3578 | case XML_TOK_DATA_NEWLINE: | 3740 | case XML_TOK_DATA_NEWLINE: |
| 3579 | if (characterDataHandler) { | 3741 | if (parser->m_characterDataHandler) { |
| 3580 | XML_Char c = 0xA; | 3742 | XML_Char c = 0xA; |
| 3581 | characterDataHandler(handlerArg, &c, 1); | 3743 | parser->m_characterDataHandler(parser->m_handlerArg, &c, 1); |
| 3582 | } | 3744 | } |
| 3583 | else if (defaultHandler) | 3745 | else if (parser->m_defaultHandler) |
| 3584 | reportDefault(parser, enc, s, next); | 3746 | reportDefault(parser, enc, s, next); |
| 3585 | break; | 3747 | break; |
| 3586 | case XML_TOK_DATA_CHARS: | 3748 | case XML_TOK_DATA_CHARS: |
| 3587 | { | 3749 | { |
| 3588 | XML_CharacterDataHandler charDataHandler = characterDataHandler; | 3750 | XML_CharacterDataHandler charDataHandler = parser->m_characterDataHandler; |
| 3589 | if (charDataHandler) { | 3751 | if (charDataHandler) { |
| 3590 | if (MUST_CONVERT(enc, s)) { | 3752 | if (MUST_CONVERT(enc, s)) { |
| 3591 | for (;;) { | 3753 | for (;;) { |
| 3592 | ICHAR *dataPtr = (ICHAR *)dataBuf; | 3754 | ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; |
| 3593 | const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)dataBufEnd); | 3755 | const enum XML_Convert_Result convert_res = XmlConvert(enc, &s, next, &dataPtr, (ICHAR *)parser->m_dataBufEnd); |
| 3594 | *eventEndPP = next; | 3756 | *eventEndPP = next; |
| 3595 | charDataHandler(handlerArg, dataBuf, | 3757 | charDataHandler(parser->m_handlerArg, parser->m_dataBuf, |
| 3596 | (int)(dataPtr - (ICHAR *)dataBuf)); | 3758 | (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); |
| 3597 | if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) | 3759 | if ((convert_res == XML_CONVERT_COMPLETED) || (convert_res == XML_CONVERT_INPUT_INCOMPLETE)) |
| 3598 | break; | 3760 | break; |
| 3599 | *eventPP = s; | 3761 | *eventPP = s; |
| 3600 | } | 3762 | } |
| 3601 | } | 3763 | } |
| 3602 | else | 3764 | else |
| 3603 | charDataHandler(handlerArg, | 3765 | charDataHandler(parser->m_handlerArg, |
| 3604 | (XML_Char *)s, | 3766 | (XML_Char *)s, |
| 3605 | (int)((XML_Char *)next - (XML_Char *)s)); | 3767 | (int)((XML_Char *)next - (XML_Char *)s)); |
| 3606 | } | 3768 | } |
| 3607 | else if (defaultHandler) | 3769 | else if (parser->m_defaultHandler) |
| 3608 | reportDefault(parser, enc, s, next); | 3770 | reportDefault(parser, enc, s, next); |
| 3609 | } | 3771 | } |
| 3610 | break; | 3772 | break; |
| @@ -3625,12 +3787,20 @@ doCdataSection(XML_Parser parser, | |||
| 3625 | } | 3787 | } |
| 3626 | return XML_ERROR_UNCLOSED_CDATA_SECTION; | 3788 | return XML_ERROR_UNCLOSED_CDATA_SECTION; |
| 3627 | default: | 3789 | default: |
| 3790 | /* Every token returned by XmlCdataSectionTok() has its own | ||
| 3791 | * explicit case, so this default case will never be executed. | ||
| 3792 | * We retain it as a safety net and exclude it from the coverage | ||
| 3793 | * statistics. | ||
| 3794 | * | ||
| 3795 | * LCOV_EXCL_START | ||
| 3796 | */ | ||
| 3628 | *eventPP = next; | 3797 | *eventPP = next; |
| 3629 | return XML_ERROR_UNEXPECTED_STATE; | 3798 | return XML_ERROR_UNEXPECTED_STATE; |
| 3799 | /* LCOV_EXCL_STOP */ | ||
| 3630 | } | 3800 | } |
| 3631 | 3801 | ||
| 3632 | *eventPP = s = next; | 3802 | *eventPP = s = next; |
| 3633 | switch (ps_parsing) { | 3803 | switch (parser->m_parsingStatus.parsing) { |
| 3634 | case XML_SUSPENDED: | 3804 | case XML_SUSPENDED: |
| 3635 | *nextPtr = next; | 3805 | *nextPtr = next; |
| 3636 | return XML_ERROR_NONE; | 3806 | return XML_ERROR_NONE; |
| @@ -3653,12 +3823,12 @@ ignoreSectionProcessor(XML_Parser parser, | |||
| 3653 | const char *end, | 3823 | const char *end, |
| 3654 | const char **endPtr) | 3824 | const char **endPtr) |
| 3655 | { | 3825 | { |
| 3656 | enum XML_Error result = doIgnoreSection(parser, encoding, &start, end, | 3826 | enum XML_Error result = doIgnoreSection(parser, parser->m_encoding, &start, end, |
| 3657 | endPtr, (XML_Bool)!ps_finalBuffer); | 3827 | endPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 3658 | if (result != XML_ERROR_NONE) | 3828 | if (result != XML_ERROR_NONE) |
| 3659 | return result; | 3829 | return result; |
| 3660 | if (start) { | 3830 | if (start) { |
| 3661 | processor = prologProcessor; | 3831 | parser->m_processor = prologProcessor; |
| 3662 | return prologProcessor(parser, start, end, endPtr); | 3832 | return prologProcessor(parser, start, end, endPtr); |
| 3663 | } | 3833 | } |
| 3664 | return result; | 3834 | return result; |
| @@ -3680,14 +3850,26 @@ doIgnoreSection(XML_Parser parser, | |||
| 3680 | const char *s = *startPtr; | 3850 | const char *s = *startPtr; |
| 3681 | const char **eventPP; | 3851 | const char **eventPP; |
| 3682 | const char **eventEndPP; | 3852 | const char **eventEndPP; |
| 3683 | if (enc == encoding) { | 3853 | if (enc == parser->m_encoding) { |
| 3684 | eventPP = &eventPtr; | 3854 | eventPP = &parser->m_eventPtr; |
| 3685 | *eventPP = s; | 3855 | *eventPP = s; |
| 3686 | eventEndPP = &eventEndPtr; | 3856 | eventEndPP = &parser->m_eventEndPtr; |
| 3687 | } | 3857 | } |
| 3688 | else { | 3858 | else { |
| 3689 | eventPP = &(openInternalEntities->internalEventPtr); | 3859 | /* It's not entirely clear, but it seems the following two lines |
| 3690 | eventEndPP = &(openInternalEntities->internalEventEndPtr); | 3860 | * of code cannot be executed. The only occasions on which 'enc' |
| 3861 | * is not 'encoding' are when this function is called | ||
| 3862 | * from the internal entity processing, and IGNORE sections are an | ||
| 3863 | * error in internal entities. | ||
| 3864 | * | ||
| 3865 | * Since it really isn't clear that this is true, we keep the code | ||
| 3866 | * and just remove it from our coverage tests. | ||
| 3867 | * | ||
| 3868 | * LCOV_EXCL_START | ||
| 3869 | */ | ||
| 3870 | eventPP = &(parser->m_openInternalEntities->internalEventPtr); | ||
| 3871 | eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); | ||
| 3872 | /* LCOV_EXCL_STOP */ | ||
| 3691 | } | 3873 | } |
| 3692 | *eventPP = s; | 3874 | *eventPP = s; |
| 3693 | *startPtr = NULL; | 3875 | *startPtr = NULL; |
| @@ -3695,11 +3877,11 @@ doIgnoreSection(XML_Parser parser, | |||
| 3695 | *eventEndPP = next; | 3877 | *eventEndPP = next; |
| 3696 | switch (tok) { | 3878 | switch (tok) { |
| 3697 | case XML_TOK_IGNORE_SECT: | 3879 | case XML_TOK_IGNORE_SECT: |
| 3698 | if (defaultHandler) | 3880 | if (parser->m_defaultHandler) |
| 3699 | reportDefault(parser, enc, s, next); | 3881 | reportDefault(parser, enc, s, next); |
| 3700 | *startPtr = next; | 3882 | *startPtr = next; |
| 3701 | *nextPtr = next; | 3883 | *nextPtr = next; |
| 3702 | if (ps_parsing == XML_FINISHED) | 3884 | if (parser->m_parsingStatus.parsing == XML_FINISHED) |
| 3703 | return XML_ERROR_ABORTED; | 3885 | return XML_ERROR_ABORTED; |
| 3704 | else | 3886 | else |
| 3705 | return XML_ERROR_NONE; | 3887 | return XML_ERROR_NONE; |
| @@ -3720,8 +3902,16 @@ doIgnoreSection(XML_Parser parser, | |||
| 3720 | } | 3902 | } |
| 3721 | return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ | 3903 | return XML_ERROR_SYNTAX; /* XML_ERROR_UNCLOSED_IGNORE_SECTION */ |
| 3722 | default: | 3904 | default: |
| 3905 | /* All of the tokens that XmlIgnoreSectionTok() returns have | ||
| 3906 | * explicit cases to handle them, so this default case is never | ||
| 3907 | * executed. We keep it as a safety net anyway, and remove it | ||
| 3908 | * from our test coverage statistics. | ||
| 3909 | * | ||
| 3910 | * LCOV_EXCL_START | ||
| 3911 | */ | ||
| 3723 | *eventPP = next; | 3912 | *eventPP = next; |
| 3724 | return XML_ERROR_UNEXPECTED_STATE; | 3913 | return XML_ERROR_UNEXPECTED_STATE; |
| 3914 | /* LCOV_EXCL_STOP */ | ||
| 3725 | } | 3915 | } |
| 3726 | /* not reached */ | 3916 | /* not reached */ |
| 3727 | } | 3917 | } |
| @@ -3734,27 +3924,28 @@ initializeEncoding(XML_Parser parser) | |||
| 3734 | const char *s; | 3924 | const char *s; |
| 3735 | #ifdef XML_UNICODE | 3925 | #ifdef XML_UNICODE |
| 3736 | char encodingBuf[128]; | 3926 | char encodingBuf[128]; |
| 3737 | if (!protocolEncodingName) | 3927 | /* See comments abount `protoclEncodingName` in parserInit() */ |
| 3928 | if (!parser->m_protocolEncodingName) | ||
| 3738 | s = NULL; | 3929 | s = NULL; |
| 3739 | else { | 3930 | else { |
| 3740 | int i; | 3931 | int i; |
| 3741 | for (i = 0; protocolEncodingName[i]; i++) { | 3932 | for (i = 0; parser->m_protocolEncodingName[i]; i++) { |
| 3742 | if (i == sizeof(encodingBuf) - 1 | 3933 | if (i == sizeof(encodingBuf) - 1 |
| 3743 | || (protocolEncodingName[i] & ~0x7f) != 0) { | 3934 | || (parser->m_protocolEncodingName[i] & ~0x7f) != 0) { |
| 3744 | encodingBuf[0] = '\0'; | 3935 | encodingBuf[0] = '\0'; |
| 3745 | break; | 3936 | break; |
| 3746 | } | 3937 | } |
| 3747 | encodingBuf[i] = (char)protocolEncodingName[i]; | 3938 | encodingBuf[i] = (char)parser->m_protocolEncodingName[i]; |
| 3748 | } | 3939 | } |
| 3749 | encodingBuf[i] = '\0'; | 3940 | encodingBuf[i] = '\0'; |
| 3750 | s = encodingBuf; | 3941 | s = encodingBuf; |
| 3751 | } | 3942 | } |
| 3752 | #else | 3943 | #else |
| 3753 | s = protocolEncodingName; | 3944 | s = parser->m_protocolEncodingName; |
| 3754 | #endif | 3945 | #endif |
| 3755 | if ((ns ? XmlInitEncodingNS : XmlInitEncoding)(&initEncoding, &encoding, s)) | 3946 | if ((parser->m_ns ? XmlInitEncodingNS : XmlInitEncoding)(&parser->m_initEncoding, &parser->m_encoding, s)) |
| 3756 | return XML_ERROR_NONE; | 3947 | return XML_ERROR_NONE; |
| 3757 | return handleUnknownEncoding(parser, protocolEncodingName); | 3948 | return handleUnknownEncoding(parser, parser->m_protocolEncodingName); |
| 3758 | } | 3949 | } |
| 3759 | 3950 | ||
| 3760 | static enum XML_Error | 3951 | static enum XML_Error |
| @@ -3768,13 +3959,13 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, | |||
| 3768 | const char *versionend; | 3959 | const char *versionend; |
| 3769 | const XML_Char *storedversion = NULL; | 3960 | const XML_Char *storedversion = NULL; |
| 3770 | int standalone = -1; | 3961 | int standalone = -1; |
| 3771 | if (!(ns | 3962 | if (!(parser->m_ns |
| 3772 | ? XmlParseXmlDeclNS | 3963 | ? XmlParseXmlDeclNS |
| 3773 | : XmlParseXmlDecl)(isGeneralTextEntity, | 3964 | : XmlParseXmlDecl)(isGeneralTextEntity, |
| 3774 | encoding, | 3965 | parser->m_encoding, |
| 3775 | s, | 3966 | s, |
| 3776 | next, | 3967 | next, |
| 3777 | &eventPtr, | 3968 | &parser->m_eventPtr, |
| 3778 | &version, | 3969 | &version, |
| 3779 | &versionend, | 3970 | &versionend, |
| 3780 | &encodingName, | 3971 | &encodingName, |
| @@ -3786,62 +3977,69 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, | |||
| 3786 | return XML_ERROR_XML_DECL; | 3977 | return XML_ERROR_XML_DECL; |
| 3787 | } | 3978 | } |
| 3788 | if (!isGeneralTextEntity && standalone == 1) { | 3979 | if (!isGeneralTextEntity && standalone == 1) { |
| 3789 | _dtd->standalone = XML_TRUE; | 3980 | parser->m_dtd->standalone = XML_TRUE; |
| 3790 | #ifdef XML_DTD | 3981 | #ifdef XML_DTD |
| 3791 | if (paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) | 3982 | if (parser->m_paramEntityParsing == XML_PARAM_ENTITY_PARSING_UNLESS_STANDALONE) |
| 3792 | paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; | 3983 | parser->m_paramEntityParsing = XML_PARAM_ENTITY_PARSING_NEVER; |
| 3793 | #endif /* XML_DTD */ | 3984 | #endif /* XML_DTD */ |
| 3794 | } | 3985 | } |
| 3795 | if (xmlDeclHandler) { | 3986 | if (parser->m_xmlDeclHandler) { |
| 3796 | if (encodingName != NULL) { | 3987 | if (encodingName != NULL) { |
| 3797 | storedEncName = poolStoreString(&temp2Pool, | 3988 | storedEncName = poolStoreString(&parser->m_temp2Pool, |
| 3798 | encoding, | 3989 | parser->m_encoding, |
| 3799 | encodingName, | 3990 | encodingName, |
| 3800 | encodingName | 3991 | encodingName |
| 3801 | + XmlNameLength(encoding, encodingName)); | 3992 | + XmlNameLength(parser->m_encoding, encodingName)); |
| 3802 | if (!storedEncName) | 3993 | if (!storedEncName) |
| 3803 | return XML_ERROR_NO_MEMORY; | 3994 | return XML_ERROR_NO_MEMORY; |
| 3804 | poolFinish(&temp2Pool); | 3995 | poolFinish(&parser->m_temp2Pool); |
| 3805 | } | 3996 | } |
| 3806 | if (version) { | 3997 | if (version) { |
| 3807 | storedversion = poolStoreString(&temp2Pool, | 3998 | storedversion = poolStoreString(&parser->m_temp2Pool, |
| 3808 | encoding, | 3999 | parser->m_encoding, |
| 3809 | version, | 4000 | version, |
| 3810 | versionend - encoding->minBytesPerChar); | 4001 | versionend - parser->m_encoding->minBytesPerChar); |
| 3811 | if (!storedversion) | 4002 | if (!storedversion) |
| 3812 | return XML_ERROR_NO_MEMORY; | 4003 | return XML_ERROR_NO_MEMORY; |
| 3813 | } | 4004 | } |
| 3814 | xmlDeclHandler(handlerArg, storedversion, storedEncName, standalone); | 4005 | parser->m_xmlDeclHandler(parser->m_handlerArg, storedversion, storedEncName, standalone); |
| 3815 | } | 4006 | } |
| 3816 | else if (defaultHandler) | 4007 | else if (parser->m_defaultHandler) |
| 3817 | reportDefault(parser, encoding, s, next); | 4008 | reportDefault(parser, parser->m_encoding, s, next); |
| 3818 | if (protocolEncodingName == NULL) { | 4009 | if (parser->m_protocolEncodingName == NULL) { |
| 3819 | if (newEncoding) { | 4010 | if (newEncoding) { |
| 3820 | if (newEncoding->minBytesPerChar != encoding->minBytesPerChar) { | 4011 | /* Check that the specified encoding does not conflict with what |
| 3821 | eventPtr = encodingName; | 4012 | * the parser has already deduced. Do we have the same number |
| 4013 | * of bytes in the smallest representation of a character? If | ||
| 4014 | * this is UTF-16, is it the same endianness? | ||
| 4015 | */ | ||
| 4016 | if (newEncoding->minBytesPerChar != parser->m_encoding->minBytesPerChar | ||
| 4017 | || (newEncoding->minBytesPerChar == 2 && | ||
| 4018 | newEncoding != parser->m_encoding)) { | ||
| 4019 | parser->m_eventPtr = encodingName; | ||
| 3822 | return XML_ERROR_INCORRECT_ENCODING; | 4020 | return XML_ERROR_INCORRECT_ENCODING; |
| 3823 | } | 4021 | } |
| 3824 | encoding = newEncoding; | 4022 | parser->m_encoding = newEncoding; |
| 3825 | } | 4023 | } |
| 3826 | else if (encodingName) { | 4024 | else if (encodingName) { |
| 3827 | enum XML_Error result; | 4025 | enum XML_Error result; |
| 3828 | if (!storedEncName) { | 4026 | if (!storedEncName) { |
| 3829 | storedEncName = poolStoreString( | 4027 | storedEncName = poolStoreString( |
| 3830 | &temp2Pool, encoding, encodingName, | 4028 | &parser->m_temp2Pool, parser->m_encoding, encodingName, |
| 3831 | encodingName + XmlNameLength(encoding, encodingName)); | 4029 | encodingName + XmlNameLength(parser->m_encoding, encodingName)); |
| 3832 | if (!storedEncName) | 4030 | if (!storedEncName) |
| 3833 | return XML_ERROR_NO_MEMORY; | 4031 | return XML_ERROR_NO_MEMORY; |
| 3834 | } | 4032 | } |
| 3835 | result = handleUnknownEncoding(parser, storedEncName); | 4033 | result = handleUnknownEncoding(parser, storedEncName); |
| 3836 | poolClear(&temp2Pool); | 4034 | poolClear(&parser->m_temp2Pool); |
| 3837 | if (result == XML_ERROR_UNKNOWN_ENCODING) | 4035 | if (result == XML_ERROR_UNKNOWN_ENCODING) |
| 3838 | eventPtr = encodingName; | 4036 | parser->m_eventPtr = encodingName; |
| 3839 | return result; | 4037 | return result; |
| 3840 | } | 4038 | } |
| 3841 | } | 4039 | } |
| 3842 | 4040 | ||
| 3843 | if (storedEncName || storedversion) | 4041 | if (storedEncName || storedversion) |
| 3844 | poolClear(&temp2Pool); | 4042 | poolClear(&parser->m_temp2Pool); |
| 3845 | 4043 | ||
| 3846 | return XML_ERROR_NONE; | 4044 | return XML_ERROR_NONE; |
| 3847 | } | 4045 | } |
| @@ -3849,7 +4047,7 @@ processXmlDecl(XML_Parser parser, int isGeneralTextEntity, | |||
| 3849 | static enum XML_Error | 4047 | static enum XML_Error |
| 3850 | handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | 4048 | handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) |
| 3851 | { | 4049 | { |
| 3852 | if (unknownEncodingHandler) { | 4050 | if (parser->m_unknownEncodingHandler) { |
| 3853 | XML_Encoding info; | 4051 | XML_Encoding info; |
| 3854 | int i; | 4052 | int i; |
| 3855 | for (i = 0; i < 256; i++) | 4053 | for (i = 0; i < 256; i++) |
| @@ -3857,25 +4055,25 @@ handleUnknownEncoding(XML_Parser parser, const XML_Char *encodingName) | |||
| 3857 | info.convert = NULL; | 4055 | info.convert = NULL; |
| 3858 | info.data = NULL; | 4056 | info.data = NULL; |
| 3859 | info.release = NULL; | 4057 | info.release = NULL; |
| 3860 | if (unknownEncodingHandler(unknownEncodingHandlerData, encodingName, | 4058 | if (parser->m_unknownEncodingHandler(parser->m_unknownEncodingHandlerData, encodingName, |
| 3861 | &info)) { | 4059 | &info)) { |
| 3862 | ENCODING *enc; | 4060 | ENCODING *enc; |
| 3863 | unknownEncodingMem = MALLOC(XmlSizeOfUnknownEncoding()); | 4061 | parser->m_unknownEncodingMem = MALLOC(parser, XmlSizeOfUnknownEncoding()); |
| 3864 | if (!unknownEncodingMem) { | 4062 | if (!parser->m_unknownEncodingMem) { |
| 3865 | if (info.release) | 4063 | if (info.release) |
| 3866 | info.release(info.data); | 4064 | info.release(info.data); |
| 3867 | return XML_ERROR_NO_MEMORY; | 4065 | return XML_ERROR_NO_MEMORY; |
| 3868 | } | 4066 | } |
| 3869 | enc = (ns | 4067 | enc = (parser->m_ns |
| 3870 | ? XmlInitUnknownEncodingNS | 4068 | ? XmlInitUnknownEncodingNS |
| 3871 | : XmlInitUnknownEncoding)(unknownEncodingMem, | 4069 | : XmlInitUnknownEncoding)(parser->m_unknownEncodingMem, |
| 3872 | info.map, | 4070 | info.map, |
| 3873 | info.convert, | 4071 | info.convert, |
| 3874 | info.data); | 4072 | info.data); |
| 3875 | if (enc) { | 4073 | if (enc) { |
| 3876 | unknownEncodingData = info.data; | 4074 | parser->m_unknownEncodingData = info.data; |
| 3877 | unknownEncodingRelease = info.release; | 4075 | parser->m_unknownEncodingRelease = info.release; |
| 3878 | encoding = enc; | 4076 | parser->m_encoding = enc; |
| 3879 | return XML_ERROR_NONE; | 4077 | return XML_ERROR_NONE; |
| 3880 | } | 4078 | } |
| 3881 | } | 4079 | } |
| @@ -3894,7 +4092,7 @@ prologInitProcessor(XML_Parser parser, | |||
| 3894 | enum XML_Error result = initializeEncoding(parser); | 4092 | enum XML_Error result = initializeEncoding(parser); |
| 3895 | if (result != XML_ERROR_NONE) | 4093 | if (result != XML_ERROR_NONE) |
| 3896 | return result; | 4094 | return result; |
| 3897 | processor = prologProcessor; | 4095 | parser->m_processor = prologProcessor; |
| 3898 | return prologProcessor(parser, s, end, nextPtr); | 4096 | return prologProcessor(parser, s, end, nextPtr); |
| 3899 | } | 4097 | } |
| 3900 | 4098 | ||
| @@ -3912,14 +4110,14 @@ externalParEntInitProcessor(XML_Parser parser, | |||
| 3912 | 4110 | ||
| 3913 | /* we know now that XML_Parse(Buffer) has been called, | 4111 | /* we know now that XML_Parse(Buffer) has been called, |
| 3914 | so we consider the external parameter entity read */ | 4112 | so we consider the external parameter entity read */ |
| 3915 | _dtd->paramEntityRead = XML_TRUE; | 4113 | parser->m_dtd->paramEntityRead = XML_TRUE; |
| 3916 | 4114 | ||
| 3917 | if (prologState.inEntityValue) { | 4115 | if (parser->m_prologState.inEntityValue) { |
| 3918 | processor = entityValueInitProcessor; | 4116 | parser->m_processor = entityValueInitProcessor; |
| 3919 | return entityValueInitProcessor(parser, s, end, nextPtr); | 4117 | return entityValueInitProcessor(parser, s, end, nextPtr); |
| 3920 | } | 4118 | } |
| 3921 | else { | 4119 | else { |
| 3922 | processor = externalParEntProcessor; | 4120 | parser->m_processor = externalParEntProcessor; |
| 3923 | return externalParEntProcessor(parser, s, end, nextPtr); | 4121 | return externalParEntProcessor(parser, s, end, nextPtr); |
| 3924 | } | 4122 | } |
| 3925 | } | 4123 | } |
| @@ -3933,13 +4131,13 @@ entityValueInitProcessor(XML_Parser parser, | |||
| 3933 | int tok; | 4131 | int tok; |
| 3934 | const char *start = s; | 4132 | const char *start = s; |
| 3935 | const char *next = start; | 4133 | const char *next = start; |
| 3936 | eventPtr = start; | 4134 | parser->m_eventPtr = start; |
| 3937 | 4135 | ||
| 3938 | for (;;) { | 4136 | for (;;) { |
| 3939 | tok = XmlPrologTok(encoding, start, end, &next); | 4137 | tok = XmlPrologTok(parser->m_encoding, start, end, &next); |
| 3940 | eventEndPtr = next; | 4138 | parser->m_eventEndPtr = next; |
| 3941 | if (tok <= 0) { | 4139 | if (tok <= 0) { |
| 3942 | if (!ps_finalBuffer && tok != XML_TOK_INVALID) { | 4140 | if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { |
| 3943 | *nextPtr = s; | 4141 | *nextPtr = s; |
| 3944 | return XML_ERROR_NONE; | 4142 | return XML_ERROR_NONE; |
| 3945 | } | 4143 | } |
| @@ -3955,24 +4153,23 @@ entityValueInitProcessor(XML_Parser parser, | |||
| 3955 | break; | 4153 | break; |
| 3956 | } | 4154 | } |
| 3957 | /* found end of entity value - can store it now */ | 4155 | /* found end of entity value - can store it now */ |
| 3958 | return storeEntityValue(parser, encoding, s, end); | 4156 | return storeEntityValue(parser, parser->m_encoding, s, end); |
| 3959 | } | 4157 | } |
| 3960 | else if (tok == XML_TOK_XML_DECL) { | 4158 | else if (tok == XML_TOK_XML_DECL) { |
| 3961 | enum XML_Error result; | 4159 | enum XML_Error result; |
| 3962 | result = processXmlDecl(parser, 0, start, next); | 4160 | result = processXmlDecl(parser, 0, start, next); |
| 3963 | if (result != XML_ERROR_NONE) | 4161 | if (result != XML_ERROR_NONE) |
| 3964 | return result; | 4162 | return result; |
| 3965 | switch (ps_parsing) { | 4163 | /* At this point, m_parsingStatus.parsing cannot be XML_SUSPENDED. For that |
| 3966 | case XML_SUSPENDED: | 4164 | * to happen, a parameter entity parsing handler must have |
| 3967 | *nextPtr = next; | 4165 | * attempted to suspend the parser, which fails and raises an |
| 3968 | return XML_ERROR_NONE; | 4166 | * error. The parser can be aborted, but can't be suspended. |
| 3969 | case XML_FINISHED: | 4167 | */ |
| 4168 | if (parser->m_parsingStatus.parsing == XML_FINISHED) | ||
| 3970 | return XML_ERROR_ABORTED; | 4169 | return XML_ERROR_ABORTED; |
| 3971 | default: | 4170 | *nextPtr = next; |
| 3972 | *nextPtr = next; | ||
| 3973 | } | ||
| 3974 | /* stop scanning for text declaration - we found one */ | 4171 | /* stop scanning for text declaration - we found one */ |
| 3975 | processor = entityValueProcessor; | 4172 | parser->m_processor = entityValueProcessor; |
| 3976 | return entityValueProcessor(parser, next, end, nextPtr); | 4173 | return entityValueProcessor(parser, next, end, nextPtr); |
| 3977 | } | 4174 | } |
| 3978 | /* If we are at the end of the buffer, this would cause XmlPrologTok to | 4175 | /* If we are at the end of the buffer, this would cause XmlPrologTok to |
| @@ -3982,7 +4179,7 @@ entityValueInitProcessor(XML_Parser parser, | |||
| 3982 | then, when this routine is entered the next time, XmlPrologTok will | 4179 | then, when this routine is entered the next time, XmlPrologTok will |
| 3983 | return XML_TOK_INVALID, since the BOM is still in the buffer | 4180 | return XML_TOK_INVALID, since the BOM is still in the buffer |
| 3984 | */ | 4181 | */ |
| 3985 | else if (tok == XML_TOK_BOM && next == end && !ps_finalBuffer) { | 4182 | else if (tok == XML_TOK_BOM && next == end && !parser->m_parsingStatus.finalBuffer) { |
| 3986 | *nextPtr = next; | 4183 | *nextPtr = next; |
| 3987 | return XML_ERROR_NONE; | 4184 | return XML_ERROR_NONE; |
| 3988 | } | 4185 | } |
| @@ -3995,7 +4192,7 @@ entityValueInitProcessor(XML_Parser parser, | |||
| 3995 | return XML_ERROR_SYNTAX; | 4192 | return XML_ERROR_SYNTAX; |
| 3996 | } | 4193 | } |
| 3997 | start = next; | 4194 | start = next; |
| 3998 | eventPtr = start; | 4195 | parser->m_eventPtr = start; |
| 3999 | } | 4196 | } |
| 4000 | } | 4197 | } |
| 4001 | 4198 | ||
| @@ -4008,9 +4205,9 @@ externalParEntProcessor(XML_Parser parser, | |||
| 4008 | const char *next = s; | 4205 | const char *next = s; |
| 4009 | int tok; | 4206 | int tok; |
| 4010 | 4207 | ||
| 4011 | tok = XmlPrologTok(encoding, s, end, &next); | 4208 | tok = XmlPrologTok(parser->m_encoding, s, end, &next); |
| 4012 | if (tok <= 0) { | 4209 | if (tok <= 0) { |
| 4013 | if (!ps_finalBuffer && tok != XML_TOK_INVALID) { | 4210 | if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { |
| 4014 | *nextPtr = s; | 4211 | *nextPtr = s; |
| 4015 | return XML_ERROR_NONE; | 4212 | return XML_ERROR_NONE; |
| 4016 | } | 4213 | } |
| @@ -4032,12 +4229,12 @@ externalParEntProcessor(XML_Parser parser, | |||
| 4032 | */ | 4229 | */ |
| 4033 | else if (tok == XML_TOK_BOM) { | 4230 | else if (tok == XML_TOK_BOM) { |
| 4034 | s = next; | 4231 | s = next; |
| 4035 | tok = XmlPrologTok(encoding, s, end, &next); | 4232 | tok = XmlPrologTok(parser->m_encoding, s, end, &next); |
| 4036 | } | 4233 | } |
| 4037 | 4234 | ||
| 4038 | processor = prologProcessor; | 4235 | parser->m_processor = prologProcessor; |
| 4039 | return doProlog(parser, encoding, s, end, tok, next, | 4236 | return doProlog(parser, parser->m_encoding, s, end, tok, next, |
| 4040 | nextPtr, (XML_Bool)!ps_finalBuffer); | 4237 | nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 4041 | } | 4238 | } |
| 4042 | 4239 | ||
| 4043 | static enum XML_Error PTRCALL | 4240 | static enum XML_Error PTRCALL |
| @@ -4048,13 +4245,13 @@ entityValueProcessor(XML_Parser parser, | |||
| 4048 | { | 4245 | { |
| 4049 | const char *start = s; | 4246 | const char *start = s; |
| 4050 | const char *next = s; | 4247 | const char *next = s; |
| 4051 | const ENCODING *enc = encoding; | 4248 | const ENCODING *enc = parser->m_encoding; |
| 4052 | int tok; | 4249 | int tok; |
| 4053 | 4250 | ||
| 4054 | for (;;) { | 4251 | for (;;) { |
| 4055 | tok = XmlPrologTok(enc, start, end, &next); | 4252 | tok = XmlPrologTok(enc, start, end, &next); |
| 4056 | if (tok <= 0) { | 4253 | if (tok <= 0) { |
| 4057 | if (!ps_finalBuffer && tok != XML_TOK_INVALID) { | 4254 | if (!parser->m_parsingStatus.finalBuffer && tok != XML_TOK_INVALID) { |
| 4058 | *nextPtr = s; | 4255 | *nextPtr = s; |
| 4059 | return XML_ERROR_NONE; | 4256 | return XML_ERROR_NONE; |
| 4060 | } | 4257 | } |
| @@ -4085,9 +4282,9 @@ prologProcessor(XML_Parser parser, | |||
| 4085 | const char **nextPtr) | 4282 | const char **nextPtr) |
| 4086 | { | 4283 | { |
| 4087 | const char *next = s; | 4284 | const char *next = s; |
| 4088 | int tok = XmlPrologTok(encoding, s, end, &next); | 4285 | int tok = XmlPrologTok(parser->m_encoding, s, end, &next); |
| 4089 | return doProlog(parser, encoding, s, end, tok, next, | 4286 | return doProlog(parser, parser->m_encoding, s, end, tok, next, |
| 4090 | nextPtr, (XML_Bool)!ps_finalBuffer); | 4287 | nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 4091 | } | 4288 | } |
| 4092 | 4289 | ||
| 4093 | static enum XML_Error | 4290 | static enum XML_Error |
| @@ -4124,19 +4321,19 @@ doProlog(XML_Parser parser, | |||
| 4124 | static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; | 4321 | static const XML_Char enumValueStart[] = { ASCII_LPAREN, '\0' }; |
| 4125 | 4322 | ||
| 4126 | /* save one level of indirection */ | 4323 | /* save one level of indirection */ |
| 4127 | DTD * const dtd = _dtd; | 4324 | DTD * const dtd = parser->m_dtd; |
| 4128 | 4325 | ||
| 4129 | const char **eventPP; | 4326 | const char **eventPP; |
| 4130 | const char **eventEndPP; | 4327 | const char **eventEndPP; |
| 4131 | enum XML_Content_Quant quant; | 4328 | enum XML_Content_Quant quant; |
| 4132 | 4329 | ||
| 4133 | if (enc == encoding) { | 4330 | if (enc == parser->m_encoding) { |
| 4134 | eventPP = &eventPtr; | 4331 | eventPP = &parser->m_eventPtr; |
| 4135 | eventEndPP = &eventEndPtr; | 4332 | eventEndPP = &parser->m_eventEndPtr; |
| 4136 | } | 4333 | } |
| 4137 | else { | 4334 | else { |
| 4138 | eventPP = &(openInternalEntities->internalEventPtr); | 4335 | eventPP = &(parser->m_openInternalEntities->internalEventPtr); |
| 4139 | eventEndPP = &(openInternalEntities->internalEventEndPtr); | 4336 | eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); |
| 4140 | } | 4337 | } |
| 4141 | 4338 | ||
| 4142 | for (;;) { | 4339 | for (;;) { |
| @@ -4163,7 +4360,7 @@ doProlog(XML_Parser parser, | |||
| 4163 | case XML_TOK_NONE: | 4360 | case XML_TOK_NONE: |
| 4164 | #ifdef XML_DTD | 4361 | #ifdef XML_DTD |
| 4165 | /* for internal PE NOT referenced between declarations */ | 4362 | /* for internal PE NOT referenced between declarations */ |
| 4166 | if (enc != encoding && !openInternalEntities->betweenDecl) { | 4363 | if (enc != parser->m_encoding && !parser->m_openInternalEntities->betweenDecl) { |
| 4167 | *nextPtr = s; | 4364 | *nextPtr = s; |
| 4168 | return XML_ERROR_NONE; | 4365 | return XML_ERROR_NONE; |
| 4169 | } | 4366 | } |
| @@ -4171,8 +4368,8 @@ doProlog(XML_Parser parser, | |||
| 4171 | complete markup, not only for external PEs, but also for | 4368 | complete markup, not only for external PEs, but also for |
| 4172 | internal PEs if the reference occurs between declarations. | 4369 | internal PEs if the reference occurs between declarations. |
| 4173 | */ | 4370 | */ |
| 4174 | if (isParamEntity || enc != encoding) { | 4371 | if (parser->m_isParamEntity || enc != parser->m_encoding) { |
| 4175 | if (XmlTokenRole(&prologState, XML_TOK_NONE, end, end, enc) | 4372 | if (XmlTokenRole(&parser->m_prologState, XML_TOK_NONE, end, end, enc) |
| 4176 | == XML_ROLE_ERROR) | 4373 | == XML_ROLE_ERROR) |
| 4177 | return XML_ERROR_INCOMPLETE_PE; | 4374 | return XML_ERROR_INCOMPLETE_PE; |
| 4178 | *nextPtr = s; | 4375 | *nextPtr = s; |
| @@ -4186,34 +4383,34 @@ doProlog(XML_Parser parser, | |||
| 4186 | break; | 4383 | break; |
| 4187 | } | 4384 | } |
| 4188 | } | 4385 | } |
| 4189 | role = XmlTokenRole(&prologState, tok, s, next, enc); | 4386 | role = XmlTokenRole(&parser->m_prologState, tok, s, next, enc); |
| 4190 | switch (role) { | 4387 | switch (role) { |
| 4191 | case XML_ROLE_XML_DECL: | 4388 | case XML_ROLE_XML_DECL: |
| 4192 | { | 4389 | { |
| 4193 | enum XML_Error result = processXmlDecl(parser, 0, s, next); | 4390 | enum XML_Error result = processXmlDecl(parser, 0, s, next); |
| 4194 | if (result != XML_ERROR_NONE) | 4391 | if (result != XML_ERROR_NONE) |
| 4195 | return result; | 4392 | return result; |
| 4196 | enc = encoding; | 4393 | enc = parser->m_encoding; |
| 4197 | handleDefault = XML_FALSE; | 4394 | handleDefault = XML_FALSE; |
| 4198 | } | 4395 | } |
| 4199 | break; | 4396 | break; |
| 4200 | case XML_ROLE_DOCTYPE_NAME: | 4397 | case XML_ROLE_DOCTYPE_NAME: |
| 4201 | if (startDoctypeDeclHandler) { | 4398 | if (parser->m_startDoctypeDeclHandler) { |
| 4202 | doctypeName = poolStoreString(&tempPool, enc, s, next); | 4399 | parser->m_doctypeName = poolStoreString(&parser->m_tempPool, enc, s, next); |
| 4203 | if (!doctypeName) | 4400 | if (!parser->m_doctypeName) |
| 4204 | return XML_ERROR_NO_MEMORY; | 4401 | return XML_ERROR_NO_MEMORY; |
| 4205 | poolFinish(&tempPool); | 4402 | poolFinish(&parser->m_tempPool); |
| 4206 | doctypePubid = NULL; | 4403 | parser->m_doctypePubid = NULL; |
| 4207 | handleDefault = XML_FALSE; | 4404 | handleDefault = XML_FALSE; |
| 4208 | } | 4405 | } |
| 4209 | doctypeSysid = NULL; /* always initialize to NULL */ | 4406 | parser->m_doctypeSysid = NULL; /* always initialize to NULL */ |
| 4210 | break; | 4407 | break; |
| 4211 | case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: | 4408 | case XML_ROLE_DOCTYPE_INTERNAL_SUBSET: |
| 4212 | if (startDoctypeDeclHandler) { | 4409 | if (parser->m_startDoctypeDeclHandler) { |
| 4213 | startDoctypeDeclHandler(handlerArg, doctypeName, doctypeSysid, | 4410 | parser->m_startDoctypeDeclHandler(parser->m_handlerArg, parser->m_doctypeName, parser->m_doctypeSysid, |
| 4214 | doctypePubid, 1); | 4411 | parser->m_doctypePubid, 1); |
| 4215 | doctypeName = NULL; | 4412 | parser->m_doctypeName = NULL; |
| 4216 | poolClear(&tempPool); | 4413 | poolClear(&parser->m_tempPool); |
| 4217 | handleDefault = XML_FALSE; | 4414 | handleDefault = XML_FALSE; |
| 4218 | } | 4415 | } |
| 4219 | break; | 4416 | break; |
| @@ -4223,34 +4420,34 @@ doProlog(XML_Parser parser, | |||
| 4223 | enum XML_Error result = processXmlDecl(parser, 1, s, next); | 4420 | enum XML_Error result = processXmlDecl(parser, 1, s, next); |
| 4224 | if (result != XML_ERROR_NONE) | 4421 | if (result != XML_ERROR_NONE) |
| 4225 | return result; | 4422 | return result; |
| 4226 | enc = encoding; | 4423 | enc = parser->m_encoding; |
| 4227 | handleDefault = XML_FALSE; | 4424 | handleDefault = XML_FALSE; |
| 4228 | } | 4425 | } |
| 4229 | break; | 4426 | break; |
| 4230 | #endif /* XML_DTD */ | 4427 | #endif /* XML_DTD */ |
| 4231 | case XML_ROLE_DOCTYPE_PUBLIC_ID: | 4428 | case XML_ROLE_DOCTYPE_PUBLIC_ID: |
| 4232 | #ifdef XML_DTD | 4429 | #ifdef XML_DTD |
| 4233 | useForeignDTD = XML_FALSE; | 4430 | parser->m_useForeignDTD = XML_FALSE; |
| 4234 | declEntity = (ENTITY *)lookup(parser, | 4431 | parser->m_declEntity = (ENTITY *)lookup(parser, |
| 4235 | &dtd->paramEntities, | 4432 | &dtd->paramEntities, |
| 4236 | externalSubsetName, | 4433 | externalSubsetName, |
| 4237 | sizeof(ENTITY)); | 4434 | sizeof(ENTITY)); |
| 4238 | if (!declEntity) | 4435 | if (!parser->m_declEntity) |
| 4239 | return XML_ERROR_NO_MEMORY; | 4436 | return XML_ERROR_NO_MEMORY; |
| 4240 | #endif /* XML_DTD */ | 4437 | #endif /* XML_DTD */ |
| 4241 | dtd->hasParamEntityRefs = XML_TRUE; | 4438 | dtd->hasParamEntityRefs = XML_TRUE; |
| 4242 | if (startDoctypeDeclHandler) { | 4439 | if (parser->m_startDoctypeDeclHandler) { |
| 4243 | XML_Char *pubId; | 4440 | XML_Char *pubId; |
| 4244 | if (!XmlIsPublicId(enc, s, next, eventPP)) | 4441 | if (!XmlIsPublicId(enc, s, next, eventPP)) |
| 4245 | return XML_ERROR_PUBLICID; | 4442 | return XML_ERROR_PUBLICID; |
| 4246 | pubId = poolStoreString(&tempPool, enc, | 4443 | pubId = poolStoreString(&parser->m_tempPool, enc, |
| 4247 | s + enc->minBytesPerChar, | 4444 | s + enc->minBytesPerChar, |
| 4248 | next - enc->minBytesPerChar); | 4445 | next - enc->minBytesPerChar); |
| 4249 | if (!pubId) | 4446 | if (!pubId) |
| 4250 | return XML_ERROR_NO_MEMORY; | 4447 | return XML_ERROR_NO_MEMORY; |
| 4251 | normalizePublicId(pubId); | 4448 | normalizePublicId(pubId); |
| 4252 | poolFinish(&tempPool); | 4449 | poolFinish(&parser->m_tempPool); |
| 4253 | doctypePubid = pubId; | 4450 | parser->m_doctypePubid = pubId; |
| 4254 | handleDefault = XML_FALSE; | 4451 | handleDefault = XML_FALSE; |
| 4255 | goto alreadyChecked; | 4452 | goto alreadyChecked; |
| 4256 | } | 4453 | } |
| @@ -4259,7 +4456,7 @@ doProlog(XML_Parser parser, | |||
| 4259 | if (!XmlIsPublicId(enc, s, next, eventPP)) | 4456 | if (!XmlIsPublicId(enc, s, next, eventPP)) |
| 4260 | return XML_ERROR_PUBLICID; | 4457 | return XML_ERROR_PUBLICID; |
| 4261 | alreadyChecked: | 4458 | alreadyChecked: |
| 4262 | if (dtd->keepProcessing && declEntity) { | 4459 | if (dtd->keepProcessing && parser->m_declEntity) { |
| 4263 | XML_Char *tem = poolStoreString(&dtd->pool, | 4460 | XML_Char *tem = poolStoreString(&dtd->pool, |
| 4264 | enc, | 4461 | enc, |
| 4265 | s + enc->minBytesPerChar, | 4462 | s + enc->minBytesPerChar, |
| @@ -4267,38 +4464,47 @@ doProlog(XML_Parser parser, | |||
| 4267 | if (!tem) | 4464 | if (!tem) |
| 4268 | return XML_ERROR_NO_MEMORY; | 4465 | return XML_ERROR_NO_MEMORY; |
| 4269 | normalizePublicId(tem); | 4466 | normalizePublicId(tem); |
| 4270 | declEntity->publicId = tem; | 4467 | parser->m_declEntity->publicId = tem; |
| 4271 | poolFinish(&dtd->pool); | 4468 | poolFinish(&dtd->pool); |
| 4272 | if (entityDeclHandler) | 4469 | /* Don't suppress the default handler if we fell through from |
| 4470 | * the XML_ROLE_DOCTYPE_PUBLIC_ID case. | ||
| 4471 | */ | ||
| 4472 | if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_PUBLIC_ID) | ||
| 4273 | handleDefault = XML_FALSE; | 4473 | handleDefault = XML_FALSE; |
| 4274 | } | 4474 | } |
| 4275 | break; | 4475 | break; |
| 4276 | case XML_ROLE_DOCTYPE_CLOSE: | 4476 | case XML_ROLE_DOCTYPE_CLOSE: |
| 4277 | if (doctypeName) { | 4477 | if (parser->m_doctypeName) { |
| 4278 | startDoctypeDeclHandler(handlerArg, doctypeName, | 4478 | parser->m_startDoctypeDeclHandler(parser->m_handlerArg, parser->m_doctypeName, |
| 4279 | doctypeSysid, doctypePubid, 0); | 4479 | parser->m_doctypeSysid, parser->m_doctypePubid, 0); |
| 4280 | poolClear(&tempPool); | 4480 | poolClear(&parser->m_tempPool); |
| 4281 | handleDefault = XML_FALSE; | 4481 | handleDefault = XML_FALSE; |
| 4282 | } | 4482 | } |
| 4283 | /* doctypeSysid will be non-NULL in the case of a previous | 4483 | /* parser->m_doctypeSysid will be non-NULL in the case of a previous |
| 4284 | XML_ROLE_DOCTYPE_SYSTEM_ID, even if startDoctypeDeclHandler | 4484 | XML_ROLE_DOCTYPE_SYSTEM_ID, even if parser->m_startDoctypeDeclHandler |
| 4285 | was not set, indicating an external subset | 4485 | was not set, indicating an external subset |
| 4286 | */ | 4486 | */ |
| 4287 | #ifdef XML_DTD | 4487 | #ifdef XML_DTD |
| 4288 | if (doctypeSysid || useForeignDTD) { | 4488 | if (parser->m_doctypeSysid || parser->m_useForeignDTD) { |
| 4289 | XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; | 4489 | XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
| 4290 | dtd->hasParamEntityRefs = XML_TRUE; | 4490 | dtd->hasParamEntityRefs = XML_TRUE; |
| 4291 | if (paramEntityParsing && externalEntityRefHandler) { | 4491 | if (parser->m_paramEntityParsing && parser->m_externalEntityRefHandler) { |
| 4292 | ENTITY *entity = (ENTITY *)lookup(parser, | 4492 | ENTITY *entity = (ENTITY *)lookup(parser, |
| 4293 | &dtd->paramEntities, | 4493 | &dtd->paramEntities, |
| 4294 | externalSubsetName, | 4494 | externalSubsetName, |
| 4295 | sizeof(ENTITY)); | 4495 | sizeof(ENTITY)); |
| 4296 | if (!entity) | 4496 | if (!entity) { |
| 4297 | return XML_ERROR_NO_MEMORY; | 4497 | /* The external subset name "#" will have already been |
| 4298 | if (useForeignDTD) | 4498 | * inserted into the hash table at the start of the |
| 4299 | entity->base = curBase; | 4499 | * external entity parsing, so no allocation will happen |
| 4500 | * and lookup() cannot fail. | ||
| 4501 | */ | ||
| 4502 | return XML_ERROR_NO_MEMORY; /* LCOV_EXCL_LINE */ | ||
| 4503 | } | ||
| 4504 | if (parser->m_useForeignDTD) | ||
| 4505 | entity->base = parser->m_curBase; | ||
| 4300 | dtd->paramEntityRead = XML_FALSE; | 4506 | dtd->paramEntityRead = XML_FALSE; |
| 4301 | if (!externalEntityRefHandler(externalEntityRefHandlerArg, | 4507 | if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, |
| 4302 | 0, | 4508 | 0, |
| 4303 | entity->base, | 4509 | entity->base, |
| 4304 | entity->systemId, | 4510 | entity->systemId, |
| @@ -4306,22 +4512,22 @@ doProlog(XML_Parser parser, | |||
| 4306 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; | 4512 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
| 4307 | if (dtd->paramEntityRead) { | 4513 | if (dtd->paramEntityRead) { |
| 4308 | if (!dtd->standalone && | 4514 | if (!dtd->standalone && |
| 4309 | notStandaloneHandler && | 4515 | parser->m_notStandaloneHandler && |
| 4310 | !notStandaloneHandler(handlerArg)) | 4516 | !parser->m_notStandaloneHandler(parser->m_handlerArg)) |
| 4311 | return XML_ERROR_NOT_STANDALONE; | 4517 | return XML_ERROR_NOT_STANDALONE; |
| 4312 | } | 4518 | } |
| 4313 | /* if we didn't read the foreign DTD then this means that there | 4519 | /* if we didn't read the foreign DTD then this means that there |
| 4314 | is no external subset and we must reset dtd->hasParamEntityRefs | 4520 | is no external subset and we must reset dtd->hasParamEntityRefs |
| 4315 | */ | 4521 | */ |
| 4316 | else if (!doctypeSysid) | 4522 | else if (!parser->m_doctypeSysid) |
| 4317 | dtd->hasParamEntityRefs = hadParamEntityRefs; | 4523 | dtd->hasParamEntityRefs = hadParamEntityRefs; |
| 4318 | /* end of DTD - no need to update dtd->keepProcessing */ | 4524 | /* end of DTD - no need to update dtd->keepProcessing */ |
| 4319 | } | 4525 | } |
| 4320 | useForeignDTD = XML_FALSE; | 4526 | parser->m_useForeignDTD = XML_FALSE; |
| 4321 | } | 4527 | } |
| 4322 | #endif /* XML_DTD */ | 4528 | #endif /* XML_DTD */ |
| 4323 | if (endDoctypeDeclHandler) { | 4529 | if (parser->m_endDoctypeDeclHandler) { |
| 4324 | endDoctypeDeclHandler(handlerArg); | 4530 | parser->m_endDoctypeDeclHandler(parser->m_handlerArg); |
| 4325 | handleDefault = XML_FALSE; | 4531 | handleDefault = XML_FALSE; |
| 4326 | } | 4532 | } |
| 4327 | break; | 4533 | break; |
| @@ -4330,18 +4536,18 @@ doProlog(XML_Parser parser, | |||
| 4330 | /* if there is no DOCTYPE declaration then now is the | 4536 | /* if there is no DOCTYPE declaration then now is the |
| 4331 | last chance to read the foreign DTD | 4537 | last chance to read the foreign DTD |
| 4332 | */ | 4538 | */ |
| 4333 | if (useForeignDTD) { | 4539 | if (parser->m_useForeignDTD) { |
| 4334 | XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; | 4540 | XML_Bool hadParamEntityRefs = dtd->hasParamEntityRefs; |
| 4335 | dtd->hasParamEntityRefs = XML_TRUE; | 4541 | dtd->hasParamEntityRefs = XML_TRUE; |
| 4336 | if (paramEntityParsing && externalEntityRefHandler) { | 4542 | if (parser->m_paramEntityParsing && parser->m_externalEntityRefHandler) { |
| 4337 | ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, | 4543 | ENTITY *entity = (ENTITY *)lookup(parser, &dtd->paramEntities, |
| 4338 | externalSubsetName, | 4544 | externalSubsetName, |
| 4339 | sizeof(ENTITY)); | 4545 | sizeof(ENTITY)); |
| 4340 | if (!entity) | 4546 | if (!entity) |
| 4341 | return XML_ERROR_NO_MEMORY; | 4547 | return XML_ERROR_NO_MEMORY; |
| 4342 | entity->base = curBase; | 4548 | entity->base = parser->m_curBase; |
| 4343 | dtd->paramEntityRead = XML_FALSE; | 4549 | dtd->paramEntityRead = XML_FALSE; |
| 4344 | if (!externalEntityRefHandler(externalEntityRefHandlerArg, | 4550 | if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, |
| 4345 | 0, | 4551 | 0, |
| 4346 | entity->base, | 4552 | entity->base, |
| 4347 | entity->systemId, | 4553 | entity->systemId, |
| @@ -4349,8 +4555,8 @@ doProlog(XML_Parser parser, | |||
| 4349 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; | 4555 | return XML_ERROR_EXTERNAL_ENTITY_HANDLING; |
| 4350 | if (dtd->paramEntityRead) { | 4556 | if (dtd->paramEntityRead) { |
| 4351 | if (!dtd->standalone && | 4557 | if (!dtd->standalone && |
| 4352 | notStandaloneHandler && | 4558 | parser->m_notStandaloneHandler && |
| 4353 | !notStandaloneHandler(handlerArg)) | 4559 | !parser->m_notStandaloneHandler(parser->m_handlerArg)) |
| 4354 | return XML_ERROR_NOT_STANDALONE; | 4560 | return XML_ERROR_NOT_STANDALONE; |
| 4355 | } | 4561 | } |
| 4356 | /* if we didn't read the foreign DTD then this means that there | 4562 | /* if we didn't read the foreign DTD then this means that there |
| @@ -4362,55 +4568,55 @@ doProlog(XML_Parser parser, | |||
| 4362 | } | 4568 | } |
| 4363 | } | 4569 | } |
| 4364 | #endif /* XML_DTD */ | 4570 | #endif /* XML_DTD */ |
| 4365 | processor = contentProcessor; | 4571 | parser->m_processor = contentProcessor; |
| 4366 | return contentProcessor(parser, s, end, nextPtr); | 4572 | return contentProcessor(parser, s, end, nextPtr); |
| 4367 | case XML_ROLE_ATTLIST_ELEMENT_NAME: | 4573 | case XML_ROLE_ATTLIST_ELEMENT_NAME: |
| 4368 | declElementType = getElementType(parser, enc, s, next); | 4574 | parser->m_declElementType = getElementType(parser, enc, s, next); |
| 4369 | if (!declElementType) | 4575 | if (!parser->m_declElementType) |
| 4370 | return XML_ERROR_NO_MEMORY; | 4576 | return XML_ERROR_NO_MEMORY; |
| 4371 | goto checkAttListDeclHandler; | 4577 | goto checkAttListDeclHandler; |
| 4372 | case XML_ROLE_ATTRIBUTE_NAME: | 4578 | case XML_ROLE_ATTRIBUTE_NAME: |
| 4373 | declAttributeId = getAttributeId(parser, enc, s, next); | 4579 | parser->m_declAttributeId = getAttributeId(parser, enc, s, next); |
| 4374 | if (!declAttributeId) | 4580 | if (!parser->m_declAttributeId) |
| 4375 | return XML_ERROR_NO_MEMORY; | 4581 | return XML_ERROR_NO_MEMORY; |
| 4376 | declAttributeIsCdata = XML_FALSE; | 4582 | parser->m_declAttributeIsCdata = XML_FALSE; |
| 4377 | declAttributeType = NULL; | 4583 | parser->m_declAttributeType = NULL; |
| 4378 | declAttributeIsId = XML_FALSE; | 4584 | parser->m_declAttributeIsId = XML_FALSE; |
| 4379 | goto checkAttListDeclHandler; | 4585 | goto checkAttListDeclHandler; |
| 4380 | case XML_ROLE_ATTRIBUTE_TYPE_CDATA: | 4586 | case XML_ROLE_ATTRIBUTE_TYPE_CDATA: |
| 4381 | declAttributeIsCdata = XML_TRUE; | 4587 | parser->m_declAttributeIsCdata = XML_TRUE; |
| 4382 | declAttributeType = atypeCDATA; | 4588 | parser->m_declAttributeType = atypeCDATA; |
| 4383 | goto checkAttListDeclHandler; | 4589 | goto checkAttListDeclHandler; |
| 4384 | case XML_ROLE_ATTRIBUTE_TYPE_ID: | 4590 | case XML_ROLE_ATTRIBUTE_TYPE_ID: |
| 4385 | declAttributeIsId = XML_TRUE; | 4591 | parser->m_declAttributeIsId = XML_TRUE; |
| 4386 | declAttributeType = atypeID; | 4592 | parser->m_declAttributeType = atypeID; |
| 4387 | goto checkAttListDeclHandler; | 4593 | goto checkAttListDeclHandler; |
| 4388 | case XML_ROLE_ATTRIBUTE_TYPE_IDREF: | 4594 | case XML_ROLE_ATTRIBUTE_TYPE_IDREF: |
| 4389 | declAttributeType = atypeIDREF; | 4595 | parser->m_declAttributeType = atypeIDREF; |
| 4390 | goto checkAttListDeclHandler; | 4596 | goto checkAttListDeclHandler; |
| 4391 | case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: | 4597 | case XML_ROLE_ATTRIBUTE_TYPE_IDREFS: |
| 4392 | declAttributeType = atypeIDREFS; | 4598 | parser->m_declAttributeType = atypeIDREFS; |
| 4393 | goto checkAttListDeclHandler; | 4599 | goto checkAttListDeclHandler; |
| 4394 | case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: | 4600 | case XML_ROLE_ATTRIBUTE_TYPE_ENTITY: |
| 4395 | declAttributeType = atypeENTITY; | 4601 | parser->m_declAttributeType = atypeENTITY; |
| 4396 | goto checkAttListDeclHandler; | 4602 | goto checkAttListDeclHandler; |
| 4397 | case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: | 4603 | case XML_ROLE_ATTRIBUTE_TYPE_ENTITIES: |
| 4398 | declAttributeType = atypeENTITIES; | 4604 | parser->m_declAttributeType = atypeENTITIES; |
| 4399 | goto checkAttListDeclHandler; | 4605 | goto checkAttListDeclHandler; |
| 4400 | case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: | 4606 | case XML_ROLE_ATTRIBUTE_TYPE_NMTOKEN: |
| 4401 | declAttributeType = atypeNMTOKEN; | 4607 | parser->m_declAttributeType = atypeNMTOKEN; |
| 4402 | goto checkAttListDeclHandler; | 4608 | goto checkAttListDeclHandler; |
| 4403 | case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: | 4609 | case XML_ROLE_ATTRIBUTE_TYPE_NMTOKENS: |
| 4404 | declAttributeType = atypeNMTOKENS; | 4610 | parser->m_declAttributeType = atypeNMTOKENS; |
| 4405 | checkAttListDeclHandler: | 4611 | checkAttListDeclHandler: |
| 4406 | if (dtd->keepProcessing && attlistDeclHandler) | 4612 | if (dtd->keepProcessing && parser->m_attlistDeclHandler) |
| 4407 | handleDefault = XML_FALSE; | 4613 | handleDefault = XML_FALSE; |
| 4408 | break; | 4614 | break; |
| 4409 | case XML_ROLE_ATTRIBUTE_ENUM_VALUE: | 4615 | case XML_ROLE_ATTRIBUTE_ENUM_VALUE: |
| 4410 | case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: | 4616 | case XML_ROLE_ATTRIBUTE_NOTATION_VALUE: |
| 4411 | if (dtd->keepProcessing && attlistDeclHandler) { | 4617 | if (dtd->keepProcessing && parser->m_attlistDeclHandler) { |
| 4412 | const XML_Char *prefix; | 4618 | const XML_Char *prefix; |
| 4413 | if (declAttributeType) { | 4619 | if (parser->m_declAttributeType) { |
| 4414 | prefix = enumValueSep; | 4620 | prefix = enumValueSep; |
| 4415 | } | 4621 | } |
| 4416 | else { | 4622 | else { |
| @@ -4418,37 +4624,37 @@ doProlog(XML_Parser parser, | |||
| 4418 | ? notationPrefix | 4624 | ? notationPrefix |
| 4419 | : enumValueStart); | 4625 | : enumValueStart); |
| 4420 | } | 4626 | } |
| 4421 | if (!poolAppendString(&tempPool, prefix)) | 4627 | if (!poolAppendString(&parser->m_tempPool, prefix)) |
| 4422 | return XML_ERROR_NO_MEMORY; | 4628 | return XML_ERROR_NO_MEMORY; |
| 4423 | if (!poolAppend(&tempPool, enc, s, next)) | 4629 | if (!poolAppend(&parser->m_tempPool, enc, s, next)) |
| 4424 | return XML_ERROR_NO_MEMORY; | 4630 | return XML_ERROR_NO_MEMORY; |
| 4425 | declAttributeType = tempPool.start; | 4631 | parser->m_declAttributeType = parser->m_tempPool.start; |
| 4426 | handleDefault = XML_FALSE; | 4632 | handleDefault = XML_FALSE; |
| 4427 | } | 4633 | } |
| 4428 | break; | 4634 | break; |
| 4429 | case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: | 4635 | case XML_ROLE_IMPLIED_ATTRIBUTE_VALUE: |
| 4430 | case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: | 4636 | case XML_ROLE_REQUIRED_ATTRIBUTE_VALUE: |
| 4431 | if (dtd->keepProcessing) { | 4637 | if (dtd->keepProcessing) { |
| 4432 | if (!defineAttribute(declElementType, declAttributeId, | 4638 | if (!defineAttribute(parser->m_declElementType, parser->m_declAttributeId, |
| 4433 | declAttributeIsCdata, declAttributeIsId, | 4639 | parser->m_declAttributeIsCdata, parser->m_declAttributeIsId, |
| 4434 | 0, parser)) | 4640 | 0, parser)) |
| 4435 | return XML_ERROR_NO_MEMORY; | 4641 | return XML_ERROR_NO_MEMORY; |
| 4436 | if (attlistDeclHandler && declAttributeType) { | 4642 | if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { |
| 4437 | if (*declAttributeType == XML_T(ASCII_LPAREN) | 4643 | if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) |
| 4438 | || (*declAttributeType == XML_T(ASCII_N) | 4644 | || (*parser->m_declAttributeType == XML_T(ASCII_N) |
| 4439 | && declAttributeType[1] == XML_T(ASCII_O))) { | 4645 | && parser->m_declAttributeType[1] == XML_T(ASCII_O))) { |
| 4440 | /* Enumerated or Notation type */ | 4646 | /* Enumerated or Notation type */ |
| 4441 | if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) | 4647 | if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) |
| 4442 | || !poolAppendChar(&tempPool, XML_T('\0'))) | 4648 | || !poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 4443 | return XML_ERROR_NO_MEMORY; | 4649 | return XML_ERROR_NO_MEMORY; |
| 4444 | declAttributeType = tempPool.start; | 4650 | parser->m_declAttributeType = parser->m_tempPool.start; |
| 4445 | poolFinish(&tempPool); | 4651 | poolFinish(&parser->m_tempPool); |
| 4446 | } | 4652 | } |
| 4447 | *eventEndPP = s; | 4653 | *eventEndPP = s; |
| 4448 | attlistDeclHandler(handlerArg, declElementType->name, | 4654 | parser->m_attlistDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, |
| 4449 | declAttributeId->name, declAttributeType, | 4655 | parser->m_declAttributeId->name, parser->m_declAttributeType, |
| 4450 | 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); | 4656 | 0, role == XML_ROLE_REQUIRED_ATTRIBUTE_VALUE); |
| 4451 | poolClear(&tempPool); | 4657 | poolClear(&parser->m_tempPool); |
| 4452 | handleDefault = XML_FALSE; | 4658 | handleDefault = XML_FALSE; |
| 4453 | } | 4659 | } |
| 4454 | } | 4660 | } |
| @@ -4458,7 +4664,7 @@ doProlog(XML_Parser parser, | |||
| 4458 | if (dtd->keepProcessing) { | 4664 | if (dtd->keepProcessing) { |
| 4459 | const XML_Char *attVal; | 4665 | const XML_Char *attVal; |
| 4460 | enum XML_Error result = | 4666 | enum XML_Error result = |
| 4461 | storeAttributeValue(parser, enc, declAttributeIsCdata, | 4667 | storeAttributeValue(parser, enc, parser->m_declAttributeIsCdata, |
| 4462 | s + enc->minBytesPerChar, | 4668 | s + enc->minBytesPerChar, |
| 4463 | next - enc->minBytesPerChar, | 4669 | next - enc->minBytesPerChar, |
| 4464 | &dtd->pool); | 4670 | &dtd->pool); |
| @@ -4467,26 +4673,26 @@ doProlog(XML_Parser parser, | |||
| 4467 | attVal = poolStart(&dtd->pool); | 4673 | attVal = poolStart(&dtd->pool); |
| 4468 | poolFinish(&dtd->pool); | 4674 | poolFinish(&dtd->pool); |
| 4469 | /* ID attributes aren't allowed to have a default */ | 4675 | /* ID attributes aren't allowed to have a default */ |
| 4470 | if (!defineAttribute(declElementType, declAttributeId, | 4676 | if (!defineAttribute(parser->m_declElementType, parser->m_declAttributeId, |
| 4471 | declAttributeIsCdata, XML_FALSE, attVal, parser)) | 4677 | parser->m_declAttributeIsCdata, XML_FALSE, attVal, parser)) |
| 4472 | return XML_ERROR_NO_MEMORY; | 4678 | return XML_ERROR_NO_MEMORY; |
| 4473 | if (attlistDeclHandler && declAttributeType) { | 4679 | if (parser->m_attlistDeclHandler && parser->m_declAttributeType) { |
| 4474 | if (*declAttributeType == XML_T(ASCII_LPAREN) | 4680 | if (*parser->m_declAttributeType == XML_T(ASCII_LPAREN) |
| 4475 | || (*declAttributeType == XML_T(ASCII_N) | 4681 | || (*parser->m_declAttributeType == XML_T(ASCII_N) |
| 4476 | && declAttributeType[1] == XML_T(ASCII_O))) { | 4682 | && parser->m_declAttributeType[1] == XML_T(ASCII_O))) { |
| 4477 | /* Enumerated or Notation type */ | 4683 | /* Enumerated or Notation type */ |
| 4478 | if (!poolAppendChar(&tempPool, XML_T(ASCII_RPAREN)) | 4684 | if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_RPAREN)) |
| 4479 | || !poolAppendChar(&tempPool, XML_T('\0'))) | 4685 | || !poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 4480 | return XML_ERROR_NO_MEMORY; | 4686 | return XML_ERROR_NO_MEMORY; |
| 4481 | declAttributeType = tempPool.start; | 4687 | parser->m_declAttributeType = parser->m_tempPool.start; |
| 4482 | poolFinish(&tempPool); | 4688 | poolFinish(&parser->m_tempPool); |
| 4483 | } | 4689 | } |
| 4484 | *eventEndPP = s; | 4690 | *eventEndPP = s; |
| 4485 | attlistDeclHandler(handlerArg, declElementType->name, | 4691 | parser->m_attlistDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, |
| 4486 | declAttributeId->name, declAttributeType, | 4692 | parser->m_declAttributeId->name, parser->m_declAttributeType, |
| 4487 | attVal, | 4693 | attVal, |
| 4488 | role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); | 4694 | role == XML_ROLE_FIXED_ATTRIBUTE_VALUE); |
| 4489 | poolClear(&tempPool); | 4695 | poolClear(&parser->m_tempPool); |
| 4490 | handleDefault = XML_FALSE; | 4696 | handleDefault = XML_FALSE; |
| 4491 | } | 4697 | } |
| 4492 | } | 4698 | } |
| @@ -4496,18 +4702,18 @@ doProlog(XML_Parser parser, | |||
| 4496 | enum XML_Error result = storeEntityValue(parser, enc, | 4702 | enum XML_Error result = storeEntityValue(parser, enc, |
| 4497 | s + enc->minBytesPerChar, | 4703 | s + enc->minBytesPerChar, |
| 4498 | next - enc->minBytesPerChar); | 4704 | next - enc->minBytesPerChar); |
| 4499 | if (declEntity) { | 4705 | if (parser->m_declEntity) { |
| 4500 | declEntity->textPtr = poolStart(&dtd->entityValuePool); | 4706 | parser->m_declEntity->textPtr = poolStart(&dtd->entityValuePool); |
| 4501 | declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); | 4707 | parser->m_declEntity->textLen = (int)(poolLength(&dtd->entityValuePool)); |
| 4502 | poolFinish(&dtd->entityValuePool); | 4708 | poolFinish(&dtd->entityValuePool); |
| 4503 | if (entityDeclHandler) { | 4709 | if (parser->m_entityDeclHandler) { |
| 4504 | *eventEndPP = s; | 4710 | *eventEndPP = s; |
| 4505 | entityDeclHandler(handlerArg, | 4711 | parser->m_entityDeclHandler(parser->m_handlerArg, |
| 4506 | declEntity->name, | 4712 | parser->m_declEntity->name, |
| 4507 | declEntity->is_param, | 4713 | parser->m_declEntity->is_param, |
| 4508 | declEntity->textPtr, | 4714 | parser->m_declEntity->textPtr, |
| 4509 | declEntity->textLen, | 4715 | parser->m_declEntity->textLen, |
| 4510 | curBase, 0, 0, 0); | 4716 | parser->m_curBase, 0, 0, 0); |
| 4511 | handleDefault = XML_FALSE; | 4717 | handleDefault = XML_FALSE; |
| 4512 | } | 4718 | } |
| 4513 | } | 4719 | } |
| @@ -4519,97 +4725,100 @@ doProlog(XML_Parser parser, | |||
| 4519 | break; | 4725 | break; |
| 4520 | case XML_ROLE_DOCTYPE_SYSTEM_ID: | 4726 | case XML_ROLE_DOCTYPE_SYSTEM_ID: |
| 4521 | #ifdef XML_DTD | 4727 | #ifdef XML_DTD |
| 4522 | useForeignDTD = XML_FALSE; | 4728 | parser->m_useForeignDTD = XML_FALSE; |
| 4523 | #endif /* XML_DTD */ | 4729 | #endif /* XML_DTD */ |
| 4524 | dtd->hasParamEntityRefs = XML_TRUE; | 4730 | dtd->hasParamEntityRefs = XML_TRUE; |
| 4525 | if (startDoctypeDeclHandler) { | 4731 | if (parser->m_startDoctypeDeclHandler) { |
| 4526 | doctypeSysid = poolStoreString(&tempPool, enc, | 4732 | parser->m_doctypeSysid = poolStoreString(&parser->m_tempPool, enc, |
| 4527 | s + enc->minBytesPerChar, | 4733 | s + enc->minBytesPerChar, |
| 4528 | next - enc->minBytesPerChar); | 4734 | next - enc->minBytesPerChar); |
| 4529 | if (doctypeSysid == NULL) | 4735 | if (parser->m_doctypeSysid == NULL) |
| 4530 | return XML_ERROR_NO_MEMORY; | 4736 | return XML_ERROR_NO_MEMORY; |
| 4531 | poolFinish(&tempPool); | 4737 | poolFinish(&parser->m_tempPool); |
| 4532 | handleDefault = XML_FALSE; | 4738 | handleDefault = XML_FALSE; |
| 4533 | } | 4739 | } |
| 4534 | #ifdef XML_DTD | 4740 | #ifdef XML_DTD |
| 4535 | else | 4741 | else |
| 4536 | /* use externalSubsetName to make doctypeSysid non-NULL | 4742 | /* use externalSubsetName to make parser->m_doctypeSysid non-NULL |
| 4537 | for the case where no startDoctypeDeclHandler is set */ | 4743 | for the case where no parser->m_startDoctypeDeclHandler is set */ |
| 4538 | doctypeSysid = externalSubsetName; | 4744 | parser->m_doctypeSysid = externalSubsetName; |
| 4539 | #endif /* XML_DTD */ | 4745 | #endif /* XML_DTD */ |
| 4540 | if (!dtd->standalone | 4746 | if (!dtd->standalone |
| 4541 | #ifdef XML_DTD | 4747 | #ifdef XML_DTD |
| 4542 | && !paramEntityParsing | 4748 | && !parser->m_paramEntityParsing |
| 4543 | #endif /* XML_DTD */ | 4749 | #endif /* XML_DTD */ |
| 4544 | && notStandaloneHandler | 4750 | && parser->m_notStandaloneHandler |
| 4545 | && !notStandaloneHandler(handlerArg)) | 4751 | && !parser->m_notStandaloneHandler(parser->m_handlerArg)) |
| 4546 | return XML_ERROR_NOT_STANDALONE; | 4752 | return XML_ERROR_NOT_STANDALONE; |
| 4547 | #ifndef XML_DTD | 4753 | #ifndef XML_DTD |
| 4548 | break; | 4754 | break; |
| 4549 | #else /* XML_DTD */ | 4755 | #else /* XML_DTD */ |
| 4550 | if (!declEntity) { | 4756 | if (!parser->m_declEntity) { |
| 4551 | declEntity = (ENTITY *)lookup(parser, | 4757 | parser->m_declEntity = (ENTITY *)lookup(parser, |
| 4552 | &dtd->paramEntities, | 4758 | &dtd->paramEntities, |
| 4553 | externalSubsetName, | 4759 | externalSubsetName, |
| 4554 | sizeof(ENTITY)); | 4760 | sizeof(ENTITY)); |
| 4555 | if (!declEntity) | 4761 | if (!parser->m_declEntity) |
| 4556 | return XML_ERROR_NO_MEMORY; | 4762 | return XML_ERROR_NO_MEMORY; |
| 4557 | declEntity->publicId = NULL; | 4763 | parser->m_declEntity->publicId = NULL; |
| 4558 | } | 4764 | } |
| 4559 | /* fall through */ | ||
| 4560 | #endif /* XML_DTD */ | 4765 | #endif /* XML_DTD */ |
| 4766 | /* fall through */ | ||
| 4561 | case XML_ROLE_ENTITY_SYSTEM_ID: | 4767 | case XML_ROLE_ENTITY_SYSTEM_ID: |
| 4562 | if (dtd->keepProcessing && declEntity) { | 4768 | if (dtd->keepProcessing && parser->m_declEntity) { |
| 4563 | declEntity->systemId = poolStoreString(&dtd->pool, enc, | 4769 | parser->m_declEntity->systemId = poolStoreString(&dtd->pool, enc, |
| 4564 | s + enc->minBytesPerChar, | 4770 | s + enc->minBytesPerChar, |
| 4565 | next - enc->minBytesPerChar); | 4771 | next - enc->minBytesPerChar); |
| 4566 | if (!declEntity->systemId) | 4772 | if (!parser->m_declEntity->systemId) |
| 4567 | return XML_ERROR_NO_MEMORY; | 4773 | return XML_ERROR_NO_MEMORY; |
| 4568 | declEntity->base = curBase; | 4774 | parser->m_declEntity->base = parser->m_curBase; |
| 4569 | poolFinish(&dtd->pool); | 4775 | poolFinish(&dtd->pool); |
| 4570 | if (entityDeclHandler) | 4776 | /* Don't suppress the default handler if we fell through from |
| 4777 | * the XML_ROLE_DOCTYPE_SYSTEM_ID case. | ||
| 4778 | */ | ||
| 4779 | if (parser->m_entityDeclHandler && role == XML_ROLE_ENTITY_SYSTEM_ID) | ||
| 4571 | handleDefault = XML_FALSE; | 4780 | handleDefault = XML_FALSE; |
| 4572 | } | 4781 | } |
| 4573 | break; | 4782 | break; |
| 4574 | case XML_ROLE_ENTITY_COMPLETE: | 4783 | case XML_ROLE_ENTITY_COMPLETE: |
| 4575 | if (dtd->keepProcessing && declEntity && entityDeclHandler) { | 4784 | if (dtd->keepProcessing && parser->m_declEntity && parser->m_entityDeclHandler) { |
| 4576 | *eventEndPP = s; | 4785 | *eventEndPP = s; |
| 4577 | entityDeclHandler(handlerArg, | 4786 | parser->m_entityDeclHandler(parser->m_handlerArg, |
| 4578 | declEntity->name, | 4787 | parser->m_declEntity->name, |
| 4579 | declEntity->is_param, | 4788 | parser->m_declEntity->is_param, |
| 4580 | 0,0, | 4789 | 0,0, |
| 4581 | declEntity->base, | 4790 | parser->m_declEntity->base, |
| 4582 | declEntity->systemId, | 4791 | parser->m_declEntity->systemId, |
| 4583 | declEntity->publicId, | 4792 | parser->m_declEntity->publicId, |
| 4584 | 0); | 4793 | 0); |
| 4585 | handleDefault = XML_FALSE; | 4794 | handleDefault = XML_FALSE; |
| 4586 | } | 4795 | } |
| 4587 | break; | 4796 | break; |
| 4588 | case XML_ROLE_ENTITY_NOTATION_NAME: | 4797 | case XML_ROLE_ENTITY_NOTATION_NAME: |
| 4589 | if (dtd->keepProcessing && declEntity) { | 4798 | if (dtd->keepProcessing && parser->m_declEntity) { |
| 4590 | declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); | 4799 | parser->m_declEntity->notation = poolStoreString(&dtd->pool, enc, s, next); |
| 4591 | if (!declEntity->notation) | 4800 | if (!parser->m_declEntity->notation) |
| 4592 | return XML_ERROR_NO_MEMORY; | 4801 | return XML_ERROR_NO_MEMORY; |
| 4593 | poolFinish(&dtd->pool); | 4802 | poolFinish(&dtd->pool); |
| 4594 | if (unparsedEntityDeclHandler) { | 4803 | if (parser->m_unparsedEntityDeclHandler) { |
| 4595 | *eventEndPP = s; | 4804 | *eventEndPP = s; |
| 4596 | unparsedEntityDeclHandler(handlerArg, | 4805 | parser->m_unparsedEntityDeclHandler(parser->m_handlerArg, |
| 4597 | declEntity->name, | 4806 | parser->m_declEntity->name, |
| 4598 | declEntity->base, | 4807 | parser->m_declEntity->base, |
| 4599 | declEntity->systemId, | 4808 | parser->m_declEntity->systemId, |
| 4600 | declEntity->publicId, | 4809 | parser->m_declEntity->publicId, |
| 4601 | declEntity->notation); | 4810 | parser->m_declEntity->notation); |
| 4602 | handleDefault = XML_FALSE; | 4811 | handleDefault = XML_FALSE; |
| 4603 | } | 4812 | } |
| 4604 | else if (entityDeclHandler) { | 4813 | else if (parser->m_entityDeclHandler) { |
| 4605 | *eventEndPP = s; | 4814 | *eventEndPP = s; |
| 4606 | entityDeclHandler(handlerArg, | 4815 | parser->m_entityDeclHandler(parser->m_handlerArg, |
| 4607 | declEntity->name, | 4816 | parser->m_declEntity->name, |
| 4608 | 0,0,0, | 4817 | 0,0,0, |
| 4609 | declEntity->base, | 4818 | parser->m_declEntity->base, |
| 4610 | declEntity->systemId, | 4819 | parser->m_declEntity->systemId, |
| 4611 | declEntity->publicId, | 4820 | parser->m_declEntity->publicId, |
| 4612 | declEntity->notation); | 4821 | parser->m_declEntity->notation); |
| 4613 | handleDefault = XML_FALSE; | 4822 | handleDefault = XML_FALSE; |
| 4614 | } | 4823 | } |
| 4615 | } | 4824 | } |
| @@ -4617,36 +4826,36 @@ doProlog(XML_Parser parser, | |||
| 4617 | case XML_ROLE_GENERAL_ENTITY_NAME: | 4826 | case XML_ROLE_GENERAL_ENTITY_NAME: |
| 4618 | { | 4827 | { |
| 4619 | if (XmlPredefinedEntityName(enc, s, next)) { | 4828 | if (XmlPredefinedEntityName(enc, s, next)) { |
| 4620 | declEntity = NULL; | 4829 | parser->m_declEntity = NULL; |
| 4621 | break; | 4830 | break; |
| 4622 | } | 4831 | } |
| 4623 | if (dtd->keepProcessing) { | 4832 | if (dtd->keepProcessing) { |
| 4624 | const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); | 4833 | const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
| 4625 | if (!name) | 4834 | if (!name) |
| 4626 | return XML_ERROR_NO_MEMORY; | 4835 | return XML_ERROR_NO_MEMORY; |
| 4627 | declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, | 4836 | parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, |
| 4628 | sizeof(ENTITY)); | 4837 | sizeof(ENTITY)); |
| 4629 | if (!declEntity) | 4838 | if (!parser->m_declEntity) |
| 4630 | return XML_ERROR_NO_MEMORY; | 4839 | return XML_ERROR_NO_MEMORY; |
| 4631 | if (declEntity->name != name) { | 4840 | if (parser->m_declEntity->name != name) { |
| 4632 | poolDiscard(&dtd->pool); | 4841 | poolDiscard(&dtd->pool); |
| 4633 | declEntity = NULL; | 4842 | parser->m_declEntity = NULL; |
| 4634 | } | 4843 | } |
| 4635 | else { | 4844 | else { |
| 4636 | poolFinish(&dtd->pool); | 4845 | poolFinish(&dtd->pool); |
| 4637 | declEntity->publicId = NULL; | 4846 | parser->m_declEntity->publicId = NULL; |
| 4638 | declEntity->is_param = XML_FALSE; | 4847 | parser->m_declEntity->is_param = XML_FALSE; |
| 4639 | /* if we have a parent parser or are reading an internal parameter | 4848 | /* if we have a parent parser or are reading an internal parameter |
| 4640 | entity, then the entity declaration is not considered "internal" | 4849 | entity, then the entity declaration is not considered "internal" |
| 4641 | */ | 4850 | */ |
| 4642 | declEntity->is_internal = !(parentParser || openInternalEntities); | 4851 | parser->m_declEntity->is_internal = !(parser->m_parentParser || parser->m_openInternalEntities); |
| 4643 | if (entityDeclHandler) | 4852 | if (parser->m_entityDeclHandler) |
| 4644 | handleDefault = XML_FALSE; | 4853 | handleDefault = XML_FALSE; |
| 4645 | } | 4854 | } |
| 4646 | } | 4855 | } |
| 4647 | else { | 4856 | else { |
| 4648 | poolDiscard(&dtd->pool); | 4857 | poolDiscard(&dtd->pool); |
| 4649 | declEntity = NULL; | 4858 | parser->m_declEntity = NULL; |
| 4650 | } | 4859 | } |
| 4651 | } | 4860 | } |
| 4652 | break; | 4861 | break; |
| @@ -4656,90 +4865,90 @@ doProlog(XML_Parser parser, | |||
| 4656 | const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); | 4865 | const XML_Char *name = poolStoreString(&dtd->pool, enc, s, next); |
| 4657 | if (!name) | 4866 | if (!name) |
| 4658 | return XML_ERROR_NO_MEMORY; | 4867 | return XML_ERROR_NO_MEMORY; |
| 4659 | declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, | 4868 | parser->m_declEntity = (ENTITY *)lookup(parser, &dtd->paramEntities, |
| 4660 | name, sizeof(ENTITY)); | 4869 | name, sizeof(ENTITY)); |
| 4661 | if (!declEntity) | 4870 | if (!parser->m_declEntity) |
| 4662 | return XML_ERROR_NO_MEMORY; | 4871 | return XML_ERROR_NO_MEMORY; |
| 4663 | if (declEntity->name != name) { | 4872 | if (parser->m_declEntity->name != name) { |
| 4664 | poolDiscard(&dtd->pool); | 4873 | poolDiscard(&dtd->pool); |
| 4665 | declEntity = NULL; | 4874 | parser->m_declEntity = NULL; |
| 4666 | } | 4875 | } |
| 4667 | else { | 4876 | else { |
| 4668 | poolFinish(&dtd->pool); | 4877 | poolFinish(&dtd->pool); |
| 4669 | declEntity->publicId = NULL; | 4878 | parser->m_declEntity->publicId = NULL; |
| 4670 | declEntity->is_param = XML_TRUE; | 4879 | parser->m_declEntity->is_param = XML_TRUE; |
| 4671 | /* if we have a parent parser or are reading an internal parameter | 4880 | /* if we have a parent parser or are reading an internal parameter |
| 4672 | entity, then the entity declaration is not considered "internal" | 4881 | entity, then the entity declaration is not considered "internal" |
| 4673 | */ | 4882 | */ |
| 4674 | declEntity->is_internal = !(parentParser || openInternalEntities); | 4883 | parser->m_declEntity->is_internal = !(parser->m_parentParser || parser->m_openInternalEntities); |
| 4675 | if (entityDeclHandler) | 4884 | if (parser->m_entityDeclHandler) |
| 4676 | handleDefault = XML_FALSE; | 4885 | handleDefault = XML_FALSE; |
| 4677 | } | 4886 | } |
| 4678 | } | 4887 | } |
| 4679 | else { | 4888 | else { |
| 4680 | poolDiscard(&dtd->pool); | 4889 | poolDiscard(&dtd->pool); |
| 4681 | declEntity = NULL; | 4890 | parser->m_declEntity = NULL; |
| 4682 | } | 4891 | } |
| 4683 | #else /* not XML_DTD */ | 4892 | #else /* not XML_DTD */ |
| 4684 | declEntity = NULL; | 4893 | parser->m_declEntity = NULL; |
| 4685 | #endif /* XML_DTD */ | 4894 | #endif /* XML_DTD */ |
| 4686 | break; | 4895 | break; |
| 4687 | case XML_ROLE_NOTATION_NAME: | 4896 | case XML_ROLE_NOTATION_NAME: |
| 4688 | declNotationPublicId = NULL; | 4897 | parser->m_declNotationPublicId = NULL; |
| 4689 | declNotationName = NULL; | 4898 | parser->m_declNotationName = NULL; |
| 4690 | if (notationDeclHandler) { | 4899 | if (parser->m_notationDeclHandler) { |
| 4691 | declNotationName = poolStoreString(&tempPool, enc, s, next); | 4900 | parser->m_declNotationName = poolStoreString(&parser->m_tempPool, enc, s, next); |
| 4692 | if (!declNotationName) | 4901 | if (!parser->m_declNotationName) |
| 4693 | return XML_ERROR_NO_MEMORY; | 4902 | return XML_ERROR_NO_MEMORY; |
| 4694 | poolFinish(&tempPool); | 4903 | poolFinish(&parser->m_tempPool); |
| 4695 | handleDefault = XML_FALSE; | 4904 | handleDefault = XML_FALSE; |
| 4696 | } | 4905 | } |
| 4697 | break; | 4906 | break; |
| 4698 | case XML_ROLE_NOTATION_PUBLIC_ID: | 4907 | case XML_ROLE_NOTATION_PUBLIC_ID: |
| 4699 | if (!XmlIsPublicId(enc, s, next, eventPP)) | 4908 | if (!XmlIsPublicId(enc, s, next, eventPP)) |
| 4700 | return XML_ERROR_PUBLICID; | 4909 | return XML_ERROR_PUBLICID; |
| 4701 | if (declNotationName) { /* means notationDeclHandler != NULL */ | 4910 | if (parser->m_declNotationName) { /* means m_notationDeclHandler != NULL */ |
| 4702 | XML_Char *tem = poolStoreString(&tempPool, | 4911 | XML_Char *tem = poolStoreString(&parser->m_tempPool, |
| 4703 | enc, | 4912 | enc, |
| 4704 | s + enc->minBytesPerChar, | 4913 | s + enc->minBytesPerChar, |
| 4705 | next - enc->minBytesPerChar); | 4914 | next - enc->minBytesPerChar); |
| 4706 | if (!tem) | 4915 | if (!tem) |
| 4707 | return XML_ERROR_NO_MEMORY; | 4916 | return XML_ERROR_NO_MEMORY; |
| 4708 | normalizePublicId(tem); | 4917 | normalizePublicId(tem); |
| 4709 | declNotationPublicId = tem; | 4918 | parser->m_declNotationPublicId = tem; |
| 4710 | poolFinish(&tempPool); | 4919 | poolFinish(&parser->m_tempPool); |
| 4711 | handleDefault = XML_FALSE; | 4920 | handleDefault = XML_FALSE; |
| 4712 | } | 4921 | } |
| 4713 | break; | 4922 | break; |
| 4714 | case XML_ROLE_NOTATION_SYSTEM_ID: | 4923 | case XML_ROLE_NOTATION_SYSTEM_ID: |
| 4715 | if (declNotationName && notationDeclHandler) { | 4924 | if (parser->m_declNotationName && parser->m_notationDeclHandler) { |
| 4716 | const XML_Char *systemId | 4925 | const XML_Char *systemId |
| 4717 | = poolStoreString(&tempPool, enc, | 4926 | = poolStoreString(&parser->m_tempPool, enc, |
| 4718 | s + enc->minBytesPerChar, | 4927 | s + enc->minBytesPerChar, |
| 4719 | next - enc->minBytesPerChar); | 4928 | next - enc->minBytesPerChar); |
| 4720 | if (!systemId) | 4929 | if (!systemId) |
| 4721 | return XML_ERROR_NO_MEMORY; | 4930 | return XML_ERROR_NO_MEMORY; |
| 4722 | *eventEndPP = s; | 4931 | *eventEndPP = s; |
| 4723 | notationDeclHandler(handlerArg, | 4932 | parser->m_notationDeclHandler(parser->m_handlerArg, |
| 4724 | declNotationName, | 4933 | parser->m_declNotationName, |
| 4725 | curBase, | 4934 | parser->m_curBase, |
| 4726 | systemId, | 4935 | systemId, |
| 4727 | declNotationPublicId); | 4936 | parser->m_declNotationPublicId); |
| 4728 | handleDefault = XML_FALSE; | 4937 | handleDefault = XML_FALSE; |
| 4729 | } | 4938 | } |
| 4730 | poolClear(&tempPool); | 4939 | poolClear(&parser->m_tempPool); |
| 4731 | break; | 4940 | break; |
| 4732 | case XML_ROLE_NOTATION_NO_SYSTEM_ID: | 4941 | case XML_ROLE_NOTATION_NO_SYSTEM_ID: |
| 4733 | if (declNotationPublicId && notationDeclHandler) { | 4942 | if (parser->m_declNotationPublicId && parser->m_notationDeclHandler) { |
| 4734 | *eventEndPP = s; | 4943 | *eventEndPP = s; |
| 4735 | notationDeclHandler(handlerArg, | 4944 | parser->m_notationDeclHandler(parser->m_handlerArg, |
| 4736 | declNotationName, | 4945 | parser->m_declNotationName, |
| 4737 | curBase, | 4946 | parser->m_curBase, |
| 4738 | 0, | 4947 | 0, |
| 4739 | declNotationPublicId); | 4948 | parser->m_declNotationPublicId); |
| 4740 | handleDefault = XML_FALSE; | 4949 | handleDefault = XML_FALSE; |
| 4741 | } | 4950 | } |
| 4742 | poolClear(&tempPool); | 4951 | poolClear(&parser->m_tempPool); |
| 4743 | break; | 4952 | break; |
| 4744 | case XML_ROLE_ERROR: | 4953 | case XML_ROLE_ERROR: |
| 4745 | switch (tok) { | 4954 | switch (tok) { |
| @@ -4756,41 +4965,45 @@ doProlog(XML_Parser parser, | |||
| 4756 | case XML_ROLE_IGNORE_SECT: | 4965 | case XML_ROLE_IGNORE_SECT: |
| 4757 | { | 4966 | { |
| 4758 | enum XML_Error result; | 4967 | enum XML_Error result; |
| 4759 | if (defaultHandler) | 4968 | if (parser->m_defaultHandler) |
| 4760 | reportDefault(parser, enc, s, next); | 4969 | reportDefault(parser, enc, s, next); |
| 4761 | handleDefault = XML_FALSE; | 4970 | handleDefault = XML_FALSE; |
| 4762 | result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); | 4971 | result = doIgnoreSection(parser, enc, &next, end, nextPtr, haveMore); |
| 4763 | if (result != XML_ERROR_NONE) | 4972 | if (result != XML_ERROR_NONE) |
| 4764 | return result; | 4973 | return result; |
| 4765 | else if (!next) { | 4974 | else if (!next) { |
| 4766 | processor = ignoreSectionProcessor; | 4975 | parser->m_processor = ignoreSectionProcessor; |
| 4767 | return result; | 4976 | return result; |
| 4768 | } | 4977 | } |
| 4769 | } | 4978 | } |
| 4770 | break; | 4979 | break; |
| 4771 | #endif /* XML_DTD */ | 4980 | #endif /* XML_DTD */ |
| 4772 | case XML_ROLE_GROUP_OPEN: | 4981 | case XML_ROLE_GROUP_OPEN: |
| 4773 | if (prologState.level >= groupSize) { | 4982 | if (parser->m_prologState.level >= parser->m_groupSize) { |
| 4774 | if (groupSize) { | 4983 | if (parser->m_groupSize) { |
| 4775 | char *temp = (char *)REALLOC(groupConnector, groupSize *= 2); | 4984 | char *temp = (char *)REALLOC(parser, parser->m_groupConnector, parser->m_groupSize *= 2); |
| 4776 | if (temp == NULL) | 4985 | if (temp == NULL) { |
| 4986 | parser->m_groupSize /= 2; | ||
| 4777 | return XML_ERROR_NO_MEMORY; | 4987 | return XML_ERROR_NO_MEMORY; |
| 4778 | groupConnector = temp; | 4988 | } |
| 4989 | parser->m_groupConnector = temp; | ||
| 4779 | if (dtd->scaffIndex) { | 4990 | if (dtd->scaffIndex) { |
| 4780 | int *temp = (int *)REALLOC(dtd->scaffIndex, | 4991 | int *temp = (int *)REALLOC(parser, dtd->scaffIndex, |
| 4781 | groupSize * sizeof(int)); | 4992 | parser->m_groupSize * sizeof(int)); |
| 4782 | if (temp == NULL) | 4993 | if (temp == NULL) |
| 4783 | return XML_ERROR_NO_MEMORY; | 4994 | return XML_ERROR_NO_MEMORY; |
| 4784 | dtd->scaffIndex = temp; | 4995 | dtd->scaffIndex = temp; |
| 4785 | } | 4996 | } |
| 4786 | } | 4997 | } |
| 4787 | else { | 4998 | else { |
| 4788 | groupConnector = (char *)MALLOC(groupSize = 32); | 4999 | parser->m_groupConnector = (char *)MALLOC(parser, parser->m_groupSize = 32); |
| 4789 | if (!groupConnector) | 5000 | if (!parser->m_groupConnector) { |
| 5001 | parser->m_groupSize = 0; | ||
| 4790 | return XML_ERROR_NO_MEMORY; | 5002 | return XML_ERROR_NO_MEMORY; |
| 5003 | } | ||
| 4791 | } | 5004 | } |
| 4792 | } | 5005 | } |
| 4793 | groupConnector[prologState.level] = 0; | 5006 | parser->m_groupConnector[parser->m_prologState.level] = 0; |
| 4794 | if (dtd->in_eldecl) { | 5007 | if (dtd->in_eldecl) { |
| 4795 | int myindex = nextScaffoldPart(parser); | 5008 | int myindex = nextScaffoldPart(parser); |
| 4796 | if (myindex < 0) | 5009 | if (myindex < 0) |
| @@ -4798,37 +5011,37 @@ doProlog(XML_Parser parser, | |||
| 4798 | dtd->scaffIndex[dtd->scaffLevel] = myindex; | 5011 | dtd->scaffIndex[dtd->scaffLevel] = myindex; |
| 4799 | dtd->scaffLevel++; | 5012 | dtd->scaffLevel++; |
| 4800 | dtd->scaffold[myindex].type = XML_CTYPE_SEQ; | 5013 | dtd->scaffold[myindex].type = XML_CTYPE_SEQ; |
| 4801 | if (elementDeclHandler) | 5014 | if (parser->m_elementDeclHandler) |
| 4802 | handleDefault = XML_FALSE; | 5015 | handleDefault = XML_FALSE; |
| 4803 | } | 5016 | } |
| 4804 | break; | 5017 | break; |
| 4805 | case XML_ROLE_GROUP_SEQUENCE: | 5018 | case XML_ROLE_GROUP_SEQUENCE: |
| 4806 | if (groupConnector[prologState.level] == ASCII_PIPE) | 5019 | if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_PIPE) |
| 4807 | return XML_ERROR_SYNTAX; | 5020 | return XML_ERROR_SYNTAX; |
| 4808 | groupConnector[prologState.level] = ASCII_COMMA; | 5021 | parser->m_groupConnector[parser->m_prologState.level] = ASCII_COMMA; |
| 4809 | if (dtd->in_eldecl && elementDeclHandler) | 5022 | if (dtd->in_eldecl && parser->m_elementDeclHandler) |
| 4810 | handleDefault = XML_FALSE; | 5023 | handleDefault = XML_FALSE; |
| 4811 | break; | 5024 | break; |
| 4812 | case XML_ROLE_GROUP_CHOICE: | 5025 | case XML_ROLE_GROUP_CHOICE: |
| 4813 | if (groupConnector[prologState.level] == ASCII_COMMA) | 5026 | if (parser->m_groupConnector[parser->m_prologState.level] == ASCII_COMMA) |
| 4814 | return XML_ERROR_SYNTAX; | 5027 | return XML_ERROR_SYNTAX; |
| 4815 | if (dtd->in_eldecl | 5028 | if (dtd->in_eldecl |
| 4816 | && !groupConnector[prologState.level] | 5029 | && !parser->m_groupConnector[parser->m_prologState.level] |
| 4817 | && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type | 5030 | && (dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
| 4818 | != XML_CTYPE_MIXED) | 5031 | != XML_CTYPE_MIXED) |
| 4819 | ) { | 5032 | ) { |
| 4820 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type | 5033 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
| 4821 | = XML_CTYPE_CHOICE; | 5034 | = XML_CTYPE_CHOICE; |
| 4822 | if (elementDeclHandler) | 5035 | if (parser->m_elementDeclHandler) |
| 4823 | handleDefault = XML_FALSE; | 5036 | handleDefault = XML_FALSE; |
| 4824 | } | 5037 | } |
| 4825 | groupConnector[prologState.level] = ASCII_PIPE; | 5038 | parser->m_groupConnector[parser->m_prologState.level] = ASCII_PIPE; |
| 4826 | break; | 5039 | break; |
| 4827 | case XML_ROLE_PARAM_ENTITY_REF: | 5040 | case XML_ROLE_PARAM_ENTITY_REF: |
| 4828 | #ifdef XML_DTD | 5041 | #ifdef XML_DTD |
| 4829 | case XML_ROLE_INNER_PARAM_ENTITY_REF: | 5042 | case XML_ROLE_INNER_PARAM_ENTITY_REF: |
| 4830 | dtd->hasParamEntityRefs = XML_TRUE; | 5043 | dtd->hasParamEntityRefs = XML_TRUE; |
| 4831 | if (!paramEntityParsing) | 5044 | if (!parser->m_paramEntityParsing) |
| 4832 | dtd->keepProcessing = dtd->standalone; | 5045 | dtd->keepProcessing = dtd->standalone; |
| 4833 | else { | 5046 | else { |
| 4834 | const XML_Char *name; | 5047 | const XML_Char *name; |
| @@ -4844,20 +5057,41 @@ doProlog(XML_Parser parser, | |||
| 4844 | if yes, check that the entity exists, and that it is internal, | 5057 | if yes, check that the entity exists, and that it is internal, |
| 4845 | otherwise call the skipped entity handler | 5058 | otherwise call the skipped entity handler |
| 4846 | */ | 5059 | */ |
| 4847 | if (prologState.documentEntity && | 5060 | if (parser->m_prologState.documentEntity && |
| 4848 | (dtd->standalone | 5061 | (dtd->standalone |
| 4849 | ? !openInternalEntities | 5062 | ? !parser->m_openInternalEntities |
| 4850 | : !dtd->hasParamEntityRefs)) { | 5063 | : !dtd->hasParamEntityRefs)) { |
| 4851 | if (!entity) | 5064 | if (!entity) |
| 4852 | return XML_ERROR_UNDEFINED_ENTITY; | 5065 | return XML_ERROR_UNDEFINED_ENTITY; |
| 4853 | else if (!entity->is_internal) | 5066 | else if (!entity->is_internal) { |
| 4854 | return XML_ERROR_ENTITY_DECLARED_IN_PE; | 5067 | /* It's hard to exhaustively search the code to be sure, |
| 5068 | * but there doesn't seem to be a way of executing the | ||
| 5069 | * following line. There are two cases: | ||
| 5070 | * | ||
| 5071 | * If 'standalone' is false, the DTD must have no | ||
| 5072 | * parameter entities or we wouldn't have passed the outer | ||
| 5073 | * 'if' statement. That measn the only entity in the hash | ||
| 5074 | * table is the external subset name "#" which cannot be | ||
| 5075 | * given as a parameter entity name in XML syntax, so the | ||
| 5076 | * lookup must have returned NULL and we don't even reach | ||
| 5077 | * the test for an internal entity. | ||
| 5078 | * | ||
| 5079 | * If 'standalone' is true, it does not seem to be | ||
| 5080 | * possible to create entities taking this code path that | ||
| 5081 | * are not internal entities, so fail the test above. | ||
| 5082 | * | ||
| 5083 | * Because this analysis is very uncertain, the code is | ||
| 5084 | * being left in place and merely removed from the | ||
| 5085 | * coverage test statistics. | ||
| 5086 | */ | ||
| 5087 | return XML_ERROR_ENTITY_DECLARED_IN_PE; /* LCOV_EXCL_LINE */ | ||
| 5088 | } | ||
| 4855 | } | 5089 | } |
| 4856 | else if (!entity) { | 5090 | else if (!entity) { |
| 4857 | dtd->keepProcessing = dtd->standalone; | 5091 | dtd->keepProcessing = dtd->standalone; |
| 4858 | /* cannot report skipped entities in declarations */ | 5092 | /* cannot report skipped entities in declarations */ |
| 4859 | if ((role == XML_ROLE_PARAM_ENTITY_REF) && skippedEntityHandler) { | 5093 | if ((role == XML_ROLE_PARAM_ENTITY_REF) && parser->m_skippedEntityHandler) { |
| 4860 | skippedEntityHandler(handlerArg, name, 1); | 5094 | parser->m_skippedEntityHandler(parser->m_handlerArg, name, 1); |
| 4861 | handleDefault = XML_FALSE; | 5095 | handleDefault = XML_FALSE; |
| 4862 | } | 5096 | } |
| 4863 | break; | 5097 | break; |
| @@ -4874,10 +5108,10 @@ doProlog(XML_Parser parser, | |||
| 4874 | handleDefault = XML_FALSE; | 5108 | handleDefault = XML_FALSE; |
| 4875 | break; | 5109 | break; |
| 4876 | } | 5110 | } |
| 4877 | if (externalEntityRefHandler) { | 5111 | if (parser->m_externalEntityRefHandler) { |
| 4878 | dtd->paramEntityRead = XML_FALSE; | 5112 | dtd->paramEntityRead = XML_FALSE; |
| 4879 | entity->open = XML_TRUE; | 5113 | entity->open = XML_TRUE; |
| 4880 | if (!externalEntityRefHandler(externalEntityRefHandlerArg, | 5114 | if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, |
| 4881 | 0, | 5115 | 0, |
| 4882 | entity->base, | 5116 | entity->base, |
| 4883 | entity->systemId, | 5117 | entity->systemId, |
| @@ -4899,17 +5133,17 @@ doProlog(XML_Parser parser, | |||
| 4899 | } | 5133 | } |
| 4900 | #endif /* XML_DTD */ | 5134 | #endif /* XML_DTD */ |
| 4901 | if (!dtd->standalone && | 5135 | if (!dtd->standalone && |
| 4902 | notStandaloneHandler && | 5136 | parser->m_notStandaloneHandler && |
| 4903 | !notStandaloneHandler(handlerArg)) | 5137 | !parser->m_notStandaloneHandler(parser->m_handlerArg)) |
| 4904 | return XML_ERROR_NOT_STANDALONE; | 5138 | return XML_ERROR_NOT_STANDALONE; |
| 4905 | break; | 5139 | break; |
| 4906 | 5140 | ||
| 4907 | /* Element declaration stuff */ | 5141 | /* Element declaration stuff */ |
| 4908 | 5142 | ||
| 4909 | case XML_ROLE_ELEMENT_NAME: | 5143 | case XML_ROLE_ELEMENT_NAME: |
| 4910 | if (elementDeclHandler) { | 5144 | if (parser->m_elementDeclHandler) { |
| 4911 | declElementType = getElementType(parser, enc, s, next); | 5145 | parser->m_declElementType = getElementType(parser, enc, s, next); |
| 4912 | if (!declElementType) | 5146 | if (!parser->m_declElementType) |
| 4913 | return XML_ERROR_NO_MEMORY; | 5147 | return XML_ERROR_NO_MEMORY; |
| 4914 | dtd->scaffLevel = 0; | 5148 | dtd->scaffLevel = 0; |
| 4915 | dtd->scaffCount = 0; | 5149 | dtd->scaffCount = 0; |
| @@ -4921,8 +5155,8 @@ doProlog(XML_Parser parser, | |||
| 4921 | case XML_ROLE_CONTENT_ANY: | 5155 | case XML_ROLE_CONTENT_ANY: |
| 4922 | case XML_ROLE_CONTENT_EMPTY: | 5156 | case XML_ROLE_CONTENT_EMPTY: |
| 4923 | if (dtd->in_eldecl) { | 5157 | if (dtd->in_eldecl) { |
| 4924 | if (elementDeclHandler) { | 5158 | if (parser->m_elementDeclHandler) { |
| 4925 | XML_Content * content = (XML_Content *) MALLOC(sizeof(XML_Content)); | 5159 | XML_Content * content = (XML_Content *) MALLOC(parser, sizeof(XML_Content)); |
| 4926 | if (!content) | 5160 | if (!content) |
| 4927 | return XML_ERROR_NO_MEMORY; | 5161 | return XML_ERROR_NO_MEMORY; |
| 4928 | content->quant = XML_CQUANT_NONE; | 5162 | content->quant = XML_CQUANT_NONE; |
| @@ -4933,7 +5167,7 @@ doProlog(XML_Parser parser, | |||
| 4933 | XML_CTYPE_ANY : | 5167 | XML_CTYPE_ANY : |
| 4934 | XML_CTYPE_EMPTY); | 5168 | XML_CTYPE_EMPTY); |
| 4935 | *eventEndPP = s; | 5169 | *eventEndPP = s; |
| 4936 | elementDeclHandler(handlerArg, declElementType->name, content); | 5170 | parser->m_elementDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, content); |
| 4937 | handleDefault = XML_FALSE; | 5171 | handleDefault = XML_FALSE; |
| 4938 | } | 5172 | } |
| 4939 | dtd->in_eldecl = XML_FALSE; | 5173 | dtd->in_eldecl = XML_FALSE; |
| @@ -4944,7 +5178,7 @@ doProlog(XML_Parser parser, | |||
| 4944 | if (dtd->in_eldecl) { | 5178 | if (dtd->in_eldecl) { |
| 4945 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type | 5179 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel - 1]].type |
| 4946 | = XML_CTYPE_MIXED; | 5180 | = XML_CTYPE_MIXED; |
| 4947 | if (elementDeclHandler) | 5181 | if (parser->m_elementDeclHandler) |
| 4948 | handleDefault = XML_FALSE; | 5182 | handleDefault = XML_FALSE; |
| 4949 | } | 5183 | } |
| 4950 | break; | 5184 | break; |
| @@ -4981,7 +5215,7 @@ doProlog(XML_Parser parser, | |||
| 4981 | nameLen = 0; | 5215 | nameLen = 0; |
| 4982 | for (; name[nameLen++]; ); | 5216 | for (; name[nameLen++]; ); |
| 4983 | dtd->contentStringLen += nameLen; | 5217 | dtd->contentStringLen += nameLen; |
| 4984 | if (elementDeclHandler) | 5218 | if (parser->m_elementDeclHandler) |
| 4985 | handleDefault = XML_FALSE; | 5219 | handleDefault = XML_FALSE; |
| 4986 | } | 5220 | } |
| 4987 | break; | 5221 | break; |
| @@ -4999,7 +5233,7 @@ doProlog(XML_Parser parser, | |||
| 4999 | quant = XML_CQUANT_PLUS; | 5233 | quant = XML_CQUANT_PLUS; |
| 5000 | closeGroup: | 5234 | closeGroup: |
| 5001 | if (dtd->in_eldecl) { | 5235 | if (dtd->in_eldecl) { |
| 5002 | if (elementDeclHandler) | 5236 | if (parser->m_elementDeclHandler) |
| 5003 | handleDefault = XML_FALSE; | 5237 | handleDefault = XML_FALSE; |
| 5004 | dtd->scaffLevel--; | 5238 | dtd->scaffLevel--; |
| 5005 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; | 5239 | dtd->scaffold[dtd->scaffIndex[dtd->scaffLevel]].quant = quant; |
| @@ -5009,7 +5243,7 @@ doProlog(XML_Parser parser, | |||
| 5009 | if (!model) | 5243 | if (!model) |
| 5010 | return XML_ERROR_NO_MEMORY; | 5244 | return XML_ERROR_NO_MEMORY; |
| 5011 | *eventEndPP = s; | 5245 | *eventEndPP = s; |
| 5012 | elementDeclHandler(handlerArg, declElementType->name, model); | 5246 | parser->m_elementDeclHandler(parser->m_handlerArg, parser->m_declElementType->name, model); |
| 5013 | } | 5247 | } |
| 5014 | dtd->in_eldecl = XML_FALSE; | 5248 | dtd->in_eldecl = XML_FALSE; |
| 5015 | dtd->contentStringLen = 0; | 5249 | dtd->contentStringLen = 0; |
| @@ -5036,31 +5270,31 @@ doProlog(XML_Parser parser, | |||
| 5036 | } | 5270 | } |
| 5037 | break; | 5271 | break; |
| 5038 | case XML_ROLE_DOCTYPE_NONE: | 5272 | case XML_ROLE_DOCTYPE_NONE: |
| 5039 | if (startDoctypeDeclHandler) | 5273 | if (parser->m_startDoctypeDeclHandler) |
| 5040 | handleDefault = XML_FALSE; | 5274 | handleDefault = XML_FALSE; |
| 5041 | break; | 5275 | break; |
| 5042 | case XML_ROLE_ENTITY_NONE: | 5276 | case XML_ROLE_ENTITY_NONE: |
| 5043 | if (dtd->keepProcessing && entityDeclHandler) | 5277 | if (dtd->keepProcessing && parser->m_entityDeclHandler) |
| 5044 | handleDefault = XML_FALSE; | 5278 | handleDefault = XML_FALSE; |
| 5045 | break; | 5279 | break; |
| 5046 | case XML_ROLE_NOTATION_NONE: | 5280 | case XML_ROLE_NOTATION_NONE: |
| 5047 | if (notationDeclHandler) | 5281 | if (parser->m_notationDeclHandler) |
| 5048 | handleDefault = XML_FALSE; | 5282 | handleDefault = XML_FALSE; |
| 5049 | break; | 5283 | break; |
| 5050 | case XML_ROLE_ATTLIST_NONE: | 5284 | case XML_ROLE_ATTLIST_NONE: |
| 5051 | if (dtd->keepProcessing && attlistDeclHandler) | 5285 | if (dtd->keepProcessing && parser->m_attlistDeclHandler) |
| 5052 | handleDefault = XML_FALSE; | 5286 | handleDefault = XML_FALSE; |
| 5053 | break; | 5287 | break; |
| 5054 | case XML_ROLE_ELEMENT_NONE: | 5288 | case XML_ROLE_ELEMENT_NONE: |
| 5055 | if (elementDeclHandler) | 5289 | if (parser->m_elementDeclHandler) |
| 5056 | handleDefault = XML_FALSE; | 5290 | handleDefault = XML_FALSE; |
| 5057 | break; | 5291 | break; |
| 5058 | } /* end of big switch */ | 5292 | } /* end of big switch */ |
| 5059 | 5293 | ||
| 5060 | if (handleDefault && defaultHandler) | 5294 | if (handleDefault && parser->m_defaultHandler) |
| 5061 | reportDefault(parser, enc, s, next); | 5295 | reportDefault(parser, enc, s, next); |
| 5062 | 5296 | ||
| 5063 | switch (ps_parsing) { | 5297 | switch (parser->m_parsingStatus.parsing) { |
| 5064 | case XML_SUSPENDED: | 5298 | case XML_SUSPENDED: |
| 5065 | *nextPtr = next; | 5299 | *nextPtr = next; |
| 5066 | return XML_ERROR_NONE; | 5300 | return XML_ERROR_NONE; |
| @@ -5080,18 +5314,18 @@ epilogProcessor(XML_Parser parser, | |||
| 5080 | const char *end, | 5314 | const char *end, |
| 5081 | const char **nextPtr) | 5315 | const char **nextPtr) |
| 5082 | { | 5316 | { |
| 5083 | processor = epilogProcessor; | 5317 | parser->m_processor = epilogProcessor; |
| 5084 | eventPtr = s; | 5318 | parser->m_eventPtr = s; |
| 5085 | for (;;) { | 5319 | for (;;) { |
| 5086 | const char *next = NULL; | 5320 | const char *next = NULL; |
| 5087 | int tok = XmlPrologTok(encoding, s, end, &next); | 5321 | int tok = XmlPrologTok(parser->m_encoding, s, end, &next); |
| 5088 | eventEndPtr = next; | 5322 | parser->m_eventEndPtr = next; |
| 5089 | switch (tok) { | 5323 | switch (tok) { |
| 5090 | /* report partial linebreak - it might be the last token */ | 5324 | /* report partial linebreak - it might be the last token */ |
| 5091 | case -XML_TOK_PROLOG_S: | 5325 | case -XML_TOK_PROLOG_S: |
| 5092 | if (defaultHandler) { | 5326 | if (parser->m_defaultHandler) { |
| 5093 | reportDefault(parser, encoding, s, next); | 5327 | reportDefault(parser, parser->m_encoding, s, next); |
| 5094 | if (ps_parsing == XML_FINISHED) | 5328 | if (parser->m_parsingStatus.parsing == XML_FINISHED) |
| 5095 | return XML_ERROR_ABORTED; | 5329 | return XML_ERROR_ABORTED; |
| 5096 | } | 5330 | } |
| 5097 | *nextPtr = next; | 5331 | *nextPtr = next; |
| @@ -5100,28 +5334,28 @@ epilogProcessor(XML_Parser parser, | |||
| 5100 | *nextPtr = s; | 5334 | *nextPtr = s; |
| 5101 | return XML_ERROR_NONE; | 5335 | return XML_ERROR_NONE; |
| 5102 | case XML_TOK_PROLOG_S: | 5336 | case XML_TOK_PROLOG_S: |
| 5103 | if (defaultHandler) | 5337 | if (parser->m_defaultHandler) |
| 5104 | reportDefault(parser, encoding, s, next); | 5338 | reportDefault(parser, parser->m_encoding, s, next); |
| 5105 | break; | 5339 | break; |
| 5106 | case XML_TOK_PI: | 5340 | case XML_TOK_PI: |
| 5107 | if (!reportProcessingInstruction(parser, encoding, s, next)) | 5341 | if (!reportProcessingInstruction(parser, parser->m_encoding, s, next)) |
| 5108 | return XML_ERROR_NO_MEMORY; | 5342 | return XML_ERROR_NO_MEMORY; |
| 5109 | break; | 5343 | break; |
| 5110 | case XML_TOK_COMMENT: | 5344 | case XML_TOK_COMMENT: |
| 5111 | if (!reportComment(parser, encoding, s, next)) | 5345 | if (!reportComment(parser, parser->m_encoding, s, next)) |
| 5112 | return XML_ERROR_NO_MEMORY; | 5346 | return XML_ERROR_NO_MEMORY; |
| 5113 | break; | 5347 | break; |
| 5114 | case XML_TOK_INVALID: | 5348 | case XML_TOK_INVALID: |
| 5115 | eventPtr = next; | 5349 | parser->m_eventPtr = next; |
| 5116 | return XML_ERROR_INVALID_TOKEN; | 5350 | return XML_ERROR_INVALID_TOKEN; |
| 5117 | case XML_TOK_PARTIAL: | 5351 | case XML_TOK_PARTIAL: |
| 5118 | if (!ps_finalBuffer) { | 5352 | if (!parser->m_parsingStatus.finalBuffer) { |
| 5119 | *nextPtr = s; | 5353 | *nextPtr = s; |
| 5120 | return XML_ERROR_NONE; | 5354 | return XML_ERROR_NONE; |
| 5121 | } | 5355 | } |
| 5122 | return XML_ERROR_UNCLOSED_TOKEN; | 5356 | return XML_ERROR_UNCLOSED_TOKEN; |
| 5123 | case XML_TOK_PARTIAL_CHAR: | 5357 | case XML_TOK_PARTIAL_CHAR: |
| 5124 | if (!ps_finalBuffer) { | 5358 | if (!parser->m_parsingStatus.finalBuffer) { |
| 5125 | *nextPtr = s; | 5359 | *nextPtr = s; |
| 5126 | return XML_ERROR_NONE; | 5360 | return XML_ERROR_NONE; |
| 5127 | } | 5361 | } |
| @@ -5129,8 +5363,8 @@ epilogProcessor(XML_Parser parser, | |||
| 5129 | default: | 5363 | default: |
| 5130 | return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; | 5364 | return XML_ERROR_JUNK_AFTER_DOC_ELEMENT; |
| 5131 | } | 5365 | } |
| 5132 | eventPtr = s = next; | 5366 | parser->m_eventPtr = s = next; |
| 5133 | switch (ps_parsing) { | 5367 | switch (parser->m_parsingStatus.parsing) { |
| 5134 | case XML_SUSPENDED: | 5368 | case XML_SUSPENDED: |
| 5135 | *nextPtr = next; | 5369 | *nextPtr = next; |
| 5136 | return XML_ERROR_NONE; | 5370 | return XML_ERROR_NONE; |
| @@ -5150,21 +5384,21 @@ processInternalEntity(XML_Parser parser, ENTITY *entity, | |||
| 5150 | enum XML_Error result; | 5384 | enum XML_Error result; |
| 5151 | OPEN_INTERNAL_ENTITY *openEntity; | 5385 | OPEN_INTERNAL_ENTITY *openEntity; |
| 5152 | 5386 | ||
| 5153 | if (freeInternalEntities) { | 5387 | if (parser->m_freeInternalEntities) { |
| 5154 | openEntity = freeInternalEntities; | 5388 | openEntity = parser->m_freeInternalEntities; |
| 5155 | freeInternalEntities = openEntity->next; | 5389 | parser->m_freeInternalEntities = openEntity->next; |
| 5156 | } | 5390 | } |
| 5157 | else { | 5391 | else { |
| 5158 | openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(sizeof(OPEN_INTERNAL_ENTITY)); | 5392 | openEntity = (OPEN_INTERNAL_ENTITY *)MALLOC(parser, sizeof(OPEN_INTERNAL_ENTITY)); |
| 5159 | if (!openEntity) | 5393 | if (!openEntity) |
| 5160 | return XML_ERROR_NO_MEMORY; | 5394 | return XML_ERROR_NO_MEMORY; |
| 5161 | } | 5395 | } |
| 5162 | entity->open = XML_TRUE; | 5396 | entity->open = XML_TRUE; |
| 5163 | entity->processed = 0; | 5397 | entity->processed = 0; |
| 5164 | openEntity->next = openInternalEntities; | 5398 | openEntity->next = parser->m_openInternalEntities; |
| 5165 | openInternalEntities = openEntity; | 5399 | parser->m_openInternalEntities = openEntity; |
| 5166 | openEntity->entity = entity; | 5400 | openEntity->entity = entity; |
| 5167 | openEntity->startTagLevel = tagLevel; | 5401 | openEntity->startTagLevel = parser->m_tagLevel; |
| 5168 | openEntity->betweenDecl = betweenDecl; | 5402 | openEntity->betweenDecl = betweenDecl; |
| 5169 | openEntity->internalEventPtr = NULL; | 5403 | openEntity->internalEventPtr = NULL; |
| 5170 | openEntity->internalEventEndPtr = NULL; | 5404 | openEntity->internalEventEndPtr = NULL; |
| @@ -5175,26 +5409,26 @@ processInternalEntity(XML_Parser parser, ENTITY *entity, | |||
| 5175 | 5409 | ||
| 5176 | #ifdef XML_DTD | 5410 | #ifdef XML_DTD |
| 5177 | if (entity->is_param) { | 5411 | if (entity->is_param) { |
| 5178 | int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | 5412 | int tok = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); |
| 5179 | result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | 5413 | result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, tok, |
| 5180 | next, &next, XML_FALSE); | 5414 | next, &next, XML_FALSE); |
| 5181 | } | 5415 | } |
| 5182 | else | 5416 | else |
| 5183 | #endif /* XML_DTD */ | 5417 | #endif /* XML_DTD */ |
| 5184 | result = doContent(parser, tagLevel, internalEncoding, textStart, | 5418 | result = doContent(parser, parser->m_tagLevel, parser->m_internalEncoding, textStart, |
| 5185 | textEnd, &next, XML_FALSE); | 5419 | textEnd, &next, XML_FALSE); |
| 5186 | 5420 | ||
| 5187 | if (result == XML_ERROR_NONE) { | 5421 | if (result == XML_ERROR_NONE) { |
| 5188 | if (textEnd != next && ps_parsing == XML_SUSPENDED) { | 5422 | if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) { |
| 5189 | entity->processed = (int)(next - textStart); | 5423 | entity->processed = (int)(next - textStart); |
| 5190 | processor = internalEntityProcessor; | 5424 | parser->m_processor = internalEntityProcessor; |
| 5191 | } | 5425 | } |
| 5192 | else { | 5426 | else { |
| 5193 | entity->open = XML_FALSE; | 5427 | entity->open = XML_FALSE; |
| 5194 | openInternalEntities = openEntity->next; | 5428 | parser->m_openInternalEntities = openEntity->next; |
| 5195 | /* put openEntity back in list of free instances */ | 5429 | /* put openEntity back in list of free instances */ |
| 5196 | openEntity->next = freeInternalEntities; | 5430 | openEntity->next = parser->m_freeInternalEntities; |
| 5197 | freeInternalEntities = openEntity; | 5431 | parser->m_freeInternalEntities = openEntity; |
| 5198 | } | 5432 | } |
| 5199 | } | 5433 | } |
| 5200 | return result; | 5434 | return result; |
| @@ -5210,7 +5444,7 @@ internalEntityProcessor(XML_Parser parser, | |||
| 5210 | const char *textStart, *textEnd; | 5444 | const char *textStart, *textEnd; |
| 5211 | const char *next; | 5445 | const char *next; |
| 5212 | enum XML_Error result; | 5446 | enum XML_Error result; |
| 5213 | OPEN_INTERNAL_ENTITY *openEntity = openInternalEntities; | 5447 | OPEN_INTERNAL_ENTITY *openEntity = parser->m_openInternalEntities; |
| 5214 | if (!openEntity) | 5448 | if (!openEntity) |
| 5215 | return XML_ERROR_UNEXPECTED_STATE; | 5449 | return XML_ERROR_UNEXPECTED_STATE; |
| 5216 | 5450 | ||
| @@ -5222,44 +5456,44 @@ internalEntityProcessor(XML_Parser parser, | |||
| 5222 | 5456 | ||
| 5223 | #ifdef XML_DTD | 5457 | #ifdef XML_DTD |
| 5224 | if (entity->is_param) { | 5458 | if (entity->is_param) { |
| 5225 | int tok = XmlPrologTok(internalEncoding, textStart, textEnd, &next); | 5459 | int tok = XmlPrologTok(parser->m_internalEncoding, textStart, textEnd, &next); |
| 5226 | result = doProlog(parser, internalEncoding, textStart, textEnd, tok, | 5460 | result = doProlog(parser, parser->m_internalEncoding, textStart, textEnd, tok, |
| 5227 | next, &next, XML_FALSE); | 5461 | next, &next, XML_FALSE); |
| 5228 | } | 5462 | } |
| 5229 | else | 5463 | else |
| 5230 | #endif /* XML_DTD */ | 5464 | #endif /* XML_DTD */ |
| 5231 | result = doContent(parser, openEntity->startTagLevel, internalEncoding, | 5465 | result = doContent(parser, openEntity->startTagLevel, parser->m_internalEncoding, |
| 5232 | textStart, textEnd, &next, XML_FALSE); | 5466 | textStart, textEnd, &next, XML_FALSE); |
| 5233 | 5467 | ||
| 5234 | if (result != XML_ERROR_NONE) | 5468 | if (result != XML_ERROR_NONE) |
| 5235 | return result; | 5469 | return result; |
| 5236 | else if (textEnd != next && ps_parsing == XML_SUSPENDED) { | 5470 | else if (textEnd != next && parser->m_parsingStatus.parsing == XML_SUSPENDED) { |
| 5237 | entity->processed = (int)(next - (char *)entity->textPtr); | 5471 | entity->processed = (int)(next - (char *)entity->textPtr); |
| 5238 | return result; | 5472 | return result; |
| 5239 | } | 5473 | } |
| 5240 | else { | 5474 | else { |
| 5241 | entity->open = XML_FALSE; | 5475 | entity->open = XML_FALSE; |
| 5242 | openInternalEntities = openEntity->next; | 5476 | parser->m_openInternalEntities = openEntity->next; |
| 5243 | /* put openEntity back in list of free instances */ | 5477 | /* put openEntity back in list of free instances */ |
| 5244 | openEntity->next = freeInternalEntities; | 5478 | openEntity->next = parser->m_freeInternalEntities; |
| 5245 | freeInternalEntities = openEntity; | 5479 | parser->m_freeInternalEntities = openEntity; |
| 5246 | } | 5480 | } |
| 5247 | 5481 | ||
| 5248 | #ifdef XML_DTD | 5482 | #ifdef XML_DTD |
| 5249 | if (entity->is_param) { | 5483 | if (entity->is_param) { |
| 5250 | int tok; | 5484 | int tok; |
| 5251 | processor = prologProcessor; | 5485 | parser->m_processor = prologProcessor; |
| 5252 | tok = XmlPrologTok(encoding, s, end, &next); | 5486 | tok = XmlPrologTok(parser->m_encoding, s, end, &next); |
| 5253 | return doProlog(parser, encoding, s, end, tok, next, nextPtr, | 5487 | return doProlog(parser, parser->m_encoding, s, end, tok, next, nextPtr, |
| 5254 | (XML_Bool)!ps_finalBuffer); | 5488 | (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 5255 | } | 5489 | } |
| 5256 | else | 5490 | else |
| 5257 | #endif /* XML_DTD */ | 5491 | #endif /* XML_DTD */ |
| 5258 | { | 5492 | { |
| 5259 | processor = contentProcessor; | 5493 | parser->m_processor = contentProcessor; |
| 5260 | /* see externalEntityContentProcessor vs contentProcessor */ | 5494 | /* see externalEntityContentProcessor vs contentProcessor */ |
| 5261 | return doContent(parser, parentParser ? 1 : 0, encoding, s, end, | 5495 | return doContent(parser, parser->m_parentParser ? 1 : 0, parser->m_encoding, s, end, |
| 5262 | nextPtr, (XML_Bool)!ps_finalBuffer); | 5496 | nextPtr, (XML_Bool)!parser->m_parsingStatus.finalBuffer); |
| 5263 | } | 5497 | } |
| 5264 | } | 5498 | } |
| 5265 | 5499 | ||
| @@ -5269,7 +5503,7 @@ errorProcessor(XML_Parser parser, | |||
| 5269 | const char *UNUSED_P(end), | 5503 | const char *UNUSED_P(end), |
| 5270 | const char **UNUSED_P(nextPtr)) | 5504 | const char **UNUSED_P(nextPtr)) |
| 5271 | { | 5505 | { |
| 5272 | return errorCode; | 5506 | return parser->m_errorCode; |
| 5273 | } | 5507 | } |
| 5274 | 5508 | ||
| 5275 | static enum XML_Error | 5509 | static enum XML_Error |
| @@ -5293,7 +5527,7 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5293 | const char *ptr, const char *end, | 5527 | const char *ptr, const char *end, |
| 5294 | STRING_POOL *pool) | 5528 | STRING_POOL *pool) |
| 5295 | { | 5529 | { |
| 5296 | DTD * const dtd = _dtd; /* save one level of indirection */ | 5530 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5297 | for (;;) { | 5531 | for (;;) { |
| 5298 | const char *next; | 5532 | const char *next; |
| 5299 | int tok = XmlAttributeValueTok(enc, ptr, end, &next); | 5533 | int tok = XmlAttributeValueTok(enc, ptr, end, &next); |
| @@ -5301,12 +5535,12 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5301 | case XML_TOK_NONE: | 5535 | case XML_TOK_NONE: |
| 5302 | return XML_ERROR_NONE; | 5536 | return XML_ERROR_NONE; |
| 5303 | case XML_TOK_INVALID: | 5537 | case XML_TOK_INVALID: |
| 5304 | if (enc == encoding) | 5538 | if (enc == parser->m_encoding) |
| 5305 | eventPtr = next; | 5539 | parser->m_eventPtr = next; |
| 5306 | return XML_ERROR_INVALID_TOKEN; | 5540 | return XML_ERROR_INVALID_TOKEN; |
| 5307 | case XML_TOK_PARTIAL: | 5541 | case XML_TOK_PARTIAL: |
| 5308 | if (enc == encoding) | 5542 | if (enc == parser->m_encoding) |
| 5309 | eventPtr = ptr; | 5543 | parser->m_eventPtr = ptr; |
| 5310 | return XML_ERROR_INVALID_TOKEN; | 5544 | return XML_ERROR_INVALID_TOKEN; |
| 5311 | case XML_TOK_CHAR_REF: | 5545 | case XML_TOK_CHAR_REF: |
| 5312 | { | 5546 | { |
| @@ -5314,8 +5548,8 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5314 | int i; | 5548 | int i; |
| 5315 | int n = XmlCharRefNumber(enc, ptr); | 5549 | int n = XmlCharRefNumber(enc, ptr); |
| 5316 | if (n < 0) { | 5550 | if (n < 0) { |
| 5317 | if (enc == encoding) | 5551 | if (enc == parser->m_encoding) |
| 5318 | eventPtr = ptr; | 5552 | parser->m_eventPtr = ptr; |
| 5319 | return XML_ERROR_BAD_CHAR_REF; | 5553 | return XML_ERROR_BAD_CHAR_REF; |
| 5320 | } | 5554 | } |
| 5321 | if (!isCdata | 5555 | if (!isCdata |
| @@ -5323,11 +5557,15 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5323 | && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) | 5557 | && (poolLength(pool) == 0 || poolLastChar(pool) == 0x20)) |
| 5324 | break; | 5558 | break; |
| 5325 | n = XmlEncode(n, (ICHAR *)buf); | 5559 | n = XmlEncode(n, (ICHAR *)buf); |
| 5326 | if (!n) { | 5560 | /* The XmlEncode() functions can never return 0 here. That |
| 5327 | if (enc == encoding) | 5561 | * error return happens if the code point passed in is either |
| 5328 | eventPtr = ptr; | 5562 | * negative or greater than or equal to 0x110000. The |
| 5329 | return XML_ERROR_BAD_CHAR_REF; | 5563 | * XmlCharRefNumber() functions will all return a number |
| 5330 | } | 5564 | * strictly less than 0x110000 or a negative value if an error |
| 5565 | * occurred. The negative value is intercepted above, so | ||
| 5566 | * XmlEncode() is never passed a value it might return an | ||
| 5567 | * error for. | ||
| 5568 | */ | ||
| 5331 | for (i = 0; i < n; i++) { | 5569 | for (i = 0; i < n; i++) { |
| 5332 | if (!poolAppendChar(pool, buf[i])) | 5570 | if (!poolAppendChar(pool, buf[i])) |
| 5333 | return XML_ERROR_NO_MEMORY; | 5571 | return XML_ERROR_NO_MEMORY; |
| @@ -5361,25 +5599,25 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5361 | return XML_ERROR_NO_MEMORY; | 5599 | return XML_ERROR_NO_MEMORY; |
| 5362 | break; | 5600 | break; |
| 5363 | } | 5601 | } |
| 5364 | name = poolStoreString(&temp2Pool, enc, | 5602 | name = poolStoreString(&parser->m_temp2Pool, enc, |
| 5365 | ptr + enc->minBytesPerChar, | 5603 | ptr + enc->minBytesPerChar, |
| 5366 | next - enc->minBytesPerChar); | 5604 | next - enc->minBytesPerChar); |
| 5367 | if (!name) | 5605 | if (!name) |
| 5368 | return XML_ERROR_NO_MEMORY; | 5606 | return XML_ERROR_NO_MEMORY; |
| 5369 | entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); | 5607 | entity = (ENTITY *)lookup(parser, &dtd->generalEntities, name, 0); |
| 5370 | poolDiscard(&temp2Pool); | 5608 | poolDiscard(&parser->m_temp2Pool); |
| 5371 | /* First, determine if a check for an existing declaration is needed; | 5609 | /* First, determine if a check for an existing declaration is needed; |
| 5372 | if yes, check that the entity exists, and that it is internal. | 5610 | if yes, check that the entity exists, and that it is internal. |
| 5373 | */ | 5611 | */ |
| 5374 | if (pool == &dtd->pool) /* are we called from prolog? */ | 5612 | if (pool == &dtd->pool) /* are we called from prolog? */ |
| 5375 | checkEntityDecl = | 5613 | checkEntityDecl = |
| 5376 | #ifdef XML_DTD | 5614 | #ifdef XML_DTD |
| 5377 | prologState.documentEntity && | 5615 | parser->m_prologState.documentEntity && |
| 5378 | #endif /* XML_DTD */ | 5616 | #endif /* XML_DTD */ |
| 5379 | (dtd->standalone | 5617 | (dtd->standalone |
| 5380 | ? !openInternalEntities | 5618 | ? !parser->m_openInternalEntities |
| 5381 | : !dtd->hasParamEntityRefs); | 5619 | : !dtd->hasParamEntityRefs); |
| 5382 | else /* if (pool == &tempPool): we are called from content */ | 5620 | else /* if (pool == &parser->m_tempPool): we are called from content */ |
| 5383 | checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; | 5621 | checkEntityDecl = !dtd->hasParamEntityRefs || dtd->standalone; |
| 5384 | if (checkEntityDecl) { | 5622 | if (checkEntityDecl) { |
| 5385 | if (!entity) | 5623 | if (!entity) |
| @@ -5389,37 +5627,55 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5389 | } | 5627 | } |
| 5390 | else if (!entity) { | 5628 | else if (!entity) { |
| 5391 | /* Cannot report skipped entity here - see comments on | 5629 | /* Cannot report skipped entity here - see comments on |
| 5392 | skippedEntityHandler. | 5630 | parser->m_skippedEntityHandler. |
| 5393 | if (skippedEntityHandler) | 5631 | if (parser->m_skippedEntityHandler) |
| 5394 | skippedEntityHandler(handlerArg, name, 0); | 5632 | parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); |
| 5395 | */ | 5633 | */ |
| 5396 | /* Cannot call the default handler because this would be | 5634 | /* Cannot call the default handler because this would be |
| 5397 | out of sync with the call to the startElementHandler. | 5635 | out of sync with the call to the startElementHandler. |
| 5398 | if ((pool == &tempPool) && defaultHandler) | 5636 | if ((pool == &parser->m_tempPool) && parser->m_defaultHandler) |
| 5399 | reportDefault(parser, enc, ptr, next); | 5637 | reportDefault(parser, enc, ptr, next); |
| 5400 | */ | 5638 | */ |
| 5401 | break; | 5639 | break; |
| 5402 | } | 5640 | } |
| 5403 | if (entity->open) { | 5641 | if (entity->open) { |
| 5404 | if (enc == encoding) | 5642 | if (enc == parser->m_encoding) { |
| 5405 | eventPtr = ptr; | 5643 | /* It does not appear that this line can be executed. |
| 5644 | * | ||
| 5645 | * The "if (entity->open)" check catches recursive entity | ||
| 5646 | * definitions. In order to be called with an open | ||
| 5647 | * entity, it must have gone through this code before and | ||
| 5648 | * been through the recursive call to | ||
| 5649 | * appendAttributeValue() some lines below. That call | ||
| 5650 | * sets the local encoding ("enc") to the parser's | ||
| 5651 | * internal encoding (internal_utf8 or internal_utf16), | ||
| 5652 | * which can never be the same as the principle encoding. | ||
| 5653 | * It doesn't appear there is another code path that gets | ||
| 5654 | * here with entity->open being TRUE. | ||
| 5655 | * | ||
| 5656 | * Since it is not certain that this logic is watertight, | ||
| 5657 | * we keep the line and merely exclude it from coverage | ||
| 5658 | * tests. | ||
| 5659 | */ | ||
| 5660 | parser->m_eventPtr = ptr; /* LCOV_EXCL_LINE */ | ||
| 5661 | } | ||
| 5406 | return XML_ERROR_RECURSIVE_ENTITY_REF; | 5662 | return XML_ERROR_RECURSIVE_ENTITY_REF; |
| 5407 | } | 5663 | } |
| 5408 | if (entity->notation) { | 5664 | if (entity->notation) { |
| 5409 | if (enc == encoding) | 5665 | if (enc == parser->m_encoding) |
| 5410 | eventPtr = ptr; | 5666 | parser->m_eventPtr = ptr; |
| 5411 | return XML_ERROR_BINARY_ENTITY_REF; | 5667 | return XML_ERROR_BINARY_ENTITY_REF; |
| 5412 | } | 5668 | } |
| 5413 | if (!entity->textPtr) { | 5669 | if (!entity->textPtr) { |
| 5414 | if (enc == encoding) | 5670 | if (enc == parser->m_encoding) |
| 5415 | eventPtr = ptr; | 5671 | parser->m_eventPtr = ptr; |
| 5416 | return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; | 5672 | return XML_ERROR_ATTRIBUTE_EXTERNAL_ENTITY_REF; |
| 5417 | } | 5673 | } |
| 5418 | else { | 5674 | else { |
| 5419 | enum XML_Error result; | 5675 | enum XML_Error result; |
| 5420 | const XML_Char *textEnd = entity->textPtr + entity->textLen; | 5676 | const XML_Char *textEnd = entity->textPtr + entity->textLen; |
| 5421 | entity->open = XML_TRUE; | 5677 | entity->open = XML_TRUE; |
| 5422 | result = appendAttributeValue(parser, internalEncoding, isCdata, | 5678 | result = appendAttributeValue(parser, parser->m_internalEncoding, isCdata, |
| 5423 | (char *)entity->textPtr, | 5679 | (char *)entity->textPtr, |
| 5424 | (char *)textEnd, pool); | 5680 | (char *)textEnd, pool); |
| 5425 | entity->open = XML_FALSE; | 5681 | entity->open = XML_FALSE; |
| @@ -5429,9 +5685,21 @@ appendAttributeValue(XML_Parser parser, const ENCODING *enc, XML_Bool isCdata, | |||
| 5429 | } | 5685 | } |
| 5430 | break; | 5686 | break; |
| 5431 | default: | 5687 | default: |
| 5432 | if (enc == encoding) | 5688 | /* The only token returned by XmlAttributeValueTok() that does |
| 5433 | eventPtr = ptr; | 5689 | * not have an explicit case here is XML_TOK_PARTIAL_CHAR. |
| 5690 | * Getting that would require an entity name to contain an | ||
| 5691 | * incomplete XML character (e.g. \xE2\x82); however previous | ||
| 5692 | * tokenisers will have already recognised and rejected such | ||
| 5693 | * names before XmlAttributeValueTok() gets a look-in. This | ||
| 5694 | * default case should be retained as a safety net, but the code | ||
| 5695 | * excluded from coverage tests. | ||
| 5696 | * | ||
| 5697 | * LCOV_EXCL_START | ||
| 5698 | */ | ||
| 5699 | if (enc == parser->m_encoding) | ||
| 5700 | parser->m_eventPtr = ptr; | ||
| 5434 | return XML_ERROR_UNEXPECTED_STATE; | 5701 | return XML_ERROR_UNEXPECTED_STATE; |
| 5702 | /* LCOV_EXCL_STOP */ | ||
| 5435 | } | 5703 | } |
| 5436 | ptr = next; | 5704 | ptr = next; |
| 5437 | } | 5705 | } |
| @@ -5444,12 +5712,12 @@ storeEntityValue(XML_Parser parser, | |||
| 5444 | const char *entityTextPtr, | 5712 | const char *entityTextPtr, |
| 5445 | const char *entityTextEnd) | 5713 | const char *entityTextEnd) |
| 5446 | { | 5714 | { |
| 5447 | DTD * const dtd = _dtd; /* save one level of indirection */ | 5715 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5448 | STRING_POOL *pool = &(dtd->entityValuePool); | 5716 | STRING_POOL *pool = &(dtd->entityValuePool); |
| 5449 | enum XML_Error result = XML_ERROR_NONE; | 5717 | enum XML_Error result = XML_ERROR_NONE; |
| 5450 | #ifdef XML_DTD | 5718 | #ifdef XML_DTD |
| 5451 | int oldInEntityValue = prologState.inEntityValue; | 5719 | int oldInEntityValue = parser->m_prologState.inEntityValue; |
| 5452 | prologState.inEntityValue = 1; | 5720 | parser->m_prologState.inEntityValue = 1; |
| 5453 | #endif /* XML_DTD */ | 5721 | #endif /* XML_DTD */ |
| 5454 | /* never return Null for the value argument in EntityDeclHandler, | 5722 | /* never return Null for the value argument in EntityDeclHandler, |
| 5455 | since this would indicate an external entity; therefore we | 5723 | since this would indicate an external entity; therefore we |
| @@ -5465,10 +5733,10 @@ storeEntityValue(XML_Parser parser, | |||
| 5465 | switch (tok) { | 5733 | switch (tok) { |
| 5466 | case XML_TOK_PARAM_ENTITY_REF: | 5734 | case XML_TOK_PARAM_ENTITY_REF: |
| 5467 | #ifdef XML_DTD | 5735 | #ifdef XML_DTD |
| 5468 | if (isParamEntity || enc != encoding) { | 5736 | if (parser->m_isParamEntity || enc != parser->m_encoding) { |
| 5469 | const XML_Char *name; | 5737 | const XML_Char *name; |
| 5470 | ENTITY *entity; | 5738 | ENTITY *entity; |
| 5471 | name = poolStoreString(&tempPool, enc, | 5739 | name = poolStoreString(&parser->m_tempPool, enc, |
| 5472 | entityTextPtr + enc->minBytesPerChar, | 5740 | entityTextPtr + enc->minBytesPerChar, |
| 5473 | next - enc->minBytesPerChar); | 5741 | next - enc->minBytesPerChar); |
| 5474 | if (!name) { | 5742 | if (!name) { |
| @@ -5476,28 +5744,28 @@ storeEntityValue(XML_Parser parser, | |||
| 5476 | goto endEntityValue; | 5744 | goto endEntityValue; |
| 5477 | } | 5745 | } |
| 5478 | entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); | 5746 | entity = (ENTITY *)lookup(parser, &dtd->paramEntities, name, 0); |
| 5479 | poolDiscard(&tempPool); | 5747 | poolDiscard(&parser->m_tempPool); |
| 5480 | if (!entity) { | 5748 | if (!entity) { |
| 5481 | /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ | 5749 | /* not a well-formedness error - see XML 1.0: WFC Entity Declared */ |
| 5482 | /* cannot report skipped entity here - see comments on | 5750 | /* cannot report skipped entity here - see comments on |
| 5483 | skippedEntityHandler | 5751 | parser->m_skippedEntityHandler |
| 5484 | if (skippedEntityHandler) | 5752 | if (parser->m_skippedEntityHandler) |
| 5485 | skippedEntityHandler(handlerArg, name, 0); | 5753 | parser->m_skippedEntityHandler(parser->m_handlerArg, name, 0); |
| 5486 | */ | 5754 | */ |
| 5487 | dtd->keepProcessing = dtd->standalone; | 5755 | dtd->keepProcessing = dtd->standalone; |
| 5488 | goto endEntityValue; | 5756 | goto endEntityValue; |
| 5489 | } | 5757 | } |
| 5490 | if (entity->open) { | 5758 | if (entity->open) { |
| 5491 | if (enc == encoding) | 5759 | if (enc == parser->m_encoding) |
| 5492 | eventPtr = entityTextPtr; | 5760 | parser->m_eventPtr = entityTextPtr; |
| 5493 | result = XML_ERROR_RECURSIVE_ENTITY_REF; | 5761 | result = XML_ERROR_RECURSIVE_ENTITY_REF; |
| 5494 | goto endEntityValue; | 5762 | goto endEntityValue; |
| 5495 | } | 5763 | } |
| 5496 | if (entity->systemId) { | 5764 | if (entity->systemId) { |
| 5497 | if (externalEntityRefHandler) { | 5765 | if (parser->m_externalEntityRefHandler) { |
| 5498 | dtd->paramEntityRead = XML_FALSE; | 5766 | dtd->paramEntityRead = XML_FALSE; |
| 5499 | entity->open = XML_TRUE; | 5767 | entity->open = XML_TRUE; |
| 5500 | if (!externalEntityRefHandler(externalEntityRefHandlerArg, | 5768 | if (!parser->m_externalEntityRefHandler(parser->m_externalEntityRefHandlerArg, |
| 5501 | 0, | 5769 | 0, |
| 5502 | entity->base, | 5770 | entity->base, |
| 5503 | entity->systemId, | 5771 | entity->systemId, |
| @@ -5516,7 +5784,7 @@ storeEntityValue(XML_Parser parser, | |||
| 5516 | else { | 5784 | else { |
| 5517 | entity->open = XML_TRUE; | 5785 | entity->open = XML_TRUE; |
| 5518 | result = storeEntityValue(parser, | 5786 | result = storeEntityValue(parser, |
| 5519 | internalEncoding, | 5787 | parser->m_internalEncoding, |
| 5520 | (char *)entity->textPtr, | 5788 | (char *)entity->textPtr, |
| 5521 | (char *)(entity->textPtr | 5789 | (char *)(entity->textPtr |
| 5522 | + entity->textLen)); | 5790 | + entity->textLen)); |
| @@ -5529,7 +5797,7 @@ storeEntityValue(XML_Parser parser, | |||
| 5529 | #endif /* XML_DTD */ | 5797 | #endif /* XML_DTD */ |
| 5530 | /* In the internal subset, PE references are not legal | 5798 | /* In the internal subset, PE references are not legal |
| 5531 | within markup declarations, e.g entity values in this case. */ | 5799 | within markup declarations, e.g entity values in this case. */ |
| 5532 | eventPtr = entityTextPtr; | 5800 | parser->m_eventPtr = entityTextPtr; |
| 5533 | result = XML_ERROR_PARAM_ENTITY_REF; | 5801 | result = XML_ERROR_PARAM_ENTITY_REF; |
| 5534 | goto endEntityValue; | 5802 | goto endEntityValue; |
| 5535 | case XML_TOK_NONE: | 5803 | case XML_TOK_NONE: |
| @@ -5558,18 +5826,21 @@ storeEntityValue(XML_Parser parser, | |||
| 5558 | int i; | 5826 | int i; |
| 5559 | int n = XmlCharRefNumber(enc, entityTextPtr); | 5827 | int n = XmlCharRefNumber(enc, entityTextPtr); |
| 5560 | if (n < 0) { | 5828 | if (n < 0) { |
| 5561 | if (enc == encoding) | 5829 | if (enc == parser->m_encoding) |
| 5562 | eventPtr = entityTextPtr; | 5830 | parser->m_eventPtr = entityTextPtr; |
| 5563 | result = XML_ERROR_BAD_CHAR_REF; | 5831 | result = XML_ERROR_BAD_CHAR_REF; |
| 5564 | goto endEntityValue; | 5832 | goto endEntityValue; |
| 5565 | } | 5833 | } |
| 5566 | n = XmlEncode(n, (ICHAR *)buf); | 5834 | n = XmlEncode(n, (ICHAR *)buf); |
| 5567 | if (!n) { | 5835 | /* The XmlEncode() functions can never return 0 here. That |
| 5568 | if (enc == encoding) | 5836 | * error return happens if the code point passed in is either |
| 5569 | eventPtr = entityTextPtr; | 5837 | * negative or greater than or equal to 0x110000. The |
| 5570 | result = XML_ERROR_BAD_CHAR_REF; | 5838 | * XmlCharRefNumber() functions will all return a number |
| 5571 | goto endEntityValue; | 5839 | * strictly less than 0x110000 or a negative value if an error |
| 5572 | } | 5840 | * occurred. The negative value is intercepted above, so |
| 5841 | * XmlEncode() is never passed a value it might return an | ||
| 5842 | * error for. | ||
| 5843 | */ | ||
| 5573 | for (i = 0; i < n; i++) { | 5844 | for (i = 0; i < n; i++) { |
| 5574 | if (pool->end == pool->ptr && !poolGrow(pool)) { | 5845 | if (pool->end == pool->ptr && !poolGrow(pool)) { |
| 5575 | result = XML_ERROR_NO_MEMORY; | 5846 | result = XML_ERROR_NO_MEMORY; |
| @@ -5580,26 +5851,34 @@ storeEntityValue(XML_Parser parser, | |||
| 5580 | } | 5851 | } |
| 5581 | break; | 5852 | break; |
| 5582 | case XML_TOK_PARTIAL: | 5853 | case XML_TOK_PARTIAL: |
| 5583 | if (enc == encoding) | 5854 | if (enc == parser->m_encoding) |
| 5584 | eventPtr = entityTextPtr; | 5855 | parser->m_eventPtr = entityTextPtr; |
| 5585 | result = XML_ERROR_INVALID_TOKEN; | 5856 | result = XML_ERROR_INVALID_TOKEN; |
| 5586 | goto endEntityValue; | 5857 | goto endEntityValue; |
| 5587 | case XML_TOK_INVALID: | 5858 | case XML_TOK_INVALID: |
| 5588 | if (enc == encoding) | 5859 | if (enc == parser->m_encoding) |
| 5589 | eventPtr = next; | 5860 | parser->m_eventPtr = next; |
| 5590 | result = XML_ERROR_INVALID_TOKEN; | 5861 | result = XML_ERROR_INVALID_TOKEN; |
| 5591 | goto endEntityValue; | 5862 | goto endEntityValue; |
| 5592 | default: | 5863 | default: |
| 5593 | if (enc == encoding) | 5864 | /* This default case should be unnecessary -- all the tokens |
| 5594 | eventPtr = entityTextPtr; | 5865 | * that XmlEntityValueTok() can return have their own explicit |
| 5866 | * cases -- but should be retained for safety. We do however | ||
| 5867 | * exclude it from the coverage statistics. | ||
| 5868 | * | ||
| 5869 | * LCOV_EXCL_START | ||
| 5870 | */ | ||
| 5871 | if (enc == parser->m_encoding) | ||
| 5872 | parser->m_eventPtr = entityTextPtr; | ||
| 5595 | result = XML_ERROR_UNEXPECTED_STATE; | 5873 | result = XML_ERROR_UNEXPECTED_STATE; |
| 5596 | goto endEntityValue; | 5874 | goto endEntityValue; |
| 5875 | /* LCOV_EXCL_STOP */ | ||
| 5597 | } | 5876 | } |
| 5598 | entityTextPtr = next; | 5877 | entityTextPtr = next; |
| 5599 | } | 5878 | } |
| 5600 | endEntityValue: | 5879 | endEntityValue: |
| 5601 | #ifdef XML_DTD | 5880 | #ifdef XML_DTD |
| 5602 | prologState.inEntityValue = oldInEntityValue; | 5881 | parser->m_prologState.inEntityValue = oldInEntityValue; |
| 5603 | #endif /* XML_DTD */ | 5882 | #endif /* XML_DTD */ |
| 5604 | return result; | 5883 | return result; |
| 5605 | } | 5884 | } |
| @@ -5634,25 +5913,25 @@ reportProcessingInstruction(XML_Parser parser, const ENCODING *enc, | |||
| 5634 | const XML_Char *target; | 5913 | const XML_Char *target; |
| 5635 | XML_Char *data; | 5914 | XML_Char *data; |
| 5636 | const char *tem; | 5915 | const char *tem; |
| 5637 | if (!processingInstructionHandler) { | 5916 | if (!parser->m_processingInstructionHandler) { |
| 5638 | if (defaultHandler) | 5917 | if (parser->m_defaultHandler) |
| 5639 | reportDefault(parser, enc, start, end); | 5918 | reportDefault(parser, enc, start, end); |
| 5640 | return 1; | 5919 | return 1; |
| 5641 | } | 5920 | } |
| 5642 | start += enc->minBytesPerChar * 2; | 5921 | start += enc->minBytesPerChar * 2; |
| 5643 | tem = start + XmlNameLength(enc, start); | 5922 | tem = start + XmlNameLength(enc, start); |
| 5644 | target = poolStoreString(&tempPool, enc, start, tem); | 5923 | target = poolStoreString(&parser->m_tempPool, enc, start, tem); |
| 5645 | if (!target) | 5924 | if (!target) |
| 5646 | return 0; | 5925 | return 0; |
| 5647 | poolFinish(&tempPool); | 5926 | poolFinish(&parser->m_tempPool); |
| 5648 | data = poolStoreString(&tempPool, enc, | 5927 | data = poolStoreString(&parser->m_tempPool, enc, |
| 5649 | XmlSkipS(enc, tem), | 5928 | XmlSkipS(enc, tem), |
| 5650 | end - enc->minBytesPerChar*2); | 5929 | end - enc->minBytesPerChar*2); |
| 5651 | if (!data) | 5930 | if (!data) |
| 5652 | return 0; | 5931 | return 0; |
| 5653 | normalizeLines(data); | 5932 | normalizeLines(data); |
| 5654 | processingInstructionHandler(handlerArg, target, data); | 5933 | parser->m_processingInstructionHandler(parser->m_handlerArg, target, data); |
| 5655 | poolClear(&tempPool); | 5934 | poolClear(&parser->m_tempPool); |
| 5656 | return 1; | 5935 | return 1; |
| 5657 | } | 5936 | } |
| 5658 | 5937 | ||
| @@ -5661,20 +5940,20 @@ reportComment(XML_Parser parser, const ENCODING *enc, | |||
| 5661 | const char *start, const char *end) | 5940 | const char *start, const char *end) |
| 5662 | { | 5941 | { |
| 5663 | XML_Char *data; | 5942 | XML_Char *data; |
| 5664 | if (!commentHandler) { | 5943 | if (!parser->m_commentHandler) { |
| 5665 | if (defaultHandler) | 5944 | if (parser->m_defaultHandler) |
| 5666 | reportDefault(parser, enc, start, end); | 5945 | reportDefault(parser, enc, start, end); |
| 5667 | return 1; | 5946 | return 1; |
| 5668 | } | 5947 | } |
| 5669 | data = poolStoreString(&tempPool, | 5948 | data = poolStoreString(&parser->m_tempPool, |
| 5670 | enc, | 5949 | enc, |
| 5671 | start + enc->minBytesPerChar * 4, | 5950 | start + enc->minBytesPerChar * 4, |
| 5672 | end - enc->minBytesPerChar * 3); | 5951 | end - enc->minBytesPerChar * 3); |
| 5673 | if (!data) | 5952 | if (!data) |
| 5674 | return 0; | 5953 | return 0; |
| 5675 | normalizeLines(data); | 5954 | normalizeLines(data); |
| 5676 | commentHandler(handlerArg, data); | 5955 | parser->m_commentHandler(parser->m_handlerArg, data); |
| 5677 | poolClear(&tempPool); | 5956 | poolClear(&parser->m_tempPool); |
| 5678 | return 1; | 5957 | return 1; |
| 5679 | } | 5958 | } |
| 5680 | 5959 | ||
| @@ -5686,24 +5965,41 @@ reportDefault(XML_Parser parser, const ENCODING *enc, | |||
| 5686 | enum XML_Convert_Result convert_res; | 5965 | enum XML_Convert_Result convert_res; |
| 5687 | const char **eventPP; | 5966 | const char **eventPP; |
| 5688 | const char **eventEndPP; | 5967 | const char **eventEndPP; |
| 5689 | if (enc == encoding) { | 5968 | if (enc == parser->m_encoding) { |
| 5690 | eventPP = &eventPtr; | 5969 | eventPP = &parser->m_eventPtr; |
| 5691 | eventEndPP = &eventEndPtr; | 5970 | eventEndPP = &parser->m_eventEndPtr; |
| 5692 | } | 5971 | } |
| 5693 | else { | 5972 | else { |
| 5694 | eventPP = &(openInternalEntities->internalEventPtr); | 5973 | /* To get here, two things must be true; the parser must be |
| 5695 | eventEndPP = &(openInternalEntities->internalEventEndPtr); | 5974 | * using a character encoding that is not the same as the |
| 5975 | * encoding passed in, and the encoding passed in must need | ||
| 5976 | * conversion to the internal format (UTF-8 unless XML_UNICODE | ||
| 5977 | * is defined). The only occasions on which the encoding passed | ||
| 5978 | * in is not the same as the parser's encoding are when it is | ||
| 5979 | * the internal encoding (e.g. a previously defined parameter | ||
| 5980 | * entity, already converted to internal format). This by | ||
| 5981 | * definition doesn't need conversion, so the whole branch never | ||
| 5982 | * gets executed. | ||
| 5983 | * | ||
| 5984 | * For safety's sake we don't delete these lines and merely | ||
| 5985 | * exclude them from coverage statistics. | ||
| 5986 | * | ||
| 5987 | * LCOV_EXCL_START | ||
| 5988 | */ | ||
| 5989 | eventPP = &(parser->m_openInternalEntities->internalEventPtr); | ||
| 5990 | eventEndPP = &(parser->m_openInternalEntities->internalEventEndPtr); | ||
| 5991 | /* LCOV_EXCL_STOP */ | ||
| 5696 | } | 5992 | } |
| 5697 | do { | 5993 | do { |
| 5698 | ICHAR *dataPtr = (ICHAR *)dataBuf; | 5994 | ICHAR *dataPtr = (ICHAR *)parser->m_dataBuf; |
| 5699 | convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)dataBufEnd); | 5995 | convert_res = XmlConvert(enc, &s, end, &dataPtr, (ICHAR *)parser->m_dataBufEnd); |
| 5700 | *eventEndPP = s; | 5996 | *eventEndPP = s; |
| 5701 | defaultHandler(handlerArg, dataBuf, (int)(dataPtr - (ICHAR *)dataBuf)); | 5997 | parser->m_defaultHandler(parser->m_handlerArg, parser->m_dataBuf, (int)(dataPtr - (ICHAR *)parser->m_dataBuf)); |
| 5702 | *eventPP = s; | 5998 | *eventPP = s; |
| 5703 | } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); | 5999 | } while ((convert_res != XML_CONVERT_COMPLETED) && (convert_res != XML_CONVERT_INPUT_INCOMPLETE)); |
| 5704 | } | 6000 | } |
| 5705 | else | 6001 | else |
| 5706 | defaultHandler(handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); | 6002 | parser->m_defaultHandler(parser->m_handlerArg, (XML_Char *)s, (int)((XML_Char *)end - (XML_Char *)s)); |
| 5707 | } | 6003 | } |
| 5708 | 6004 | ||
| 5709 | 6005 | ||
| @@ -5725,16 +6021,18 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, | |||
| 5725 | if (type->nDefaultAtts == type->allocDefaultAtts) { | 6021 | if (type->nDefaultAtts == type->allocDefaultAtts) { |
| 5726 | if (type->allocDefaultAtts == 0) { | 6022 | if (type->allocDefaultAtts == 0) { |
| 5727 | type->allocDefaultAtts = 8; | 6023 | type->allocDefaultAtts = 8; |
| 5728 | type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(type->allocDefaultAtts | 6024 | type->defaultAtts = (DEFAULT_ATTRIBUTE *)MALLOC(parser, type->allocDefaultAtts |
| 5729 | * sizeof(DEFAULT_ATTRIBUTE)); | 6025 | * sizeof(DEFAULT_ATTRIBUTE)); |
| 5730 | if (!type->defaultAtts) | 6026 | if (!type->defaultAtts) { |
| 6027 | type->allocDefaultAtts = 0; | ||
| 5731 | return 0; | 6028 | return 0; |
| 6029 | } | ||
| 5732 | } | 6030 | } |
| 5733 | else { | 6031 | else { |
| 5734 | DEFAULT_ATTRIBUTE *temp; | 6032 | DEFAULT_ATTRIBUTE *temp; |
| 5735 | int count = type->allocDefaultAtts * 2; | 6033 | int count = type->allocDefaultAtts * 2; |
| 5736 | temp = (DEFAULT_ATTRIBUTE *) | 6034 | temp = (DEFAULT_ATTRIBUTE *) |
| 5737 | REALLOC(type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); | 6035 | REALLOC(parser, type->defaultAtts, (count * sizeof(DEFAULT_ATTRIBUTE))); |
| 5738 | if (temp == NULL) | 6036 | if (temp == NULL) |
| 5739 | return 0; | 6037 | return 0; |
| 5740 | type->allocDefaultAtts = count; | 6038 | type->allocDefaultAtts = count; |
| @@ -5754,7 +6052,7 @@ defineAttribute(ELEMENT_TYPE *type, ATTRIBUTE_ID *attId, XML_Bool isCdata, | |||
| 5754 | static int | 6052 | static int |
| 5755 | setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) | 6053 | setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) |
| 5756 | { | 6054 | { |
| 5757 | DTD * const dtd = _dtd; /* save one level of indirection */ | 6055 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5758 | const XML_Char *name; | 6056 | const XML_Char *name; |
| 5759 | for (name = elementType->name; *name; name++) { | 6057 | for (name = elementType->name; *name; name++) { |
| 5760 | if (*name == XML_T(ASCII_COLON)) { | 6058 | if (*name == XML_T(ASCII_COLON)) { |
| @@ -5775,7 +6073,7 @@ setElementTypePrefix(XML_Parser parser, ELEMENT_TYPE *elementType) | |||
| 5775 | else | 6073 | else |
| 5776 | poolDiscard(&dtd->pool); | 6074 | poolDiscard(&dtd->pool); |
| 5777 | elementType->prefix = prefix; | 6075 | elementType->prefix = prefix; |
| 5778 | 6076 | break; | |
| 5779 | } | 6077 | } |
| 5780 | } | 6078 | } |
| 5781 | return 1; | 6079 | return 1; |
| @@ -5785,7 +6083,7 @@ static ATTRIBUTE_ID * | |||
| 5785 | getAttributeId(XML_Parser parser, const ENCODING *enc, | 6083 | getAttributeId(XML_Parser parser, const ENCODING *enc, |
| 5786 | const char *start, const char *end) | 6084 | const char *start, const char *end) |
| 5787 | { | 6085 | { |
| 5788 | DTD * const dtd = _dtd; /* save one level of indirection */ | 6086 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5789 | ATTRIBUTE_ID *id; | 6087 | ATTRIBUTE_ID *id; |
| 5790 | const XML_Char *name; | 6088 | const XML_Char *name; |
| 5791 | if (!poolAppendChar(&dtd->pool, XML_T('\0'))) | 6089 | if (!poolAppendChar(&dtd->pool, XML_T('\0'))) |
| @@ -5802,7 +6100,7 @@ getAttributeId(XML_Parser parser, const ENCODING *enc, | |||
| 5802 | poolDiscard(&dtd->pool); | 6100 | poolDiscard(&dtd->pool); |
| 5803 | else { | 6101 | else { |
| 5804 | poolFinish(&dtd->pool); | 6102 | poolFinish(&dtd->pool); |
| 5805 | if (!ns) | 6103 | if (!parser->m_ns) |
| 5806 | ; | 6104 | ; |
| 5807 | else if (name[0] == XML_T(ASCII_x) | 6105 | else if (name[0] == XML_T(ASCII_x) |
| 5808 | && name[1] == XML_T(ASCII_m) | 6106 | && name[1] == XML_T(ASCII_m) |
| @@ -5849,21 +6147,42 @@ getAttributeId(XML_Parser parser, const ENCODING *enc, | |||
| 5849 | static const XML_Char * | 6147 | static const XML_Char * |
| 5850 | getContext(XML_Parser parser) | 6148 | getContext(XML_Parser parser) |
| 5851 | { | 6149 | { |
| 5852 | DTD * const dtd = _dtd; /* save one level of indirection */ | 6150 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5853 | HASH_TABLE_ITER iter; | 6151 | HASH_TABLE_ITER iter; |
| 5854 | XML_Bool needSep = XML_FALSE; | 6152 | XML_Bool needSep = XML_FALSE; |
| 5855 | 6153 | ||
| 5856 | if (dtd->defaultPrefix.binding) { | 6154 | if (dtd->defaultPrefix.binding) { |
| 5857 | int i; | 6155 | int i; |
| 5858 | int len; | 6156 | int len; |
| 5859 | if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) | 6157 | if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) |
| 5860 | return NULL; | 6158 | return NULL; |
| 5861 | len = dtd->defaultPrefix.binding->uriLen; | 6159 | len = dtd->defaultPrefix.binding->uriLen; |
| 5862 | if (namespaceSeparator) | 6160 | if (parser->m_namespaceSeparator) |
| 5863 | len--; | 6161 | len--; |
| 5864 | for (i = 0; i < len; i++) | 6162 | for (i = 0; i < len; i++) { |
| 5865 | if (!poolAppendChar(&tempPool, dtd->defaultPrefix.binding->uri[i])) | 6163 | if (!poolAppendChar(&parser->m_tempPool, dtd->defaultPrefix.binding->uri[i])) { |
| 5866 | return NULL; | 6164 | /* Because of memory caching, I don't believe this line can be |
| 6165 | * executed. | ||
| 6166 | * | ||
| 6167 | * This is part of a loop copying the default prefix binding | ||
| 6168 | * URI into the parser's temporary string pool. Previously, | ||
| 6169 | * that URI was copied into the same string pool, with a | ||
| 6170 | * terminating NUL character, as part of setContext(). When | ||
| 6171 | * the pool was cleared, that leaves a block definitely big | ||
| 6172 | * enough to hold the URI on the free block list of the pool. | ||
| 6173 | * The URI copy in getContext() therefore cannot run out of | ||
| 6174 | * memory. | ||
| 6175 | * | ||
| 6176 | * If the pool is used between the setContext() and | ||
| 6177 | * getContext() calls, the worst it can do is leave a bigger | ||
| 6178 | * block on the front of the free list. Given that this is | ||
| 6179 | * all somewhat inobvious and program logic can be changed, we | ||
| 6180 | * don't delete the line but we do exclude it from the test | ||
| 6181 | * coverage statistics. | ||
| 6182 | */ | ||
| 6183 | return NULL; /* LCOV_EXCL_LINE */ | ||
| 6184 | } | ||
| 6185 | } | ||
| 5867 | needSep = XML_TRUE; | 6186 | needSep = XML_TRUE; |
| 5868 | } | 6187 | } |
| 5869 | 6188 | ||
| @@ -5875,20 +6194,27 @@ getContext(XML_Parser parser) | |||
| 5875 | PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); | 6194 | PREFIX *prefix = (PREFIX *)hashTableIterNext(&iter); |
| 5876 | if (!prefix) | 6195 | if (!prefix) |
| 5877 | break; | 6196 | break; |
| 5878 | if (!prefix->binding) | 6197 | if (!prefix->binding) { |
| 5879 | continue; | 6198 | /* This test appears to be (justifiable) paranoia. There does |
| 5880 | if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | 6199 | * not seem to be a way of injecting a prefix without a binding |
| 6200 | * that doesn't get errored long before this function is called. | ||
| 6201 | * The test should remain for safety's sake, so we instead | ||
| 6202 | * exclude the following line from the coverage statistics. | ||
| 6203 | */ | ||
| 6204 | continue; /* LCOV_EXCL_LINE */ | ||
| 6205 | } | ||
| 6206 | if (needSep && !poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) | ||
| 5881 | return NULL; | 6207 | return NULL; |
| 5882 | for (s = prefix->name; *s; s++) | 6208 | for (s = prefix->name; *s; s++) |
| 5883 | if (!poolAppendChar(&tempPool, *s)) | 6209 | if (!poolAppendChar(&parser->m_tempPool, *s)) |
| 5884 | return NULL; | 6210 | return NULL; |
| 5885 | if (!poolAppendChar(&tempPool, XML_T(ASCII_EQUALS))) | 6211 | if (!poolAppendChar(&parser->m_tempPool, XML_T(ASCII_EQUALS))) |
| 5886 | return NULL; | 6212 | return NULL; |
| 5887 | len = prefix->binding->uriLen; | 6213 | len = prefix->binding->uriLen; |
| 5888 | if (namespaceSeparator) | 6214 | if (parser->m_namespaceSeparator) |
| 5889 | len--; | 6215 | len--; |
| 5890 | for (i = 0; i < len; i++) | 6216 | for (i = 0; i < len; i++) |
| 5891 | if (!poolAppendChar(&tempPool, prefix->binding->uri[i])) | 6217 | if (!poolAppendChar(&parser->m_tempPool, prefix->binding->uri[i])) |
| 5892 | return NULL; | 6218 | return NULL; |
| 5893 | needSep = XML_TRUE; | 6219 | needSep = XML_TRUE; |
| 5894 | } | 6220 | } |
| @@ -5902,73 +6228,73 @@ getContext(XML_Parser parser) | |||
| 5902 | break; | 6228 | break; |
| 5903 | if (!e->open) | 6229 | if (!e->open) |
| 5904 | continue; | 6230 | continue; |
| 5905 | if (needSep && !poolAppendChar(&tempPool, CONTEXT_SEP)) | 6231 | if (needSep && !poolAppendChar(&parser->m_tempPool, CONTEXT_SEP)) |
| 5906 | return NULL; | 6232 | return NULL; |
| 5907 | for (s = e->name; *s; s++) | 6233 | for (s = e->name; *s; s++) |
| 5908 | if (!poolAppendChar(&tempPool, *s)) | 6234 | if (!poolAppendChar(&parser->m_tempPool, *s)) |
| 5909 | return 0; | 6235 | return 0; |
| 5910 | needSep = XML_TRUE; | 6236 | needSep = XML_TRUE; |
| 5911 | } | 6237 | } |
| 5912 | 6238 | ||
| 5913 | if (!poolAppendChar(&tempPool, XML_T('\0'))) | 6239 | if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 5914 | return NULL; | 6240 | return NULL; |
| 5915 | return tempPool.start; | 6241 | return parser->m_tempPool.start; |
| 5916 | } | 6242 | } |
| 5917 | 6243 | ||
| 5918 | static XML_Bool | 6244 | static XML_Bool |
| 5919 | setContext(XML_Parser parser, const XML_Char *context) | 6245 | setContext(XML_Parser parser, const XML_Char *context) |
| 5920 | { | 6246 | { |
| 5921 | DTD * const dtd = _dtd; /* save one level of indirection */ | 6247 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 5922 | const XML_Char *s = context; | 6248 | const XML_Char *s = context; |
| 5923 | 6249 | ||
| 5924 | while (*context != XML_T('\0')) { | 6250 | while (*context != XML_T('\0')) { |
| 5925 | if (*s == CONTEXT_SEP || *s == XML_T('\0')) { | 6251 | if (*s == CONTEXT_SEP || *s == XML_T('\0')) { |
| 5926 | ENTITY *e; | 6252 | ENTITY *e; |
| 5927 | if (!poolAppendChar(&tempPool, XML_T('\0'))) | 6253 | if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 5928 | return XML_FALSE; | 6254 | return XML_FALSE; |
| 5929 | e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&tempPool), 0); | 6255 | e = (ENTITY *)lookup(parser, &dtd->generalEntities, poolStart(&parser->m_tempPool), 0); |
| 5930 | if (e) | 6256 | if (e) |
| 5931 | e->open = XML_TRUE; | 6257 | e->open = XML_TRUE; |
| 5932 | if (*s != XML_T('\0')) | 6258 | if (*s != XML_T('\0')) |
| 5933 | s++; | 6259 | s++; |
| 5934 | context = s; | 6260 | context = s; |
| 5935 | poolDiscard(&tempPool); | 6261 | poolDiscard(&parser->m_tempPool); |
| 5936 | } | 6262 | } |
| 5937 | else if (*s == XML_T(ASCII_EQUALS)) { | 6263 | else if (*s == XML_T(ASCII_EQUALS)) { |
| 5938 | PREFIX *prefix; | 6264 | PREFIX *prefix; |
| 5939 | if (poolLength(&tempPool) == 0) | 6265 | if (poolLength(&parser->m_tempPool) == 0) |
| 5940 | prefix = &dtd->defaultPrefix; | 6266 | prefix = &dtd->defaultPrefix; |
| 5941 | else { | 6267 | else { |
| 5942 | if (!poolAppendChar(&tempPool, XML_T('\0'))) | 6268 | if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 5943 | return XML_FALSE; | 6269 | return XML_FALSE; |
| 5944 | prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&tempPool), | 6270 | prefix = (PREFIX *)lookup(parser, &dtd->prefixes, poolStart(&parser->m_tempPool), |
| 5945 | sizeof(PREFIX)); | 6271 | sizeof(PREFIX)); |
| 5946 | if (!prefix) | 6272 | if (!prefix) |
| 5947 | return XML_FALSE; | 6273 | return XML_FALSE; |
| 5948 | if (prefix->name == poolStart(&tempPool)) { | 6274 | if (prefix->name == poolStart(&parser->m_tempPool)) { |
| 5949 | prefix->name = poolCopyString(&dtd->pool, prefix->name); | 6275 | prefix->name = poolCopyString(&dtd->pool, prefix->name); |
| 5950 | if (!prefix->name) | 6276 | if (!prefix->name) |
| 5951 | return XML_FALSE; | 6277 | return XML_FALSE; |
| 5952 | } | 6278 | } |
| 5953 | poolDiscard(&tempPool); | 6279 | poolDiscard(&parser->m_tempPool); |
| 5954 | } | 6280 | } |
| 5955 | for (context = s + 1; | 6281 | for (context = s + 1; |
| 5956 | *context != CONTEXT_SEP && *context != XML_T('\0'); | 6282 | *context != CONTEXT_SEP && *context != XML_T('\0'); |
| 5957 | context++) | 6283 | context++) |
| 5958 | if (!poolAppendChar(&tempPool, *context)) | 6284 | if (!poolAppendChar(&parser->m_tempPool, *context)) |
| 5959 | return XML_FALSE; | 6285 | return XML_FALSE; |
| 5960 | if (!poolAppendChar(&tempPool, XML_T('\0'))) | 6286 | if (!poolAppendChar(&parser->m_tempPool, XML_T('\0'))) |
| 5961 | return XML_FALSE; | 6287 | return XML_FALSE; |
| 5962 | if (addBinding(parser, prefix, NULL, poolStart(&tempPool), | 6288 | if (addBinding(parser, prefix, NULL, poolStart(&parser->m_tempPool), |
| 5963 | &inheritedBindings) != XML_ERROR_NONE) | 6289 | &parser->m_inheritedBindings) != XML_ERROR_NONE) |
| 5964 | return XML_FALSE; | 6290 | return XML_FALSE; |
| 5965 | poolDiscard(&tempPool); | 6291 | poolDiscard(&parser->m_tempPool); |
| 5966 | if (*context != XML_T('\0')) | 6292 | if (*context != XML_T('\0')) |
| 5967 | ++context; | 6293 | ++context; |
| 5968 | s = context; | 6294 | s = context; |
| 5969 | } | 6295 | } |
| 5970 | else { | 6296 | else { |
| 5971 | if (!poolAppendChar(&tempPool, *s)) | 6297 | if (!poolAppendChar(&parser->m_tempPool, *s)) |
| 5972 | return XML_FALSE; | 6298 | return XML_FALSE; |
| 5973 | s++; | 6299 | s++; |
| 5974 | } | 6300 | } |
| @@ -6333,7 +6659,6 @@ hash(XML_Parser parser, KEY s) | |||
| 6333 | { | 6659 | { |
| 6334 | struct siphash state; | 6660 | struct siphash state; |
| 6335 | struct sipkey key; | 6661 | struct sipkey key; |
| 6336 | (void)sip_tobin; | ||
| 6337 | (void)sip24_valid; | 6662 | (void)sip24_valid; |
| 6338 | copy_salt_to_sipkey(parser, &key); | 6663 | copy_salt_to_sipkey(parser, &key); |
| 6339 | sip24_init(&state, &key); | 6664 | sip24_init(&state, &key); |
| @@ -6547,8 +6872,20 @@ poolCopyString(STRING_POOL *pool, const XML_Char *s) | |||
| 6547 | static const XML_Char * | 6872 | static const XML_Char * |
| 6548 | poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) | 6873 | poolCopyStringN(STRING_POOL *pool, const XML_Char *s, int n) |
| 6549 | { | 6874 | { |
| 6550 | if (!pool->ptr && !poolGrow(pool)) | 6875 | if (!pool->ptr && !poolGrow(pool)) { |
| 6551 | return NULL; | 6876 | /* The following line is unreachable given the current usage of |
| 6877 | * poolCopyStringN(). Currently it is called from exactly one | ||
| 6878 | * place to copy the text of a simple general entity. By that | ||
| 6879 | * point, the name of the entity is already stored in the pool, so | ||
| 6880 | * pool->ptr cannot be NULL. | ||
| 6881 | * | ||
| 6882 | * If poolCopyStringN() is used elsewhere as it well might be, | ||
| 6883 | * this line may well become executable again. Regardless, this | ||
| 6884 | * sort of check shouldn't be removed lightly, so we just exclude | ||
| 6885 | * it from the coverage statistics. | ||
| 6886 | */ | ||
| 6887 | return NULL; /* LCOV_EXCL_LINE */ | ||
| 6888 | } | ||
| 6552 | for (; n > 0; --n, s++) { | 6889 | for (; n > 0; --n, s++) { |
| 6553 | if (!poolAppendChar(pool, *s)) | 6890 | if (!poolAppendChar(pool, *s)) |
| 6554 | return NULL; | 6891 | return NULL; |
| @@ -6641,8 +6978,19 @@ poolGrow(STRING_POOL *pool) | |||
| 6641 | int blockSize = (int)((unsigned)(pool->end - pool->start)*2U); | 6978 | int blockSize = (int)((unsigned)(pool->end - pool->start)*2U); |
| 6642 | size_t bytesToAllocate; | 6979 | size_t bytesToAllocate; |
| 6643 | 6980 | ||
| 6644 | if (blockSize < 0) | 6981 | /* NOTE: Needs to be calculated prior to calling `realloc` |
| 6645 | return XML_FALSE; | 6982 | to avoid dangling pointers: */ |
| 6983 | const ptrdiff_t offsetInsideBlock = pool->ptr - pool->start; | ||
| 6984 | |||
| 6985 | if (blockSize < 0) { | ||
| 6986 | /* This condition traps a situation where either more than | ||
| 6987 | * INT_MAX/2 bytes have already been allocated. This isn't | ||
| 6988 | * readily testable, since it is unlikely that an average | ||
| 6989 | * machine will have that much memory, so we exclude it from the | ||
| 6990 | * coverage statistics. | ||
| 6991 | */ | ||
| 6992 | return XML_FALSE; /* LCOV_EXCL_LINE */ | ||
| 6993 | } | ||
| 6646 | 6994 | ||
| 6647 | bytesToAllocate = poolBytesToAllocateFor(blockSize); | 6995 | bytesToAllocate = poolBytesToAllocateFor(blockSize); |
| 6648 | if (bytesToAllocate == 0) | 6996 | if (bytesToAllocate == 0) |
| @@ -6654,7 +7002,7 @@ poolGrow(STRING_POOL *pool) | |||
| 6654 | return XML_FALSE; | 7002 | return XML_FALSE; |
| 6655 | pool->blocks = temp; | 7003 | pool->blocks = temp; |
| 6656 | pool->blocks->size = blockSize; | 7004 | pool->blocks->size = blockSize; |
| 6657 | pool->ptr = pool->blocks->s + (pool->ptr - pool->start); | 7005 | pool->ptr = pool->blocks->s + offsetInsideBlock; |
| 6658 | pool->start = pool->blocks->s; | 7006 | pool->start = pool->blocks->s; |
| 6659 | pool->end = pool->start + blockSize; | 7007 | pool->end = pool->start + blockSize; |
| 6660 | } | 7008 | } |
| @@ -6663,8 +7011,18 @@ poolGrow(STRING_POOL *pool) | |||
| 6663 | int blockSize = (int)(pool->end - pool->start); | 7011 | int blockSize = (int)(pool->end - pool->start); |
| 6664 | size_t bytesToAllocate; | 7012 | size_t bytesToAllocate; |
| 6665 | 7013 | ||
| 6666 | if (blockSize < 0) | 7014 | if (blockSize < 0) { |
| 6667 | return XML_FALSE; | 7015 | /* This condition traps a situation where either more than |
| 7016 | * INT_MAX bytes have already been allocated (which is prevented | ||
| 7017 | * by various pieces of program logic, not least this one, never | ||
| 7018 | * mind the unlikelihood of actually having that much memory) or | ||
| 7019 | * the pool control fields have been corrupted (which could | ||
| 7020 | * conceivably happen in an extremely buggy user handler | ||
| 7021 | * function). Either way it isn't readily testable, so we | ||
| 7022 | * exclude it from the coverage statistics. | ||
| 7023 | */ | ||
| 7024 | return XML_FALSE; /* LCOV_EXCL_LINE */ | ||
| 7025 | } | ||
| 6668 | 7026 | ||
| 6669 | if (blockSize < INIT_BLOCK_SIZE) | 7027 | if (blockSize < INIT_BLOCK_SIZE) |
| 6670 | blockSize = INIT_BLOCK_SIZE; | 7028 | blockSize = INIT_BLOCK_SIZE; |
| @@ -6699,12 +7057,12 @@ poolGrow(STRING_POOL *pool) | |||
| 6699 | static int FASTCALL | 7057 | static int FASTCALL |
| 6700 | nextScaffoldPart(XML_Parser parser) | 7058 | nextScaffoldPart(XML_Parser parser) |
| 6701 | { | 7059 | { |
| 6702 | DTD * const dtd = _dtd; /* save one level of indirection */ | 7060 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 6703 | CONTENT_SCAFFOLD * me; | 7061 | CONTENT_SCAFFOLD * me; |
| 6704 | int next; | 7062 | int next; |
| 6705 | 7063 | ||
| 6706 | if (!dtd->scaffIndex) { | 7064 | if (!dtd->scaffIndex) { |
| 6707 | dtd->scaffIndex = (int *)MALLOC(groupSize * sizeof(int)); | 7065 | dtd->scaffIndex = (int *)MALLOC(parser, parser->m_groupSize * sizeof(int)); |
| 6708 | if (!dtd->scaffIndex) | 7066 | if (!dtd->scaffIndex) |
| 6709 | return -1; | 7067 | return -1; |
| 6710 | dtd->scaffIndex[0] = 0; | 7068 | dtd->scaffIndex[0] = 0; |
| @@ -6714,13 +7072,13 @@ nextScaffoldPart(XML_Parser parser) | |||
| 6714 | CONTENT_SCAFFOLD *temp; | 7072 | CONTENT_SCAFFOLD *temp; |
| 6715 | if (dtd->scaffold) { | 7073 | if (dtd->scaffold) { |
| 6716 | temp = (CONTENT_SCAFFOLD *) | 7074 | temp = (CONTENT_SCAFFOLD *) |
| 6717 | REALLOC(dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); | 7075 | REALLOC(parser, dtd->scaffold, dtd->scaffSize * 2 * sizeof(CONTENT_SCAFFOLD)); |
| 6718 | if (temp == NULL) | 7076 | if (temp == NULL) |
| 6719 | return -1; | 7077 | return -1; |
| 6720 | dtd->scaffSize *= 2; | 7078 | dtd->scaffSize *= 2; |
| 6721 | } | 7079 | } |
| 6722 | else { | 7080 | else { |
| 6723 | temp = (CONTENT_SCAFFOLD *)MALLOC(INIT_SCAFFOLD_ELEMENTS | 7081 | temp = (CONTENT_SCAFFOLD *)MALLOC(parser, INIT_SCAFFOLD_ELEMENTS |
| 6724 | * sizeof(CONTENT_SCAFFOLD)); | 7082 | * sizeof(CONTENT_SCAFFOLD)); |
| 6725 | if (temp == NULL) | 7083 | if (temp == NULL) |
| 6726 | return -1; | 7084 | return -1; |
| @@ -6751,7 +7109,7 @@ build_node(XML_Parser parser, | |||
| 6751 | XML_Content **contpos, | 7109 | XML_Content **contpos, |
| 6752 | XML_Char **strpos) | 7110 | XML_Char **strpos) |
| 6753 | { | 7111 | { |
| 6754 | DTD * const dtd = _dtd; /* save one level of indirection */ | 7112 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 6755 | dest->type = dtd->scaffold[src_node].type; | 7113 | dest->type = dtd->scaffold[src_node].type; |
| 6756 | dest->quant = dtd->scaffold[src_node].quant; | 7114 | dest->quant = dtd->scaffold[src_node].quant; |
| 6757 | if (dest->type == XML_CTYPE_NAME) { | 7115 | if (dest->type == XML_CTYPE_NAME) { |
| @@ -6785,14 +7143,14 @@ build_node(XML_Parser parser, | |||
| 6785 | static XML_Content * | 7143 | static XML_Content * |
| 6786 | build_model (XML_Parser parser) | 7144 | build_model (XML_Parser parser) |
| 6787 | { | 7145 | { |
| 6788 | DTD * const dtd = _dtd; /* save one level of indirection */ | 7146 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 6789 | XML_Content *ret; | 7147 | XML_Content *ret; |
| 6790 | XML_Content *cpos; | 7148 | XML_Content *cpos; |
| 6791 | XML_Char * str; | 7149 | XML_Char * str; |
| 6792 | int allocsize = (dtd->scaffCount * sizeof(XML_Content) | 7150 | int allocsize = (dtd->scaffCount * sizeof(XML_Content) |
| 6793 | + (dtd->contentStringLen * sizeof(XML_Char))); | 7151 | + (dtd->contentStringLen * sizeof(XML_Char))); |
| 6794 | 7152 | ||
| 6795 | ret = (XML_Content *)MALLOC(allocsize); | 7153 | ret = (XML_Content *)MALLOC(parser, allocsize); |
| 6796 | if (!ret) | 7154 | if (!ret) |
| 6797 | return NULL; | 7155 | return NULL; |
| 6798 | 7156 | ||
| @@ -6809,7 +7167,7 @@ getElementType(XML_Parser parser, | |||
| 6809 | const char *ptr, | 7167 | const char *ptr, |
| 6810 | const char *end) | 7168 | const char *end) |
| 6811 | { | 7169 | { |
| 6812 | DTD * const dtd = _dtd; /* save one level of indirection */ | 7170 | DTD * const dtd = parser->m_dtd; /* save one level of indirection */ |
| 6813 | const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); | 7171 | const XML_Char *name = poolStoreString(&dtd->pool, enc, ptr, end); |
| 6814 | ELEMENT_TYPE *ret; | 7172 | ELEMENT_TYPE *ret; |
| 6815 | 7173 | ||
| @@ -6827,3 +7185,26 @@ getElementType(XML_Parser parser, | |||
| 6827 | } | 7185 | } |
| 6828 | return ret; | 7186 | return ret; |
| 6829 | } | 7187 | } |
| 7188 | |||
| 7189 | static XML_Char * | ||
| 7190 | copyString(const XML_Char *s, | ||
| 7191 | const XML_Memory_Handling_Suite *memsuite) | ||
| 7192 | { | ||
| 7193 | int charsRequired = 0; | ||
| 7194 | XML_Char *result; | ||
| 7195 | |||
| 7196 | /* First determine how long the string is */ | ||
| 7197 | while (s[charsRequired] != 0) { | ||
| 7198 | charsRequired++; | ||
| 7199 | } | ||
| 7200 | /* Include the terminator */ | ||
| 7201 | charsRequired++; | ||
| 7202 | |||
| 7203 | /* Now allocate space for the copy */ | ||
| 7204 | result = memsuite->malloc_fcn(charsRequired * sizeof(XML_Char)); | ||
| 7205 | if (result == NULL) | ||
| 7206 | return NULL; | ||
| 7207 | /* Copy the original into place */ | ||
| 7208 | memcpy(result, s, charsRequired * sizeof(XML_Char)); | ||
| 7209 | return result; | ||
| 7210 | } | ||
diff --git a/3rdParty/Expat/src/xmlrole.c b/3rdParty/Expat/src/xmlrole.c index a7c5630..708507d 100644 --- a/3rdParty/Expat/src/xmlrole.c +++ b/3rdParty/Expat/src/xmlrole.c | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #include <stddef.h> | 33 | #include <stddef.h> |
| @@ -170,7 +198,14 @@ prolog1(PROLOG_STATE *state, | |||
| 170 | case XML_TOK_COMMENT: | 198 | case XML_TOK_COMMENT: |
| 171 | return XML_ROLE_COMMENT; | 199 | return XML_ROLE_COMMENT; |
| 172 | case XML_TOK_BOM: | 200 | case XML_TOK_BOM: |
| 173 | return XML_ROLE_NONE; | 201 | /* This case can never arise. To reach this role function, the |
| 202 | * parse must have passed through prolog0 and therefore have had | ||
| 203 | * some form of input, even if only a space. At that point, a | ||
| 204 | * byte order mark is no longer a valid character (though | ||
| 205 | * technically it should be interpreted as a non-breaking space), | ||
| 206 | * so will be rejected by the tokenizing stages. | ||
| 207 | */ | ||
| 208 | return XML_ROLE_NONE; /* LCOV_EXCL_LINE */ | ||
| 174 | case XML_TOK_DECL_OPEN: | 209 | case XML_TOK_DECL_OPEN: |
| 175 | if (!XmlNameMatchesAscii(enc, | 210 | if (!XmlNameMatchesAscii(enc, |
| 176 | ptr + 2 * MIN_BYTES_PER_CHAR(enc), | 211 | ptr + 2 * MIN_BYTES_PER_CHAR(enc), |
| @@ -1285,6 +1320,26 @@ declClose(PROLOG_STATE *state, | |||
| 1285 | return common(state, tok); | 1320 | return common(state, tok); |
| 1286 | } | 1321 | } |
| 1287 | 1322 | ||
| 1323 | /* This function will only be invoked if the internal logic of the | ||
| 1324 | * parser has broken down. It is used in two cases: | ||
| 1325 | * | ||
| 1326 | * 1: When the XML prolog has been finished. At this point the | ||
| 1327 | * processor (the parser level above these role handlers) should | ||
| 1328 | * switch from prologProcessor to contentProcessor and reinitialise | ||
| 1329 | * the handler function. | ||
| 1330 | * | ||
| 1331 | * 2: When an error has been detected (via common() below). At this | ||
| 1332 | * point again the processor should be switched to errorProcessor, | ||
| 1333 | * which will never call a handler. | ||
| 1334 | * | ||
| 1335 | * The result of this is that error() can only be called if the | ||
| 1336 | * processor switch failed to happen, which is an internal error and | ||
| 1337 | * therefore we shouldn't be able to provoke it simply by using the | ||
| 1338 | * library. It is a necessary backstop, however, so we merely exclude | ||
| 1339 | * it from the coverage statistics. | ||
| 1340 | * | ||
| 1341 | * LCOV_EXCL_START | ||
| 1342 | */ | ||
| 1288 | static int PTRCALL | 1343 | static int PTRCALL |
| 1289 | error(PROLOG_STATE *UNUSED_P(state), | 1344 | error(PROLOG_STATE *UNUSED_P(state), |
| 1290 | int UNUSED_P(tok), | 1345 | int UNUSED_P(tok), |
| @@ -1294,6 +1349,7 @@ error(PROLOG_STATE *UNUSED_P(state), | |||
| 1294 | { | 1349 | { |
| 1295 | return XML_ROLE_NONE; | 1350 | return XML_ROLE_NONE; |
| 1296 | } | 1351 | } |
| 1352 | /* LCOV_EXCL_STOP */ | ||
| 1297 | 1353 | ||
| 1298 | static int FASTCALL | 1354 | static int FASTCALL |
| 1299 | common(PROLOG_STATE *state, int tok) | 1355 | common(PROLOG_STATE *state, int tok) |
diff --git a/3rdParty/Expat/src/xmlrole.h b/3rdParty/Expat/src/xmlrole.h index 4dd9f06..e5f048e 100644 --- a/3rdParty/Expat/src/xmlrole.h +++ b/3rdParty/Expat/src/xmlrole.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #ifndef XmlRole_INCLUDED | 33 | #ifndef XmlRole_INCLUDED |
diff --git a/3rdParty/Expat/src/xmltok.c b/3rdParty/Expat/src/xmltok.c index cdf0720..6b415d8 100644 --- a/3rdParty/Expat/src/xmltok.c +++ b/3rdParty/Expat/src/xmltok.c | |||
| @@ -1,8 +1,47 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #include <stddef.h> | 33 | #include <stddef.h> |
| 34 | #include <string.h> /* memcpy */ | ||
| 35 | |||
| 36 | #if defined(_MSC_VER) && (_MSC_VER <= 1700) | ||
| 37 | /* for vs2012/11.0/1700 and earlier Visual Studio compilers */ | ||
| 38 | # define bool int | ||
| 39 | # define false 0 | ||
| 40 | # define true 1 | ||
| 41 | #else | ||
| 42 | # include <stdbool.h> | ||
| 43 | #endif | ||
| 44 | |||
| 6 | 45 | ||
| 7 | #ifdef _WIN32 | 46 | #ifdef _WIN32 |
| 8 | #include "winconfig.h" | 47 | #include "winconfig.h" |
| @@ -27,7 +66,6 @@ | |||
| 27 | { PREFIX(prologTok), PREFIX(contentTok), \ | 66 | { PREFIX(prologTok), PREFIX(contentTok), \ |
| 28 | PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ | 67 | PREFIX(cdataSectionTok) IGNORE_SECTION_TOK_VTABLE }, \ |
| 29 | { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ | 68 | { PREFIX(attributeValueTok), PREFIX(entityValueTok) }, \ |
| 30 | PREFIX(sameName), \ | ||
| 31 | PREFIX(nameMatchesAscii), \ | 69 | PREFIX(nameMatchesAscii), \ |
| 32 | PREFIX(nameLength), \ | 70 | PREFIX(nameLength), \ |
| 33 | PREFIX(skipS), \ | 71 | PREFIX(skipS), \ |
| @@ -324,7 +362,7 @@ enum { /* UTF8_cvalN is value of masked first byte of N byte sequence */ | |||
| 324 | }; | 362 | }; |
| 325 | 363 | ||
| 326 | void | 364 | void |
| 327 | align_limit_to_full_utf8_characters(const char * from, const char ** fromLimRef) | 365 | _INTERNAL_trim_to_complete_utf8_characters(const char * from, const char ** fromLimRef) |
| 328 | { | 366 | { |
| 329 | const char * fromLim = *fromLimRef; | 367 | const char * fromLim = *fromLimRef; |
| 330 | size_t walked = 0; | 368 | size_t walked = 0; |
| @@ -363,22 +401,37 @@ utf8_toUtf8(const ENCODING *UNUSED_P(enc), | |||
| 363 | const char **fromP, const char *fromLim, | 401 | const char **fromP, const char *fromLim, |
| 364 | char **toP, const char *toLim) | 402 | char **toP, const char *toLim) |
| 365 | { | 403 | { |
| 366 | char *to; | 404 | bool input_incomplete = false; |
| 367 | const char *from; | 405 | bool output_exhausted = false; |
| 368 | const char *fromLimInitial = fromLim; | 406 | |
| 407 | /* Avoid copying partial characters (due to limited space). */ | ||
| 408 | const ptrdiff_t bytesAvailable = fromLim - *fromP; | ||
| 409 | const ptrdiff_t bytesStorable = toLim - *toP; | ||
| 410 | if (bytesAvailable > bytesStorable) { | ||
| 411 | fromLim = *fromP + bytesStorable; | ||
| 412 | output_exhausted = true; | ||
| 413 | } | ||
| 369 | 414 | ||
| 370 | /* Avoid copying partial characters. */ | 415 | /* Avoid copying partial characters (from incomplete input). */ |
| 371 | align_limit_to_full_utf8_characters(*fromP, &fromLim); | 416 | { |
| 417 | const char * const fromLimBefore = fromLim; | ||
| 418 | _INTERNAL_trim_to_complete_utf8_characters(*fromP, &fromLim); | ||
| 419 | if (fromLim < fromLimBefore) { | ||
| 420 | input_incomplete = true; | ||
| 421 | } | ||
| 422 | } | ||
| 372 | 423 | ||
| 373 | for (to = *toP, from = *fromP; (from < fromLim) && (to < toLim); from++, to++) | 424 | { |
| 374 | *to = *from; | 425 | const ptrdiff_t bytesToCopy = fromLim - *fromP; |
| 375 | *fromP = from; | 426 | memcpy(*toP, *fromP, bytesToCopy); |
| 376 | *toP = to; | 427 | *fromP += bytesToCopy; |
| 428 | *toP += bytesToCopy; | ||
| 429 | } | ||
| 377 | 430 | ||
| 378 | if (fromLim < fromLimInitial) | 431 | if (output_exhausted) /* needs to go first */ |
| 379 | return XML_CONVERT_INPUT_INCOMPLETE; | ||
| 380 | else if ((to == toLim) && (from < fromLim)) | ||
| 381 | return XML_CONVERT_OUTPUT_EXHAUSTED; | 432 | return XML_CONVERT_OUTPUT_EXHAUSTED; |
| 433 | else if (input_incomplete) | ||
| 434 | return XML_CONVERT_INPUT_INCOMPLETE; | ||
| 382 | else | 435 | else |
| 383 | return XML_CONVERT_COMPLETED; | 436 | return XML_CONVERT_COMPLETED; |
| 384 | } | 437 | } |
| @@ -1019,7 +1072,11 @@ streqci(const char *s1, const char *s2) | |||
| 1019 | if (ASCII_a <= c1 && c1 <= ASCII_z) | 1072 | if (ASCII_a <= c1 && c1 <= ASCII_z) |
| 1020 | c1 += ASCII_A - ASCII_a; | 1073 | c1 += ASCII_A - ASCII_a; |
| 1021 | if (ASCII_a <= c2 && c2 <= ASCII_z) | 1074 | if (ASCII_a <= c2 && c2 <= ASCII_z) |
| 1022 | c2 += ASCII_A - ASCII_a; | 1075 | /* The following line will never get executed. streqci() is |
| 1076 | * only called from two places, both of which guarantee to put | ||
| 1077 | * upper-case strings into s2. | ||
| 1078 | */ | ||
| 1079 | c2 += ASCII_A - ASCII_a; /* LCOV_EXCL_LINE */ | ||
| 1023 | if (c1 != c2) | 1080 | if (c1 != c2) |
| 1024 | return 0; | 1081 | return 0; |
| 1025 | if (!c1) | 1082 | if (!c1) |
| @@ -1291,7 +1348,7 @@ XmlUtf8Encode(int c, char *buf) | |||
| 1291 | }; | 1348 | }; |
| 1292 | 1349 | ||
| 1293 | if (c < 0) | 1350 | if (c < 0) |
| 1294 | return 0; | 1351 | return 0; /* LCOV_EXCL_LINE: this case is always eliminated beforehand */ |
| 1295 | if (c < min2) { | 1352 | if (c < min2) { |
| 1296 | buf[0] = (char)(c | UTF8_cval1); | 1353 | buf[0] = (char)(c | UTF8_cval1); |
| 1297 | return 1; | 1354 | return 1; |
| @@ -1314,7 +1371,7 @@ XmlUtf8Encode(int c, char *buf) | |||
| 1314 | buf[3] = (char)((c & 0x3f) | 0x80); | 1371 | buf[3] = (char)((c & 0x3f) | 0x80); |
| 1315 | return 4; | 1372 | return 4; |
| 1316 | } | 1373 | } |
| 1317 | return 0; | 1374 | return 0; /* LCOV_EXCL_LINE: this case too is eliminated before calling */ |
| 1318 | } | 1375 | } |
| 1319 | 1376 | ||
| 1320 | int FASTCALL | 1377 | int FASTCALL |
| @@ -1407,9 +1464,8 @@ unknown_toUtf8(const ENCODING *enc, | |||
| 1407 | return XML_CONVERT_OUTPUT_EXHAUSTED; | 1464 | return XML_CONVERT_OUTPUT_EXHAUSTED; |
| 1408 | (*fromP)++; | 1465 | (*fromP)++; |
| 1409 | } | 1466 | } |
| 1410 | do { | 1467 | memcpy(*toP, utf8, n); |
| 1411 | *(*toP)++ = *utf8++; | 1468 | *toP += n; |
| 1412 | } while (--n != 0); | ||
| 1413 | } | 1469 | } |
| 1414 | } | 1470 | } |
| 1415 | 1471 | ||
| @@ -1465,6 +1521,9 @@ XmlInitUnknownEncoding(void *mem, | |||
| 1465 | else if (c < 0) { | 1521 | else if (c < 0) { |
| 1466 | if (c < -4) | 1522 | if (c < -4) |
| 1467 | return 0; | 1523 | return 0; |
| 1524 | /* Multi-byte sequences need a converter function */ | ||
| 1525 | if (!convert) | ||
| 1526 | return 0; | ||
| 1468 | e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); | 1527 | e->normal.type[i] = (unsigned char)(BT_LEAD2 - (c + 2)); |
| 1469 | e->utf8[i][0] = 0; | 1528 | e->utf8[i][0] = 0; |
| 1470 | e->utf16[i] = 0; | 1529 | e->utf16[i] = 0; |
diff --git a/3rdParty/Expat/src/xmltok.h b/3rdParty/Expat/src/xmltok.h index 752007e..50926f3 100644 --- a/3rdParty/Expat/src/xmltok.h +++ b/3rdParty/Expat/src/xmltok.h | |||
| @@ -1,5 +1,33 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | #ifndef XmlTok_INCLUDED | 33 | #ifndef XmlTok_INCLUDED |
| @@ -139,9 +167,6 @@ enum XML_Convert_Result { | |||
| 139 | struct encoding { | 167 | struct encoding { |
| 140 | SCANNER scanners[XML_N_STATES]; | 168 | SCANNER scanners[XML_N_STATES]; |
| 141 | SCANNER literalScanners[XML_N_LITERAL_TYPES]; | 169 | SCANNER literalScanners[XML_N_LITERAL_TYPES]; |
| 142 | int (PTRCALL *sameName)(const ENCODING *, | ||
| 143 | const char *, | ||
| 144 | const char *); | ||
| 145 | int (PTRCALL *nameMatchesAscii)(const ENCODING *, | 170 | int (PTRCALL *nameMatchesAscii)(const ENCODING *, |
| 146 | const char *, | 171 | const char *, |
| 147 | const char *, | 172 | const char *, |
| @@ -232,8 +257,6 @@ struct encoding { | |||
| 232 | #define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ | 257 | #define XmlEntityValueTok(enc, ptr, end, nextTokPtr) \ |
| 233 | XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) | 258 | XmlLiteralTok(enc, XML_ENTITY_VALUE_LITERAL, ptr, end, nextTokPtr) |
| 234 | 259 | ||
| 235 | #define XmlSameName(enc, ptr1, ptr2) (((enc)->sameName)(enc, ptr1, ptr2)) | ||
| 236 | |||
| 237 | #define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ | 260 | #define XmlNameMatchesAscii(enc, ptr1, end1, ptr2) \ |
| 238 | (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) | 261 | (((enc)->nameMatchesAscii)(enc, ptr1, end1, ptr2)) |
| 239 | 262 | ||
diff --git a/3rdParty/Expat/src/xmltok_impl.c b/3rdParty/Expat/src/xmltok_impl.c index 5f779c0..4d9ae7d 100644 --- a/3rdParty/Expat/src/xmltok_impl.c +++ b/3rdParty/Expat/src/xmltok_impl.c | |||
| @@ -1,8 +1,35 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* This file is included! |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* This file is included! */ | ||
| 6 | #ifdef XML_TOK_IMPL_C | 33 | #ifdef XML_TOK_IMPL_C |
| 7 | 34 | ||
| 8 | #ifndef IS_INVALID_CHAR | 35 | #ifndef IS_INVALID_CHAR |
| @@ -47,6 +74,7 @@ | |||
| 47 | *nextTokPtr = ptr; \ | 74 | *nextTokPtr = ptr; \ |
| 48 | return XML_TOK_INVALID; \ | 75 | return XML_TOK_INVALID; \ |
| 49 | } \ | 76 | } \ |
| 77 | /* fall through */ \ | ||
| 50 | case BT_NMSTRT: \ | 78 | case BT_NMSTRT: \ |
| 51 | case BT_HEX: \ | 79 | case BT_HEX: \ |
| 52 | case BT_DIGIT: \ | 80 | case BT_DIGIT: \ |
| @@ -75,6 +103,7 @@ | |||
| 75 | *nextTokPtr = ptr; \ | 103 | *nextTokPtr = ptr; \ |
| 76 | return XML_TOK_INVALID; \ | 104 | return XML_TOK_INVALID; \ |
| 77 | } \ | 105 | } \ |
| 106 | /* fall through */ \ | ||
| 78 | case BT_NMSTRT: \ | 107 | case BT_NMSTRT: \ |
| 79 | case BT_HEX: \ | 108 | case BT_HEX: \ |
| 80 | ptr += MINBPC(enc); \ | 109 | ptr += MINBPC(enc); \ |
| @@ -575,7 +604,7 @@ PREFIX(scanAtts)(const ENCODING *enc, const char *ptr, const char *end, | |||
| 575 | return XML_TOK_INVALID; | 604 | return XML_TOK_INVALID; |
| 576 | } | 605 | } |
| 577 | } | 606 | } |
| 578 | /* fall through */ | 607 | /* fall through */ |
| 579 | case BT_EQUALS: | 608 | case BT_EQUALS: |
| 580 | { | 609 | { |
| 581 | int open; | 610 | int open; |
| @@ -1198,8 +1227,14 @@ PREFIX(attributeValueTok)(const ENCODING *enc, const char *ptr, | |||
| 1198 | const char *start; | 1227 | const char *start; |
| 1199 | if (ptr >= end) | 1228 | if (ptr >= end) |
| 1200 | return XML_TOK_NONE; | 1229 | return XML_TOK_NONE; |
| 1201 | else if (! HAS_CHAR(enc, ptr, end)) | 1230 | else if (! HAS_CHAR(enc, ptr, end)) { |
| 1202 | return XML_TOK_PARTIAL; | 1231 | /* This line cannot be executed. The incoming data has already |
| 1232 | * been tokenized once, so incomplete characters like this have | ||
| 1233 | * already been eliminated from the input. Retaining the paranoia | ||
| 1234 | * check is still valuable, however. | ||
| 1235 | */ | ||
| 1236 | return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ | ||
| 1237 | } | ||
| 1203 | start = ptr; | 1238 | start = ptr; |
| 1204 | while (HAS_CHAR(enc, ptr, end)) { | 1239 | while (HAS_CHAR(enc, ptr, end)) { |
| 1205 | switch (BYTE_TYPE(enc, ptr)) { | 1240 | switch (BYTE_TYPE(enc, ptr)) { |
| @@ -1258,8 +1293,14 @@ PREFIX(entityValueTok)(const ENCODING *enc, const char *ptr, | |||
| 1258 | const char *start; | 1293 | const char *start; |
| 1259 | if (ptr >= end) | 1294 | if (ptr >= end) |
| 1260 | return XML_TOK_NONE; | 1295 | return XML_TOK_NONE; |
| 1261 | else if (! HAS_CHAR(enc, ptr, end)) | 1296 | else if (! HAS_CHAR(enc, ptr, end)) { |
| 1262 | return XML_TOK_PARTIAL; | 1297 | /* This line cannot be executed. The incoming data has already |
| 1298 | * been tokenized once, so incomplete characters like this have | ||
| 1299 | * already been eliminated from the input. Retaining the paranoia | ||
| 1300 | * check is still valuable, however. | ||
| 1301 | */ | ||
| 1302 | return XML_TOK_PARTIAL; /* LCOV_EXCL_LINE */ | ||
| 1303 | } | ||
| 1263 | start = ptr; | 1304 | start = ptr; |
| 1264 | while (HAS_CHAR(enc, ptr, end)) { | 1305 | while (HAS_CHAR(enc, ptr, end)) { |
| 1265 | switch (BYTE_TYPE(enc, ptr)) { | 1306 | switch (BYTE_TYPE(enc, ptr)) { |
| @@ -1403,6 +1444,7 @@ PREFIX(isPublicId)(const ENCODING *enc, const char *ptr, const char *end, | |||
| 1403 | case BT_NMSTRT: | 1444 | case BT_NMSTRT: |
| 1404 | if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) | 1445 | if (!(BYTE_TO_ASCII(enc, ptr) & ~0x7f)) |
| 1405 | break; | 1446 | break; |
| 1447 | /* fall through */ | ||
| 1406 | default: | 1448 | default: |
| 1407 | switch (BYTE_TO_ASCII(enc, ptr)) { | 1449 | switch (BYTE_TO_ASCII(enc, ptr)) { |
| 1408 | case 0x24: /* $ */ | 1450 | case 0x24: /* $ */ |
| @@ -1615,76 +1657,18 @@ PREFIX(predefinedEntityName)(const ENCODING *UNUSED_P(enc), const char *ptr, | |||
| 1615 | } | 1657 | } |
| 1616 | 1658 | ||
| 1617 | static int PTRCALL | 1659 | static int PTRCALL |
| 1618 | PREFIX(sameName)(const ENCODING *enc, const char *ptr1, const char *ptr2) | ||
| 1619 | { | ||
| 1620 | for (;;) { | ||
| 1621 | switch (BYTE_TYPE(enc, ptr1)) { | ||
| 1622 | #define LEAD_CASE(n) \ | ||
| 1623 | case BT_LEAD ## n: \ | ||
| 1624 | if (*ptr1++ != *ptr2++) \ | ||
| 1625 | return 0; | ||
| 1626 | LEAD_CASE(4) LEAD_CASE(3) LEAD_CASE(2) | ||
| 1627 | #undef LEAD_CASE | ||
| 1628 | /* fall through */ | ||
| 1629 | if (*ptr1++ != *ptr2++) | ||
| 1630 | return 0; | ||
| 1631 | break; | ||
| 1632 | case BT_NONASCII: | ||
| 1633 | case BT_NMSTRT: | ||
| 1634 | #ifdef XML_NS | ||
| 1635 | case BT_COLON: | ||
| 1636 | #endif | ||
| 1637 | case BT_HEX: | ||
| 1638 | case BT_DIGIT: | ||
| 1639 | case BT_NAME: | ||
| 1640 | case BT_MINUS: | ||
| 1641 | if (*ptr2++ != *ptr1++) | ||
| 1642 | return 0; | ||
| 1643 | if (MINBPC(enc) > 1) { | ||
| 1644 | if (*ptr2++ != *ptr1++) | ||
| 1645 | return 0; | ||
| 1646 | if (MINBPC(enc) > 2) { | ||
| 1647 | if (*ptr2++ != *ptr1++) | ||
| 1648 | return 0; | ||
| 1649 | if (MINBPC(enc) > 3) { | ||
| 1650 | if (*ptr2++ != *ptr1++) | ||
| 1651 | return 0; | ||
| 1652 | } | ||
| 1653 | } | ||
| 1654 | } | ||
| 1655 | break; | ||
| 1656 | default: | ||
| 1657 | if (MINBPC(enc) == 1 && *ptr1 == *ptr2) | ||
| 1658 | return 1; | ||
| 1659 | switch (BYTE_TYPE(enc, ptr2)) { | ||
| 1660 | case BT_LEAD2: | ||
| 1661 | case BT_LEAD3: | ||
| 1662 | case BT_LEAD4: | ||
| 1663 | case BT_NONASCII: | ||
| 1664 | case BT_NMSTRT: | ||
| 1665 | #ifdef XML_NS | ||
| 1666 | case BT_COLON: | ||
| 1667 | #endif | ||
| 1668 | case BT_HEX: | ||
| 1669 | case BT_DIGIT: | ||
| 1670 | case BT_NAME: | ||
| 1671 | case BT_MINUS: | ||
| 1672 | return 0; | ||
| 1673 | default: | ||
| 1674 | return 1; | ||
| 1675 | } | ||
| 1676 | } | ||
| 1677 | } | ||
| 1678 | /* not reached */ | ||
| 1679 | } | ||
| 1680 | |||
| 1681 | static int PTRCALL | ||
| 1682 | PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1, | 1660 | PREFIX(nameMatchesAscii)(const ENCODING *UNUSED_P(enc), const char *ptr1, |
| 1683 | const char *end1, const char *ptr2) | 1661 | const char *end1, const char *ptr2) |
| 1684 | { | 1662 | { |
| 1685 | for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { | 1663 | for (; *ptr2; ptr1 += MINBPC(enc), ptr2++) { |
| 1686 | if (end1 - ptr1 < MINBPC(enc)) | 1664 | if (end1 - ptr1 < MINBPC(enc)) { |
| 1687 | return 0; | 1665 | /* This line cannot be executed. The incoming data has already |
| 1666 | * been tokenized once, so incomplete characters like this have | ||
| 1667 | * already been eliminated from the input. Retaining the | ||
| 1668 | * paranoia check is still valuable, however. | ||
| 1669 | */ | ||
| 1670 | return 0; /* LCOV_EXCL_LINE */ | ||
| 1671 | } | ||
| 1688 | if (!CHAR_MATCHES(enc, ptr1, *ptr2)) | 1672 | if (!CHAR_MATCHES(enc, ptr1, *ptr2)) |
| 1689 | return 0; | 1673 | return 0; |
| 1690 | } | 1674 | } |
diff --git a/3rdParty/Expat/src/xmltok_impl.h b/3rdParty/Expat/src/xmltok_impl.h index da0ea60..a6420f4 100644 --- a/3rdParty/Expat/src/xmltok_impl.h +++ b/3rdParty/Expat/src/xmltok_impl.h | |||
| @@ -1,6 +1,33 @@ | |||
| 1 | /* | 1 | /* |
| 2 | Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 2 | __ __ _ |
| 3 | See the file COPYING for copying permission. | 3 | ___\ \/ /_ __ __ _| |_ |
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 4 | */ | 31 | */ |
| 5 | 32 | ||
| 6 | enum { | 33 | enum { |
diff --git a/3rdParty/Expat/src/xmltok_ns.c b/3rdParty/Expat/src/xmltok_ns.c index c3b88fd..23d31e8 100644 --- a/3rdParty/Expat/src/xmltok_ns.c +++ b/3rdParty/Expat/src/xmltok_ns.c | |||
| @@ -1,8 +1,35 @@ | |||
| 1 | /* Copyright (c) 1998, 1999 Thai Open Source Software Center Ltd | 1 | /* This file is included! |
| 2 | See the file COPYING for copying permission. | 2 | __ __ _ |
| 3 | ___\ \/ /_ __ __ _| |_ | ||
| 4 | / _ \\ /| '_ \ / _` | __| | ||
| 5 | | __// \| |_) | (_| | |_ | ||
| 6 | \___/_/\_\ .__/ \__,_|\__| | ||
| 7 | |_| XML parser | ||
| 8 | |||
| 9 | Copyright (c) 1997-2000 Thai Open Source Software Center Ltd | ||
| 10 | Copyright (c) 2000-2017 Expat development team | ||
| 11 | Licensed under the MIT license: | ||
| 12 | |||
| 13 | Permission is hereby granted, free of charge, to any person obtaining | ||
| 14 | a copy of this software and associated documentation files (the | ||
| 15 | "Software"), to deal in the Software without restriction, including | ||
| 16 | without limitation the rights to use, copy, modify, merge, publish, | ||
| 17 | distribute, sublicense, and/or sell copies of the Software, and to permit | ||
| 18 | persons to whom the Software is furnished to do so, subject to the | ||
| 19 | following conditions: | ||
| 20 | |||
| 21 | The above copyright notice and this permission notice shall be included | ||
| 22 | in all copies or substantial portions of the Software. | ||
| 23 | |||
| 24 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 25 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 26 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN | ||
| 27 | NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, | ||
| 28 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR | ||
| 29 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE | ||
| 30 | USE OR OTHER DEALINGS IN THE SOFTWARE. | ||
| 3 | */ | 31 | */ |
| 4 | 32 | ||
| 5 | /* This file is included! */ | ||
| 6 | #ifdef XML_TOK_NS_C | 33 | #ifdef XML_TOK_NS_C |
| 7 | 34 | ||
| 8 | const ENCODING * | 35 | const ENCODING * |
Swift