gh-139478: Add warning about lack of validation for xml.sax.saxutils.XMLGenerator#139479
gh-139478: Add warning about lack of validation for xml.sax.saxutils.XMLGenerator#139479sethmlarson wants to merge 5 commits intopython:mainfrom
xml.sax.saxutils.XMLGenerator#139479Conversation
Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
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 <10796600+picnixz@users.noreply.github.com>
|
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.
| 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.
"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.
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.XMLGeneratorabout untrusted inputs #139478📚 Documentation preview 📚: https://cpython-previews--139479.org.readthedocs.build/