-
+XML_GetBuffer
+
void * XMLCALL
XML_GetBuffer(XML_Parser p,
int len);
@@ -1098,7 +1142,8 @@ for (;;) {
-
+XML_StopParser
+
enum XML_Status XMLCALL
XML_StopParser(XML_Parser p,
XML_Bool resumable);
@@ -1111,7 +1156,7 @@ XML_StopParser(XML_Parser p,
call-back handler, except when aborting (when resumable
is XML_FALSE
) an already suspended parser. Some
call-backs may still follow because they would otherwise get
-lost, including
+lost, including
- the end element handler for empty elements when stopped in the
start element handler,
@@ -1120,7 +1165,7 @@ lost, including
- the character data handler when stopped in the character data handler
while making multiple call-backs on a contiguous chunk of characters,
-and possibly others.
+and possibly others.
This can be called from most handlers, including DTD related
call-backs, except when parsing an external parameter entity and
@@ -1166,7 +1211,8 @@ implementation of that handler to call New in Expat 1.95.8.
-
+XML_ResumeParser
+
enum XML_Status XMLCALL
XML_ResumeParser(XML_Parser p);
@@ -1191,7 +1237,8 @@ appropriate moment.
New in Expat 1.95.8.
-
+XML_GetParsingStatus
+
void XMLCALL
XML_GetParsingStatus(XML_Parser p,
XML_ParsingStatus *status);
@@ -1240,7 +1287,8 @@ Note that you'll receive them in this form independent of the original
encoding of the document.
-
+XML_SetStartElementHandler
+
void XMLCALL
XML_SetStartElementHandler(XML_Parser p,
XML_StartElementHandler start);
@@ -1261,7 +1309,8 @@ by a null pointer.
-
+XML_SetEndElementHandler
+
void XMLCALL
XML_SetEndElementHandler(XML_Parser p,
XML_EndElementHandler);
@@ -1276,7 +1325,8 @@ generates a call to both start and end handlers.
-
+XML_SetElementHandler
+
void XMLCALL
XML_SetElementHandler(XML_Parser p,
XML_StartElementHandler start,
@@ -1286,7 +1336,8 @@ XML_SetElementHandler(XML_Parser p,
-
+XML_SetCharacterDataHandler
+
void XMLCALL
XML_SetCharacterDataHandler(XML_Parser p,
XML_CharacterDataHandler charhndl)
@@ -1309,7 +1360,8 @@ will continue calling back until the end of the block is reached.
-
+XML_SetProcessingInstructionHandler
+
void XMLCALL
XML_SetProcessingInstructionHandler(XML_Parser p,
XML_ProcessingInstructionHandler proc)
@@ -1327,7 +1379,8 @@ it after skipping all whitespace after the initial word.
-
+
+
void XMLCALL
XML_SetCommentHandler(XML_Parser p,
XML_CommentHandler cmnt)
@@ -1342,7 +1395,8 @@ delimiters.
-
+XML_SetStartCdataSectionHandler
+
void XMLCALL
XML_SetStartCdataSectionHandler(XML_Parser p,
XML_StartCdataSectionHandler start);
@@ -1355,7 +1409,8 @@ typedef void
-
+XML_SetEndCdataSectionHandler
+
void XMLCALL
XML_SetEndCdataSectionHandler(XML_Parser p,
XML_EndCdataSectionHandler end);
@@ -1368,7 +1423,8 @@ typedef void
-
+XML_SetCdataSectionHandler
+
void XMLCALL
XML_SetCdataSectionHandler(XML_Parser p,
XML_StartCdataSectionHandler start,
@@ -1378,7 +1434,8 @@ XML_SetCdataSectionHandler(XML_Parser p,
-
+XML_SetDefaultHandler
+
void XMLCALL
XML_SetDefaultHandler(XML_Parser p,
XML_DefaultHandler hndl)
@@ -1409,7 +1466,8 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent.
-
+XML_SetDefaultHandlerExpand
+
void XMLCALL
XML_SetDefaultHandlerExpand(XML_Parser p,
XML_DefaultHandler hndl)
@@ -1429,7 +1487,8 @@ href="#XML_DefaultCurrent">XML_DefaultCurrent.
-
+XML_SetExternalEntityRefHandler
+
void XMLCALL
XML_SetExternalEntityRefHandler(XML_Parser p,
XML_ExternalEntityRefHandler hndl)
@@ -1482,7 +1541,8 @@ parser, the body of the external entity can be recursively parsed.
information into global or static variables.
-
+XML_SetExternalEntityRefHandlerArg
+
void XMLCALL
XML_SetExternalEntityRefHandlerArg(XML_Parser p,
void *arg)
@@ -1508,7 +1568,8 @@ properly.
-
+XML_SetSkippedEntityHandler
+
void XMLCALL
XML_SetSkippedEntityHandler(XML_Parser p,
XML_SkippedEntityHandler handler)
@@ -1528,14 +1589,15 @@ typedef void
has been called.
The is_parameter_entity
argument will be non-zero for
-a parameter entity and zero for a general entity.
Note: skipped
+a parameter entity and zero for a general entity.
Note: Skipped
parameter entities in declarations and skipped general entities in
attribute values cannot be reported, because the event would be out of
sync with the reporting of the declarations or attribute values
-
+XML_SetUnknownEncodingHandler
+
void XMLCALL
XML_SetUnknownEncodingHandler(XML_Parser p,
XML_UnknownEncodingHandler enchandler,
@@ -1584,7 +1646,8 @@ parser when it is finished with the encoding. It may be NULL.
-
+XML_SetStartNamespaceDeclHandler
+
void XMLCALL
XML_SetStartNamespaceDeclHandler(XML_Parser p,
XML_StartNamespaceDeclHandler start);
@@ -1602,7 +1665,8 @@ in that start tag.
-
+XML_SetEndNamespaceDeclHandler
+
void XMLCALL
XML_SetEndNamespaceDeclHandler(XML_Parser p,
XML_EndNamespaceDeclHandler end);
@@ -1619,7 +1683,8 @@ namespace was declared.
-
+XML_SetNamespaceDeclHandler
+
void XMLCALL
XML_SetNamespaceDeclHandler(XML_Parser p,
XML_StartNamespaceDeclHandler start,
@@ -1629,7 +1694,8 @@ XML_SetNamespaceDeclHandler(XML_Parser p,
-
+XML_SetXmlDeclHandler
+
void XMLCALL
XML_SetXmlDeclHandler(XML_Parser p,
XML_XmlDeclHandler xmldecl);
@@ -1652,7 +1718,8 @@ that it was given as yes.
-
+XML_SetStartDoctypeDeclHandler
+
void XMLCALL
XML_SetStartDoctypeDeclHandler(XML_Parser p,
XML_StartDoctypeDeclHandler start);
@@ -1672,7 +1739,8 @@ will be non-zero if the DOCTYPE declaration has an internal subset.
-
+XML_SetEndDoctypeDeclHandler
+
void XMLCALL
XML_SetEndDoctypeDeclHandler(XML_Parser p,
XML_EndDoctypeDeclHandler end);
@@ -1686,7 +1754,8 @@ after parsing any external subset.
-
+XML_SetDoctypeDeclHandler
+
void XMLCALL
XML_SetDoctypeDeclHandler(XML_Parser p,
XML_StartDoctypeDeclHandler start,
@@ -1696,7 +1765,8 @@ XML_SetDoctypeDeclHandler(XML_Parser p,
-
+XML_SetElementDeclHandler
+
void XMLCALL
XML_SetElementDeclHandler(XML_Parser p,
XML_ElementDeclHandler eldecl);
@@ -1768,7 +1838,8 @@ or sequence and children
points to the nodes.
-
+XML_SetAttlistDeclHandler
+
void XMLCALL
XML_SetAttlistDeclHandler(XML_Parser p,
XML_AttlistDeclHandler attdecl);
@@ -1801,7 +1872,8 @@ in the dflt
parameter.
-
+XML_SetEntityDeclHandler
+
void XMLCALL
XML_SetEntityDeclHandler(XML_Parser p,
XML_EntityDeclHandler handler);
@@ -1835,7 +1907,8 @@ declarations.
-
+XML_SetUnparsedEntityDeclHandler
+
void XMLCALL
XML_SetUnparsedEntityDeclHandler(XML_Parser p,
XML_UnparsedEntityDeclHandler h)
@@ -1861,7 +1934,8 @@ compatibility. Use instead
-
+XML_SetNotationDeclHandler
+
void XMLCALL
XML_SetNotationDeclHandler(XML_Parser p,
XML_NotationDeclHandler h)
@@ -1878,7 +1952,8 @@ typedef void
-
+XML_SetNotStandaloneHandler
+
void XMLCALL
XML_SetNotStandaloneHandler(XML_Parser p,
XML_NotStandaloneHandler h)
@@ -1913,7 +1988,8 @@ events.
DTD. In other words, they usually return bogus information when
called from within a DTD declaration handler.
-
+XML_GetErrorCode
+
enum XML_Error XMLCALL
XML_GetErrorCode(XML_Parser p);
@@ -1921,7 +1997,8 @@ XML_GetErrorCode(XML_Parser p);
Return what type of error has occurred.
-
+XML_ErrorString
+
const XML_LChar * XMLCALL
XML_ErrorString(enum XML_Error code);
@@ -1931,7 +2008,8 @@ The code should be one of the enums that can be returned from
XML_GetErrorCode
.
-
+XML_GetCurrentByteIndex
+
XML_Index XMLCALL
XML_GetCurrentByteIndex(XML_Parser p);
@@ -1942,7 +2020,8 @@ the values returned by XML_GetCurrentColumnNumber
.
-
+XML_GetCurrentLineNumber
+
XML_Size XMLCALL
XML_GetCurrentLineNumber(XML_Parser p);
@@ -1951,7 +2030,8 @@ Return the line number of the position. The first line is reported as
1
.
-
+XML_GetCurrentColumnNumber
+
XML_Size XMLCALL
XML_GetCurrentColumnNumber(XML_Parser p);
@@ -1960,7 +2040,8 @@ Return the offset, from the beginning of the current line, of
the position.
-
+XML_GetCurrentByteCount
+
int XMLCALL
XML_GetCurrentByteCount(XML_Parser p);
@@ -1972,7 +2053,8 @@ be used to distinguish empty-element tags from empty elements using
separate start and end tags).
-
+XML_GetInputContext
+
const char * XMLCALL
XML_GetInputContext(XML_Parser p,
int *offset,
@@ -1998,12 +2080,105 @@ parse position may be before the beginning of the buffer.
return NULL.
+
+
+The functions in this section configure the built-in
+ protection against various forms of
+ billion laughs attacks.
+
+XML_SetBillionLaughsAttackProtectionMaximumAmplification
+
+/* Added in Expat 2.4.0. */
+XML_Bool XMLCALL
+XML_SetBillionLaughsAttackProtectionMaximumAmplification(XML_Parser p,
+ float maximumAmplificationFactor);
+
+
+
+ Sets the maximum tolerated amplification factor
+ for protection against
+ billion laughs attacks
+ (default: 100.0
)
+ of parser p
to maximumAmplificationFactor
, and
+ returns XML_TRUE
upon success and XML_TRUE
upon error.
+
+
+ The amplification factor is calculated as ..
+
+ amplification := (direct + indirect) / direct
+
+ .. while parsing, whereas
+
direct
is the number of bytes read from the primary document in parsing and
+
indirect
is the number of bytes added by expanding entities and reading of external DTD files, combined.
+
+
For a call to XML_SetBillionLaughsAttackProtectionMaximumAmplification
to succeed:
+
+ - parser
p
must be a non-NULL
root parser (without any parent parsers) and
+ maximumAmplificationFactor
must be non-NaN
and greater than or equal to 1.0
.
+
+
+
+ Note:
+ If you ever need to increase this value for non-attack payload,
+ please file a bug report.
+
+
+
+ Note:
+ Peak amplifications
+ of factor 15,000 for the entire payload and
+ of factor 30,000 in the middle of parsing
+ have been observed with small benign files in practice.
+
+ So if you do reduce the maximum allowed amplification,
+ please make sure that the activation threshold is still big enough
+ to not end up with undesired false positives (i.e. benign files being rejected).
+
+
+
+XML_SetBillionLaughsAttackProtectionActivationThreshold
+
+/* Added in Expat 2.4.0. */
+XML_Bool XMLCALL
+XML_SetBillionLaughsAttackProtectionActivationThreshold(XML_Parser p,
+ unsigned long long activationThresholdBytes);
+
+
+
+ Sets number of output bytes (including amplification from entity expansion and reading DTD files)
+ needed to activate protection against
+ billion laughs attacks
+ (default: 8 MiB
)
+ of parser p
to activationThresholdBytes
, and
+ returns XML_TRUE
upon success and XML_TRUE
upon error.
+
+
+
For a call to XML_SetBillionLaughsAttackProtectionActivationThreshold
to succeed:
+
+ - parser
p
must be a non-NULL
root parser (without any parent parsers).
+
+
+
+ Note:
+ If you ever need to increase this value for non-attack payload,
+ please file a bug report.
+
+
+
+ Note:
+ Activation thresholds below 4 MiB are known to break support for
+ DITA 1.3 payload
+ and are hence not recommended.
+
+
+
The functions in this section either obtain state information from
the parser or can be used to dynamically set parser options.
-
+XML_SetUserData
+
void XMLCALL
XML_SetUserData(XML_Parser p,
void *userData);
@@ -2018,7 +2193,8 @@ the memory associated with it, then you've probably just leaked
memory.
-
+XML_GetUserData
+
void * XMLCALL
XML_GetUserData(XML_Parser p);
@@ -2027,7 +2203,8 @@ This returns the user data pointer that gets passed to handlers.
It is actually implemented as a macro.
-
+XML_UseParserAsHandlerArg
+
void XMLCALL
XML_UseParserAsHandlerArg(XML_Parser p);
@@ -2038,7 +2215,8 @@ using the XML_GetUserData
function.
-
+XML_SetBase
+
enum XML_Status XMLCALL
XML_SetBase(XML_Parser p,
const XML_Char *base);
@@ -2050,7 +2228,8 @@ there's no memory to store base, otherwise it's
XML_STATUS_OK
.
-
+XML_GetBase
+
const XML_Char * XMLCALL
XML_GetBase(XML_Parser p);
@@ -2058,7 +2237,8 @@ XML_GetBase(XML_Parser p);
Return the base for resolving relative URIs.
-
+XML_GetSpecifiedAttributeCount
+
int XMLCALL
XML_GetSpecifiedAttributeCount(XML_Parser p);
@@ -2074,7 +2254,8 @@ call to a start handler. If called inside a start handler, then that
means the current call.
-
+XML_GetIdAttributeIndex
+
int XMLCALL
XML_GetIdAttributeIndex(XML_Parser p);
@@ -2086,7 +2267,8 @@ attribute. If called inside a start handler, then that means the
current call.
-
+XML_GetAttributeInfo
+
const XML_AttrInfo * XMLCALL
XML_GetAttributeInfo(XML_Parser parser);
@@ -2107,7 +2289,8 @@ as 1; thus the number of entries in the array is
XML_GetSpecifiedAttributeCount(parser) / 2
.
-
+XML_SetEncoding
+
enum XML_Status XMLCALL
XML_SetEncoding(XML_Parser p,
const XML_Char *encoding);
@@ -2122,7 +2305,8 @@ Returns XML_STATUS_OK
on success or
XML_STATUS_ERROR
on error.
-
+XML_SetParamEntityParsing
+
int XMLCALL
XML_SetParamEntityParsing(XML_Parser p,
enum XML_ParamEntityParsing code);
@@ -2142,7 +2326,8 @@ The choices for code
are:
no effect and will always return 0.
-
+XML_SetHashSalt
+
int XMLCALL
XML_SetHashSalt(XML_Parser p,
unsigned long hash_salt);
@@ -2153,15 +2338,16 @@ Helps in preventing DoS attacks based on predicting hash
function behavior. In order to have an effect this must be called
before parsing has started. Returns 1 if successful, 0 when called
after XML_Parse
or XML_ParseBuffer
.
-Note:This call is optional, as the parser will auto-generate
+
Note: This call is optional, as the parser will auto-generate
a new random salt value if no value has been set at the start of parsing.
-Note:One should not call XML_SetHashSalt
with a
+
Note: One should not call XML_SetHashSalt
with a
hash salt value of 0, as this value is used as sentinel value to indicate
that XML_SetHashSalt
has not been called. Consequently
such a call will have no effect, even if it returns 1.
-
+XML_UseForeignDTD
+
enum XML_Error XMLCALL
XML_UseForeignDTD(XML_Parser parser, XML_Bool useDTD);
@@ -2198,7 +2384,8 @@ the document had a DTD with an external subset. This holds true even if
the external entity reference handler returns without action.
-
+XML_SetReturnNSTriplet
+
void XMLCALL
XML_SetReturnNSTriplet(XML_Parser parser,
int do_nst);
@@ -2220,7 +2407,8 @@ default manner, URI then local_name separated by the namespace
separator.
-
+XML_DefaultCurrent
+
void XMLCALL
XML_DefaultCurrent(XML_Parser parser);
@@ -2234,7 +2422,8 @@ href="#XML_SetDefaultHandler" >XML_SetDefaultHandler