Skip to content

Commit c977b60

Browse files
committed
docs: also rollback cosmetic docstring changes to minimize diff
1 parent e4eb4cd commit c977b60

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

‎mdit_py_plugins/attrs/index.py‎

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,10 +56,11 @@ def attrs_plugin(
5656
:param allowed: A list of allowed attribute names.
5757
If not ``None``, any attributes not in this list will be removed
5858
and placed in the token's meta under the key "insecure_attrs".
59-
When ``None`` (the default), event-handler (``on*``) and ``style``
60-
attributes are still diverted to "insecure_attrs", since they inject
61-
script even when raw HTML is disabled; pass an explicit allow-list to
62-
restrict attributes further for untrusted input.
59+
If ``None`` (the default), event-handler (``on*``) and ``style``
60+
attributes are still removed as a baseline protection against script
61+
and CSS injection. This is not a full sanitiser: to safely render
62+
untrusted input, pass an explicit ``allowed`` list (e.g.
63+
``("id", "class")``).
6364
"""
6465

6566
if spans:
@@ -99,10 +100,11 @@ def attrs_block_plugin(md: MarkdownIt, *, allowed: Sequence[str] | None = None)
99100
:param allowed: A list of allowed attribute names.
100101
If not ``None``, any attributes not in this list will be removed
101102
and placed in the token's meta under the key "insecure_attrs".
102-
When ``None`` (the default), event-handler (``on*``) and ``style``
103-
attributes are still diverted to "insecure_attrs", since they inject
104-
script even when raw HTML is disabled; pass an explicit allow-list to
105-
restrict attributes further for untrusted input.
103+
If ``None`` (the default), event-handler (``on*``) and ``style``
104+
attributes are still removed as a baseline protection against script
105+
and CSS injection. This is not a full sanitiser: to safely render
106+
untrusted input, pass an explicit ``allowed`` list (e.g.
107+
``("id", "class")``).
106108
"""
107109
md.block.ruler.before("fence", "attr", _attr_block_rule)
108110
md.core.ruler.after(
@@ -289,11 +291,13 @@ def _add_attrs(
289291
attrs: dict[str, Any],
290292
allowed: set[str] | None,
291293
) -> None:
292-
"""Add attributes to a token, diverting disallowed ones to meta.
294+
"""Add attributes to a token, skipping any disallowed attributes.
293295
294-
With an explicit ``allowed`` set, anything outside it is diverted. Without one
295-
(the default), event-handler (``on*``) and ``style`` attributes are still
296-
diverted, so the default configuration cannot emit a script vector.
296+
When ``allowed`` is not ``None`` only those names are kept. When it is
297+
``None`` (the default) an insecure-by-default baseline still removes
298+
event-handler (``on*``) and ``style`` attributes, so untrusted input cannot
299+
inject script or CSS. Anything removed is preserved in
300+
``token.meta["insecure_attrs"]``.
297301
"""
298302
if allowed is not None:
299303
disallowed = {k: v for k, v in attrs.items() if k not in allowed}

0 commit comments

Comments
 (0)