Skip to content

Commit fcbfaf4

Browse files
committed
fix: fix wbr handling (#488)
html5lib did a 1.1 release in June 2020. Since then, they fixed how wbr is treated--it should be an element that doesn't require a closing tag. html5lib/html5lib-python#395 However, they haven't done a release since then. This adds another vendor patch to fix wbr handling.
1 parent 55e48ce commit fcbfaf4

File tree

5 files changed

+31
-7
lines changed

5 files changed

+31
-7
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
diff --git bleach/_vendor/html5lib/constants.py b/bleach/_vendor/html5lib/constants.py
2+
index fe3e237..11184e0 100644
3+
--- bleach/_vendor/html5lib/constants.py
4+
+++ bleach/_vendor/html5lib/constants.py
5+
@@ -571,7 +571,8 @@ voidElements = frozenset([
6+
"col",
7+
"input",
8+
"source",
9+
- "track"
10+
+ "track",
11+
+ "wbr",
12+
])
13+
14+
cdataElements = frozenset(['title', 'textarea'])
15+
diff --git bleach/_vendor/html5lib/filters/sanitizer.py b/bleach/_vendor/html5lib/filters/sanitizer.py
16+
index 5c31e97..74a7c91 100644
17+
--- bleach/_vendor/html5lib/filters/sanitizer.py
18+
+++ bleach/_vendor/html5lib/filters/sanitizer.py
19+
@@ -128,6 +128,7 @@ allowed_elements = frozenset((
20+
(namespaces['html'], 'ul'),
21+
(namespaces['html'], 'var'),
22+
(namespaces['html'], 'video'),
23+
+ (namespaces['html'], 'wbr'),
24+
(namespaces['mathml'], 'maction'),
25+
(namespaces['mathml'], 'math'),
26+
(namespaces['mathml'], 'merror'),

bleach/_vendor/html5lib/constants.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -571,7 +571,8 @@
571571
"col",
572572
"input",
573573
"source",
574-
"track"
574+
"track",
575+
"wbr",
575576
])
576577

577578
cdataElements = frozenset(['title', 'textarea'])

bleach/_vendor/html5lib/filters/sanitizer.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@
128128
(namespaces['html'], 'ul'),
129129
(namespaces['html'], 'var'),
130130
(namespaces['html'], 'video'),
131+
(namespaces['html'], 'wbr'),
131132
(namespaces['mathml'], 'maction'),
132133
(namespaces['mathml'], 'math'),
133134
(namespaces['mathml'], 'merror'),

bleach/_vendor/vendor_install.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ pip install --no-binary all --no-compile --no-deps -r "${BLEACH_VENDOR_DIR}/vend
1212

1313
# Apply patches
1414
(cd "${DEST}" && patch -p2 < 01_html5lib_six.patch)
15+
(cd "${DEST}" && patch -p2 < 02_html5lib_wbr.patch)
1516

1617
# install Python 3.6.14 urllib.urlparse for #536
1718
curl --proto '=https' --tlsv1.2 -o "${DEST}/parse.py" https://raw.githubusercontent.com/python/cpython/v3.6.14/Lib/urllib/parse.py

tests/test_clean.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -736,12 +736,7 @@ def test_nonexistent_namespace():
736736
),
737737
),
738738
"track",
739-
pytest.param(
740-
"wbr",
741-
marks=pytest.mark.xfail(
742-
reason="https://github.com/mozilla/bleach/issues/488"
743-
),
744-
),
739+
"wbr",
745740
],
746741
)
747742
def test_self_closing_tags_self_close(tag):

0 commit comments

Comments
 (0)