Skip to content

Commit ff7fa37

Browse files
twmambv
andauthored
Sanitizer: Allow <summary> (#423)
Add tests that the sanitizer allows <details open> and <summary> and update the implementation to allow <summary>. Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent c64a111 commit ff7fa37

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

CHANGES.rst

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
Change Log
22
----------
33

4+
1.2
5+
~~~
6+
7+
Bug fixes:
8+
9+
* The sanitizer now permits ``<summary>`` tags.
10+
411
1.1
512
~~~
613

@@ -22,7 +29,6 @@ Other changes:
2229
``html5lib`` keeps working in future Python versions. (#403)
2330
* Drop optional ``datrie`` dependency. (#442)
2431

25-
2632
1.0.1
2733
~~~~~
2834

html5lib/filters/sanitizer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
(namespaces['html'], 'strike'),
114114
(namespaces['html'], 'strong'),
115115
(namespaces['html'], 'sub'),
116+
(namespaces['html'], 'summary'),
116117
(namespaces['html'], 'sup'),
117118
(namespaces['html'], 'table'),
118119
(namespaces['html'], 'tbody'),

html5lib/tests/test_sanitizer.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,18 @@ def param_sanitizer():
111111
"""<img src="%s:%s">foo</a>""" % (protocol, rest_of_uri))
112112

113113

114+
def test_details_open_allowed():
115+
sanitized = sanitize_html("<details open>.</details>")
116+
expected = '<details open>.</details>'
117+
assert expected == sanitized
118+
119+
120+
def test_details_summary_allowed():
121+
sanitized = sanitize_html("<details><summary>.</summary><p>...</p></details>")
122+
expected = '<details><summary>.</summary><p>...</p></details>'
123+
assert expected == sanitized
124+
125+
114126
@pytest.mark.parametrize("expected, input",
115127
(pytest.param(expected, input, id=id)
116128
for id, expected, input in param_sanitizer()))

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy