Skip to content

Commit cd040bf

Browse files
committed
improve various wordings
1 parent b01e53d commit cd040bf

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

Doc/library/pyexpat.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -232,24 +232,24 @@ XMLParser Objects
232232

233233

234234
:class:`xmlparser` objects have the following methods to mitigate some
235-
well-known XML vulnerabilities.
235+
common XML vulnerabilities.
236236

237237
.. method:: xmlparser.SetAllocTrackerMaximumAmplification(max_factor, /)
238238

239239
Sets the maximum amplification factor between direct input and bytes
240240
of dynamic memory allocated.
241241

242-
By default, parsers objects have a maximum amplification factor of 100.
243-
244242
The amplification factor is calculated as ``allocated / direct``
245243
while parsing, where ``direct`` is the number of bytes read from
246244
the primary document in parsing and ``allocated`` is the number
247245
of bytes of dynamic memory allocated in the parser hierarchy.
248246

249247
The *max_factor* value must be a non-NaN :class:`float` value greater than
250-
or equal to 1.0. Amplifications factors greater than 100 can been observed
251-
near the start of parsing even with benign files in practice. As such, the
252-
activation threshold should be carefully chosen to avoid false positives.
248+
or equal to 1.0. Amplification factors greater than 100.0 can be observed
249+
near the start of parsing even with benign files in practice. In particular,
250+
the activation threshold should be carefully chosen to avoid false positives.
251+
252+
By default, parser objects have a maximum amplification factor of 100.0.
253253

254254
An :exc:`ExpatError` is raised if this method is called on a non-root
255255
parser or if *max_factor* is outside the valid range.
@@ -269,7 +269,7 @@ well-known XML vulnerabilities.
269269
Sets the number of allocated bytes of dynamic memory needed to activate
270270
protection against disproportionate use of RAM.
271271

272-
By default, parsers objects have an allocation activation threshold of 64 MiB,
272+
By default, parser objects have an allocation activation threshold of 64 MiB,
273273
or equivalently 67,108,864 bytes.
274274

275275
An :exc:`ExpatError` is raised if this method is called on a non-root parser.

Lib/test/test_pyexpat.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -868,7 +868,7 @@ def test_set_alloc_tracker_maximum_amplification(self):
868868
self.assertIsNone(p.SetAllocTrackerMaximumAmplification(10_000))
869869
self.assertIsNotNone(p.Parse(payload, True))
870870

871-
def test_set_alloc_tracker_maximum_amplification_infty(self):
871+
def test_set_alloc_tracker_maximum_amplification_infinity(self):
872872
inf = float('inf') # an 'inf' threshold is allowed
873873
parser = expat.ParserCreate()
874874
self.assertIsNone(parser.SetAllocTrackerMaximumAmplification(inf))

Modules/clinic/pyexpat.c.h

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

Modules/pyexpat.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1193,24 +1193,24 @@ pyexpat.xmlparser.SetAllocTrackerMaximumAmplification
11931193
11941194
Sets the maximum amplification factor between direct input and bytes of dynamic memory allocated.
11951195
1196-
By default, parsers objects have a maximum amplification factor of 100.
1197-
11981196
The amplification factor is calculated as "allocated / direct" while parsing,
11991197
where "direct" is the number of bytes read from the primary document in parsing
12001198
and "allocated" is the number of bytes of dynamic memory allocated in the parser
12011199
hierarchy.
12021200
12031201
The 'max_factor' value must be a non-NaN floating point value greater than
1204-
or equal to 1.0. Amplifications factors greater than 100 can been observed
1205-
near the start of parsing even with benign files in practice. As such, the
1206-
activation threshold should be carefully chosen to avoid false positives.
1202+
or equal to 1.0. Amplification factors greater than 100.0 can be observed
1203+
near the start of parsing even with benign files in practice. In particular,
1204+
the activation threshold should be carefully chosen to avoid false positives.
1205+
1206+
By default, parser objects have a maximum amplification factor of 100.0.
12071207
[clinic start generated code]*/
12081208

12091209
static PyObject *
12101210
pyexpat_xmlparser_SetAllocTrackerMaximumAmplification_impl(xmlparseobject *self,
12111211
PyTypeObject *cls,
12121212
float max_factor)
1213-
/*[clinic end generated code: output=6e44bd48c9b112a0 input=23ca8b8f7de04462]*/
1213+
/*[clinic end generated code: output=6e44bd48c9b112a0 input=e4f48064c79bf323]*/
12141214
{
12151215
#if XML_COMBINED_VERSION >= 20702
12161216
assert(self->itself != NULL);
@@ -1250,14 +1250,14 @@ pyexpat.xmlparser.SetAllocTrackerActivationThreshold
12501250
12511251
Sets the number of allocated bytes of dynamic memory needed to activate protection against disproportionate use of RAM.
12521252
1253-
By default, parsers objects have an allocation activation threshold of 64 MiB.
1253+
By default, parser objects have an allocation activation threshold of 64 MiB.
12541254
[clinic start generated code]*/
12551255

12561256
static PyObject *
12571257
pyexpat_xmlparser_SetAllocTrackerActivationThreshold_impl(xmlparseobject *self,
12581258
PyTypeObject *cls,
12591259
unsigned long long threshold)
1260-
/*[clinic end generated code: output=bed7e93207ba08c5 input=8453509a137a47c0]*/
1260+
/*[clinic end generated code: output=bed7e93207ba08c5 input=54182cd71ad69978]*/
12611261
{
12621262
#if XML_COMBINED_VERSION >= 20702
12631263
assert(self->itself != NULL);

0 commit comments

Comments
 (0)