[3.14] gh-90949: expose Expat API to tune exponential expansion protections (GH-139368) (#150496)
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
(cherry picked from commit
666112376d574c7802646ee1df6244062671cd61)
Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>