Skip to content

Commit 6c2eab7

Browse files
committed
clinic and comments
1 parent 9734458 commit 6c2eab7

File tree

3 files changed

+31
-10
lines changed

3 files changed

+31
-10
lines changed

Doc/library/pyexpat.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,11 @@ against some common XML vulnerabilities.
257257
The corresponding :attr:`~ExpatError.lineno` and :attr:`~ExpatError.offset`
258258
should not be used as they may have no special meaning.
259259

260+
.. note::
261+
262+
Activation thresholds below 4 MiB are known to break support for DITA 1.3
263+
payload and are hence not recommended.
264+
260265
.. versionadded:: next
261266

262267
.. method:: xmlparser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor, /)

Modules/clinic/pyexpat.c.h

Lines changed: 16 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Modules/pyexpat.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,15 +1230,21 @@ pyexpat.xmlparser.SetBillionLaughsAttackProtectionActivationThreshold
12301230
12311231
Sets the number of output bytes needed to activate protection against billion laughs attacks.
12321232
1233+
The number of output bytes includes amplification from entity expansion
1234+
and reading DTD files.
1235+
12331236
Parser objects usually have a protection activation threshold of 8 MiB,
12341237
but the actual default value depends on the underlying Expat library.
1238+
1239+
Activation thresholds below 4 MiB are known to break support for DITA 1.3
1240+
payload and are hence not recommended.
12351241
[clinic start generated code]*/
12361242

12371243
static PyObject *
12381244
pyexpat_xmlparser_SetBillionLaughsAttackProtectionActivationThreshold_impl(xmlparseobject *self,
12391245
PyTypeObject *cls,
12401246
unsigned long long threshold)
1241-
/*[clinic end generated code: output=0c082342f1c78114 input=a420a76f682ffc76]*/
1247+
/*[clinic end generated code: output=0c082342f1c78114 input=fa2f91f26b62a42a]*/
12421248
{
12431249
return set_activation_threshold(
12441250
self, cls, threshold,
@@ -1277,7 +1283,7 @@ static PyObject *
12771283
pyexpat_xmlparser_SetBillionLaughsAttackProtectionMaximumAmplification_impl(xmlparseobject *self,
12781284
PyTypeObject *cls,
12791285
float max_factor)
1280-
/*[clinic end generated code: output=c590439eadf463fa input=c5bae55c9b25d045]*/
1286+
/*[clinic end generated code: output=c590439eadf463fa input=cc1e97c1fd2bd950]*/
12811287
{
12821288
return set_maximum_amplification(
12831289
self, cls, max_factor,
@@ -1306,7 +1312,7 @@ static PyObject *
13061312
pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(xmlparseobject *self,
13071313
PyTypeObject *cls,
13081314
unsigned long long threshold)
1309-
/*[clinic end generated code: output=bed7e93207ba08c5 input=54182cd71ad69978]*/
1315+
/*[clinic end generated code: output=bed7e93207ba08c5 input=b7a7a3e3d054286a]*/
13101316
{
13111317
return set_activation_threshold(
13121318
self, cls, threshold,
@@ -1345,7 +1351,7 @@ static PyObject *
13451351
pyexpat_xmlparser_SetAllocTrackerMaximumAmplification_impl(xmlparseobject *self,
13461352
PyTypeObject *cls,
13471353
float max_factor)
1348-
/*[clinic end generated code: output=6e44bd48c9b112a0 input=aac2029e96e80b03]*/
1354+
/*[clinic end generated code: output=6e44bd48c9b112a0 input=c6af7ccb76ae5c6b]*/
13491355
{
13501356
return set_maximum_amplification(
13511357
self, cls, max_factor,

0 commit comments

Comments
 (0)