Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Doc/library/xml.sax.utils.rst
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ or as base classes.
content: if ``False`` (the default) they are emitted as a pair of start/end
tags, if set to ``True`` they are emitted as a single self-closed tag.

.. 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.
Comment on lines +76 to +77
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Member

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.

Comment on lines +75 to +77
Copy link
Member

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.


.. versionchanged:: 3.2
Added the *short_empty_elements* parameter.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`xml.sax.saxutils`: Add warning about lack of
validation for :class:`~xml.sax.saxutils.XMLGenerator`.
Loading