From 40bd63e6f588d02f6cb6f342576129192268eec3 Mon Sep 17 00:00:00 2001 From: Tom Most Date: Sat, 9 Jun 2018 18:40:46 -0700 Subject: [PATCH] Add support for
    , related attributes * Mark
      as a boolean attribute so it serializes properly in HTML. * Allow
        in the sanitizer. Closes #321. * Allow
          in the sanitizer. *
            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 --- CHANGES.rst | 10 ++++++++++ html5lib/constants.py | 1 + html5lib/filters/sanitizer.py | 2 ++ html5lib/tests/test_sanitizer.py | 18 ++++++++++++++++++ 4 files changed, 31 insertions(+) diff --git a/CHANGES.rst b/CHANGES.rst index 82605a21..2f0ee4d6 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -1,6 +1,16 @@ Change Log ---------- +1.1.0 +~~~~~ + +Features: + +* Add support serializing the ``
              `` boolean attribute. (Thank you, + Tom Most!) +* The ``
                `` and ``
                  `` attributes are now permitted by the + sanitizer. (#321) (Thank you, Tom Most!) + 1.0.1 ~~~~~ diff --git a/html5lib/constants.py b/html5lib/constants.py index 1ff80419..a05696ce 100644 --- a/html5lib/constants.py +++ b/html5lib/constants.py @@ -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"]), } diff --git a/html5lib/filters/sanitizer.py b/html5lib/filters/sanitizer.py index e852f53b..01499c2e 100644 --- a/html5lib/filters/sanitizer.py +++ b/html5lib/filters/sanitizer.py @@ -346,6 +346,7 @@ (None, 'maxsize'), (None, 'minsize'), (None, 'other'), + (None, 'reversed'), (None, 'rowalign'), (None, 'rowalign'), (None, 'rowalign'), @@ -356,6 +357,7 @@ (None, 'scriptlevel'), (None, 'selection'), (None, 'separator'), + (None, 'start'), (None, 'stretchy'), (None, 'width'), (None, 'width'), diff --git a/html5lib/tests/test_sanitizer.py b/html5lib/tests/test_sanitizer.py index 45046d57..0960476d 100644 --- a/html5lib/tests/test_sanitizer.py +++ b/html5lib/tests/test_sanitizer.py @@ -125,3 +125,21 @@ def test_uppercase_color_codes_in_style(): sanitized = sanitize_html("

                  ") expected = '

                  ' assert expected == sanitized + + +def test_ol_start_allowed(): + sanitized = sanitize_html("
                  1. .
                  ") + expected = '
                  1. .
                  ' + assert expected == sanitized + + +def test_ol_type_allowed(): + sanitized = sanitize_html("
                  1. .
                  ") + expected = '
                  1. .
                  ' + assert expected == sanitized + + +def test_ol_reversed_allowed(): + sanitized = sanitize_html("
                  1. .
                  ") + expected = '
                  1. .
                  ' + assert expected == sanitized