Skip to content
This repository was archived by the owner on Feb 8, 2023. It is now read-only.

Add support for <ol reversed>, related attributes #10

Merged
merged 5 commits into from
Jul 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ Features:
opportunity <https://html.spec.whatwg.org/#the-wbr-element>`_. This element
is allowed by default by the sanitizer. (#395) (Thank you, Tom Most!)


1.1
~~~

Expand All @@ -34,7 +33,6 @@ Other changes:
``html5lib`` keeps working in future Python versions. (#403)
* Drop optional ``datrie`` dependency. (#442)


1.0.1
~~~~~

Expand Down
1 change: 1 addition & 0 deletions changelog.d/10.feature.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add support for serializing the ``<ol reversed>`` boolean attribute. The ``<ol reversed>`` and ``<ol start>`` attributes are now permitted by the sanitizer.
1 change: 1 addition & 0 deletions html5lib/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -605,6 +605,7 @@
"button": frozenset(["disabled", "autofocus"]),
"input": frozenset(["disabled", "readonly", "required", "autofocus", "checked", "ismap"]),
"select": frozenset(["disabled", "readonly", "autofocus", "multiple"]),
"ol": frozenset(["reversed"]),
"output": frozenset(["disabled", "readonly"]),
"iframe": frozenset(["seamless"]),
}
Expand Down
2 changes: 2 additions & 0 deletions html5lib/filters/sanitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@
(None, 'maxsize'),
(None, 'minsize'),
(None, 'other'),
(None, 'reversed'),
(None, 'rowalign'),
(None, 'rowalign'),
(None, 'rowalign'),
Expand All @@ -360,6 +361,7 @@
(None, 'scriptlevel'),
(None, 'selection'),
(None, 'separator'),
(None, 'start'),
(None, 'stretchy'),
(None, 'width'),
(None, 'width'),
Expand Down
18 changes: 18 additions & 0 deletions html5lib/tests/test_sanitizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,21 @@ def test_uppercase_color_codes_in_style():
sanitized = sanitize_html("<p style=\"border: 1px solid #A2A2A2;\"></p>")
expected = '<p style=\"border: 1px solid #A2A2A2;\"></p>'
assert expected == sanitized


def test_ol_start_allowed():
sanitized = sanitize_html("<ol start=2><li>.</ol>")
expected = '<ol start="2"><li>.</li></ol>'
assert expected == sanitized


def test_ol_type_allowed():
sanitized = sanitize_html("<ol type=I><li>.</ol>")
expected = '<ol type="I"><li>.</li></ol>'
assert expected == sanitized


def test_ol_reversed_allowed():
sanitized = sanitize_html("<ol reversed><li>.</ol>")
expected = '<ol reversed><li>.</li></ol>'
assert expected == sanitized