Skip to content

Commit 40bd63e

Browse files
committed
Add support for <ol reversed>, related attributes
* Mark <ol reversed> as a boolean attribute so it serializes properly in HTML. * Allow <ol reversed> in the sanitizer. Closes html5lib#321. * Allow <ol start> in the sanitizer. * <ol type> was already allowed, but probably accidentally (type is an attribute allowed for other tags). I added a test to prevent it from regressing in case we add per-element attribute sanitization in the future. https://html.spec.whatwg.org/multipage/grouping-content.html#attr-ol-reversed
1 parent 950ea0e commit 40bd63e

File tree

4 files changed

+31
-0
lines changed

4 files changed

+31
-0
lines changed

CHANGES.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Change Log
22
----------
33

4+
1.1.0
5+
~~~~~
6+
7+
Features:
8+
9+
* Add support serializing the ``<ol reversed>`` boolean attribute. (Thank you,
10+
Tom Most!)
11+
* The ``<ol reversed>`` and ``<ol start>`` attributes are now permitted by the
12+
sanitizer. (#321) (Thank you, Tom Most!)
13+
414
1.0.1
515
~~~~~
616

html5lib/constants.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@
605605
"button": frozenset(["disabled", "autofocus"]),
606606
"input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
607607
"select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
608+
"ol": frozenset(["reversed"]),
608609
"output": frozenset(["disabled", "readonly"]),
609610
"iframe": frozenset(["seamless"]),
610611
}

html5lib/filters/sanitizer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@
346346
(None, 'maxsize'),
347347
(None, 'minsize'),
348348
(None, 'other'),
349+
(None, 'reversed'),
349350
(None, 'rowalign'),
350351
(None, 'rowalign'),
351352
(None, 'rowalign'),
@@ -356,6 +357,7 @@
356357
(None, 'scriptlevel'),
357358
(None, 'selection'),
358359
(None, 'separator'),
360+
(None, 'start'),
359361
(None, 'stretchy'),
360362
(None, 'width'),
361363
(None, 'width'),

html5lib/tests/test_sanitizer.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,21 @@ def test_uppercase_color_codes_in_style():
125125
sanitized = sanitize_html("<p style=\"border: 1px solid #A2A2A2;\"></p>")
126126
expected = '<p style=\"border: 1px solid #A2A2A2;\"></p>'
127127
assert expected == sanitized
128+
129+
130+
def test_ol_start_allowed():
131+
sanitized = sanitize_html("<ol start=2><li>.</ol>")
132+
expected = '<ol start="2"><li>.</li></ol>'
133+
assert expected == sanitized
134+
135+
136+
def test_ol_type_allowed():
137+
sanitized = sanitize_html("<ol type=I><li>.</ol>")
138+
expected = '<ol type="I"><li>.</li></ol>'
139+
assert expected == sanitized
140+
141+
142+
def test_ol_reversed_allowed():
143+
sanitized = sanitize_html("<ol reversed><li>.</ol>")
144+
expected = '<ol reversed><li>.</li></ol>'
145+
assert expected == sanitized

0 commit comments

Comments
 (0)