77 |_| XML parser
88
99 Copyright (c) 1997-2000 Thai Open Source Software Center Ltd
10- Copyright (c) 2000-2017 Expat development team
10+ Copyright (c) 2000 Clark Cooper <[email protected] > 11+ Copyright (c) 2000-2005 Fred L. Drake, Jr. <[email protected] > 12+ Copyright (c) 2001-2002 Greg Stein <[email protected] > 13+ Copyright (c) 2002-2016 Karl Waclawek <[email protected] > 14+ Copyright (c) 2016-2022 Sebastian Pipping <[email protected] > 15+ Copyright (c) 2016 Cristian Rodríguez <[email protected] > 16+ Copyright (c) 2016 Thomas Beutlich <[email protected] > 17+ Copyright (c) 2017 Rhodri James <[email protected] > 18+ Copyright (c) 2022 Thijs Schreijer <[email protected] > 1119 Licensed under the MIT license:
1220
1321 Permission is hereby granted, free of charge, to any person obtaining
@@ -115,7 +123,11 @@ enum XML_Error {
115123 XML_ERROR_RESERVED_PREFIX_XMLNS,
116124 XML_ERROR_RESERVED_NAMESPACE_URI,
117125 /* Added in 2.2.1. */
118- XML_ERROR_INVALID_ARGUMENT
126+ XML_ERROR_INVALID_ARGUMENT,
127+ /* Added in 2.3.0. */
128+ XML_ERROR_NO_BUFFER,
129+ /* Added in 2.4.0. */
130+ XML_ERROR_AMPLIFICATION_LIMIT_BREACH
119131};
120132
121133enum XML_Content_Type {
@@ -163,8 +175,10 @@ struct XML_cp {
163175};
164176
165177/* This is called for an element declaration. See above for
166- description of the model argument. It's the caller's responsibility
167- to free model when finished with it.
178+ description of the model argument. It's the user code's responsibility
179+ to free model when finished with it. See XML_FreeContentModel.
180+ There is no need to free the model from the handler, it can be kept
181+ around and freed at a later stage.
168182*/
169183typedef void (XMLCALL *XML_ElementDeclHandler)(void *userData,
170184 const XML_Char *name,
@@ -226,6 +240,17 @@ XML_ParserCreate(const XML_Char *encoding);
226240 and the local part will be concatenated without any separator.
227241 It is a programming error to use the separator '\0' with namespace
228242 triplets (see XML_SetReturnNSTriplet).
243+ If a namespace separator is chosen that can be part of a URI or
244+ part of an XML name, splitting an expanded name back into its
245+ 1, 2 or 3 original parts on application level in the element handler
246+ may end up vulnerable, so these are advised against; sane choices for
247+ a namespace separator are e.g. '\n' (line feed) and '|' (pipe).
248+
249+ Note that Expat does not validate namespace URIs (beyond encoding)
250+ against RFC 3986 today (and is not required to do so with regard to
251+ the XML 1.0 namespaces specification) but it may start doing that
252+ in future releases. Before that, an application using Expat must
253+ be ready to receive namespace URIs containing non-URI characters.
229254*/
230255XMLPARSEAPI (XML_Parser)
231256XML_ParserCreateNS(const XML_Char *encoding, XML_Char namespaceSeparator);
@@ -306,7 +331,7 @@ typedef void(XMLCALL *XML_StartDoctypeDeclHandler)(void *userData,
306331 const XML_Char *pubid,
307332 int has_internal_subset);
308333
309- /* This is called for the start of the DOCTYPE declaration when the
334+ /* This is called for the end of the DOCTYPE declaration when the
310335 closing > is encountered, but after processing any external
311336 subset.
312337*/
@@ -318,7 +343,7 @@ typedef void(XMLCALL *XML_EndDoctypeDeclHandler)(void *userData);
318343
319344 For internal entities (<!ENTITY foo "bar">), value will
320345 be non-NULL and systemId, publicID, and notationName will be NULL.
321- The value string is NOT nul -terminated; the length is provided in
346+ The value string is NOT null -terminated; the length is provided in
322347 the value_length argument. Since it is legal to have zero-length
323348 values, do not use this argument to test for internal entities.
324349
@@ -513,7 +538,7 @@ typedef struct {
513538 Otherwise it must return XML_STATUS_ERROR.
514539
515540 If info does not describe a suitable encoding, then the parser will
516- return an XML_UNKNOWN_ENCODING error.
541+ return an XML_ERROR_UNKNOWN_ENCODING error.
517542*/
518543typedef int (XMLCALL *XML_UnknownEncodingHandler)(void *encodingHandlerData,
519544 const XML_Char *name,
@@ -707,7 +732,7 @@ XML_GetBase(XML_Parser parser);
707732/* Returns the number of the attribute/value pairs passed in last call
708733 to the XML_StartElementHandler that were specified in the start-tag
709734 rather than defaulted. Each attribute/value pair counts as 2; thus
710- this correspondds to an index into the atts array passed to the
735+ this corresponds to an index into the atts array passed to the
711736 XML_StartElementHandler. Returns -1 if parser == NULL.
712737*/
713738XMLPARSEAPI (int )
@@ -716,7 +741,7 @@ XML_GetSpecifiedAttributeCount(XML_Parser parser);
716741/* Returns the index of the ID attribute passed in the last call to
717742 XML_StartElementHandler, or -1 if there is no ID attribute or
718743 parser == NULL. Each attribute/value pair counts as 2; thus this
719- correspondds to an index into the atts array passed to the
744+ corresponds to an index into the atts array passed to the
720745 XML_StartElementHandler.
721746*/
722747XMLPARSEAPI (int )
@@ -997,7 +1022,10 @@ enum XML_FeatureEnum {
9971022 XML_FEATURE_SIZEOF_XML_LCHAR,
9981023 XML_FEATURE_NS,
9991024 XML_FEATURE_LARGE_SIZE,
1000- XML_FEATURE_ATTR_INFO
1025+ XML_FEATURE_ATTR_INFO,
1026+ /* Added in Expat 2.4.0. */
1027+ XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_MAXIMUM_AMPLIFICATION_DEFAULT,
1028+ XML_FEATURE_BILLION_LAUGHS_ATTACK_PROTECTION_ACTIVATION_THRESHOLD_DEFAULT
10011029 /* Additional features must be added to the end of this enum. */
10021030};
10031031
@@ -1010,12 +1038,24 @@ typedef struct {
10101038XMLPARSEAPI (const XML_Feature *)
10111039XML_GetFeatureList(void );
10121040
1041+ #ifdef XML_DTD
1042+ /* Added in Expat 2.4.0. */
1043+ XMLPARSEAPI (XML_Bool)
1044+ XML_SetBillionLaughsAttackProtectionMaximumAmplification(
1045+ XML_Parser parser, float maximumAmplificationFactor);
1046+
1047+ /* Added in Expat 2.4.0. */
1048+ XMLPARSEAPI (XML_Bool)
1049+ XML_SetBillionLaughsAttackProtectionActivationThreshold(
1050+ XML_Parser parser, unsigned long long activationThresholdBytes);
1051+ #endif
1052+
10131053/* Expat follows the semantic versioning convention.
10141054 See http://semver.org.
10151055*/
10161056#define XML_MAJOR_VERSION 2
1017- #define XML_MINOR_VERSION 2
1018- #define XML_MICRO_VERSION 8
1057+ #define XML_MINOR_VERSION 4
1058+ #define XML_MICRO_VERSION 7
10191059
10201060#ifdef __cplusplus
10211061}
0 commit comments