Skip to content

Markup.striptags: comments now get replaced with a space #417

@kholmanskikh

Description

@kholmanskikh

In 2.1.4, if Markup.striptags is called, the comment gets replaced by a space. In versions before that it's completely removed from the output.

Test case to reproduce:

import unittest

from markupsafe import Markup

class MarkupSafeTest(unittest.TestCase):
    def test_striptags(self):
        value = 'x <!-- comment -->'
        self.assertEqual(Markup(value).striptags(), 'x')


if __name__ == '__main__':
    unittest.main()

With markupsafe 2.1.4 it fails, with 2.1.3 - it passes.

I'm running with Python 3.11

The issue was originally found by running the test_striptags jinja test case with markupsafe 2.1.4:

https://github.com/pallets/jinja/blob/3fd91e4d11bdd131d8c12805177dbe74d85e7b82/tests/test_filters.py#L94

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions