-
-
Notifications
You must be signed in to change notification settings - Fork 33k
gh-139478: Add warning about lack of validation for xml.sax.saxutils.XMLGenerator
#139479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
gh-139478: Add warning about lack of validation for xml.sax.saxutils.XMLGenerator
#139479
Conversation
Co-authored-by: Stan Ulbrych <[email protected]>
Misc/NEWS.d/next/Documentation/2025-10-01-10-06-52.gh-issue-139478.AdnsbB.rst
Outdated
Show resolved
Hide resolved
Co-authored-by: Bénédikt Tran <[email protected]>
My comment got hidden because of the resolved conversation:
|
@serhiy-storchaka I changed the warning to a note about intended usage here: cbe0c12 please take a look. |
with SAX parser functions from the :mod:`!xml.sax` module. Using XMLGenerator | ||
on untrusted user inputs is not the intended use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
with SAX parser functions from the :mod:`!xml.sax` module. Using XMLGenerator | |
on untrusted user inputs is not the intended use. | |
with SAX parser functions from the :mod:`!xml.sax` module. Using | |
:class:`!XMLGenerator` on untrusted user inputs is not the intended use. |
.. note:: | ||
:class:`!XMLGenerator` is only intended to be used as a ``handler`` | ||
with SAX parser functions from the :mod:`!xml.sax` module. Using XMLGenerator | ||
on untrusted user inputs is not the intended use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"is only intended to be used": Ok, but what are the consequences if the class is misused? It's unclear to me what are the risks.
:class:`!XMLGenerator` is only intended to be used as a ``handler`` | ||
with SAX parser functions from the :mod:`!xml.sax` module. Using XMLGenerator | ||
on untrusted user inputs is not the intended use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this form it simply reiterates what was said in the previous paragraph.
Even if this was not intended, people use XMLGenerator for generating XML. If it worked for them, it is fine. They should be aware about pitfalls. But I suggest adding such notes/warnings in other places that are used to generate XML first or simultaneously with XMLGenerator. They all should use unified wording. We can keep a short reminder that this is not intended use of XMLGenerator, the rest of the note should be similar to other notes.
I propose also to add helpers to validate names (#139489). Since this is a new feature, we cannot refer it the documentation changes that will be backported, but keep in mind that we can add references later.
xml.sax.saxutils.XMLGenerator
about untrusted inputs #139478📚 Documentation preview 📚: https://cpython-previews--139479.org.readthedocs.build/