]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-90949: expose Expat API to tune exponential expansion protections (#139368)
authorBénédikt Tran <10796600+picnixz@users.noreply.github.com>
Sun, 28 Sep 2025 08:27:04 +0000 (10:27 +0200)
committerGitHub <noreply@github.com>
Sun, 28 Sep 2025 08:27:04 +0000 (08:27 +0000)
commit666112376d574c7802646ee1df6244062671cd61
tree37f0c23b887144d984610d97e6d2e6ad582f45b4
parent48d0d0dd9733eae4935f2ebd31bef786d8074fc8
gh-90949: expose Expat API to tune exponential expansion protections (#139368)

Expose the XML Expat 2.7.2 APIs to tune protections against
"billion laughs" [1] attacks.

The exposed APIs are available on Expat parsers, that is,
parsers created by `xml.parsers.expat.ParserCreate()`, as:

- `parser.SetBillionLaughsAttackProtectionActivationThreshold(threshold)`, and
- `parser.SetBillionLaughsAttackProtectionMaximumAmplification(max_factor)`.

This completes the work in f04bea44c37793561d753dd4ca6e7cd658137553,
and improves the existing related documentation.

[1]: https://en.wikipedia.org/wiki/Billion_laughs_attack
Doc/library/pyexpat.rst
Doc/whatsnew/3.15.rst
Include/pyexpat.h
Lib/test/test_pyexpat.py
Misc/NEWS.d/next/Library/2025-09-22-14-40-11.gh-issue-90949.UM35nb.rst
Misc/NEWS.d/next/Library/2025-09-26-18-04-28.gh-issue-90949.YHjSzX.rst [new file with mode: 0644]
Modules/clinic/pyexpat.c.h
Modules/pyexpat.c