Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 01b7dea

Browse filesBrowse files
twmambv
andauthored
Add support for <ol reversed>, related attributes (html5lib#396)
* 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 Co-authored-by: Łukasz Langa <lukasz@langa.pl>
1 parent 82047b0 commit 01b7dea
Copy full SHA for 01b7dea

File tree

Expand file treeCollapse file tree

4 files changed

+27
-1
lines changed
Filter options
Expand file treeCollapse file tree

4 files changed

+27
-1
lines changed

‎CHANGES.rst

Copy file name to clipboardExpand all lines: CHANGES.rst
+6-1Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@ Features:
1111
* Add support for the ``<wbr>`` element in the sanitizer, `which indicates
1212
a line break opportunity <https://html.spec.whatwg.org/#the-wbr-element>`_.
1313
This element is allowed by default. (#395) (Thank you, Tom Most!)
14+
* Add support for serializing the ``<ol reversed>`` boolean attribute. (Thank
15+
you, Tom Most!) (#396)
16+
* The ``<ol reversed>`` and ``<ol start>`` attributes are now permitted by the
17+
sanitizer. (#321) (Thank you, Tom Most!)
1418

1519
Bug fixes:
1620

17-
* The sanitizer now permits ``<summary>`` tags.
21+
* The sanitizer now permits ``<summary>`` tags. It used to allow ``<details>``
22+
already. (#423)
1823

1924
1.1
2025
~~~

‎html5lib/constants.py

Copy file name to clipboardExpand all lines: html5lib/constants.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@
617617
"button": frozenset(["disabled", "autofocus"]),
618618
"input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
619619
"select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
620+
"ol": frozenset(["reversed"]),
620621
"output": frozenset(["disabled", "readonly"]),
621622
"iframe": frozenset(["seamless"]),
622623
}

‎html5lib/filters/sanitizer.py

Copy file name to clipboardExpand all lines: html5lib/filters/sanitizer.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@
365365
(None, 'maxsize'),
366366
(None, 'minsize'),
367367
(None, 'other'),
368+
(None, 'reversed'),
368369
(None, 'rowalign'),
369370
(None, 'rowalign'),
370371
(None, 'rowalign'),
@@ -375,6 +376,7 @@
375376
(None, 'scriptlevel'),
376377
(None, 'selection'),
377378
(None, 'separator'),
379+
(None, 'start'),
378380
(None, 'stretchy'),
379381
(None, 'width'),
380382
(None, 'width'),

‎html5lib/tests/test_sanitizer.py

Copy file name to clipboardExpand all lines: html5lib/tests/test_sanitizer.py
+18Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,3 +154,21 @@ def test_uppercase_color_codes_in_style():
154154
sanitized = sanitize_html("<p style=\"border: 1px solid #A2A2A2;\"></p>")
155155
expected = '<p style=\"border: 1px solid #A2A2A2;\"></p>'
156156
assert expected == sanitized
157+
158+
159+
def test_ol_start_allowed():
160+
sanitized = sanitize_html("<ol start=2><li>.</ol>")
161+
expected = '<ol start="2"><li>.</li></ol>'
162+
assert expected == sanitized
163+
164+
165+
def test_ol_type_allowed():
166+
sanitized = sanitize_html("<ol type=I><li>.</ol>")
167+
expected = '<ol type="I"><li>.</li></ol>'
168+
assert expected == sanitized
169+
170+
171+
def test_ol_reversed_allowed():
172+
sanitized = sanitize_html("<ol reversed><li>.</ol>")
173+
expected = '<ol reversed><li>.</li></ol>'
174+
assert expected == sanitized

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.