diff options
-rw-r--r-- | CHANGES.rst | 3 | ||||
-rw-r--r-- | src/markupsafe/__init__.py | 4 | ||||
-rw-r--r-- | tests/test_markupsafe.py | 2 |
3 files changed, 7 insertions, 2 deletions
diff --git a/CHANGES.rst b/CHANGES.rst index ffe462f..e1a558f 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -3,6 +3,9 @@ Version 2.1.2 Unreleased +- Fix ``striptags`` not stripping tags containing newlines. + :issue:`310` + Version 2.1.1 ------------- diff --git a/src/markupsafe/__init__.py b/src/markupsafe/__init__.py index a95eb1e..1f9d8cd 100644 --- a/src/markupsafe/__init__.py +++ b/src/markupsafe/__init__.py @@ -13,8 +13,8 @@ if t.TYPE_CHECKING: __version__ = "2.1.2.dev0" -_strip_comments_re = re.compile(r"<!--.*?-->") -_strip_tags_re = re.compile(r"<.*?>") +_strip_comments_re = re.compile(r"<!--.*?-->", re.DOTALL) +_strip_tags_re = re.compile(r"<.*?>", re.DOTALL) def _simple_escaping_wrapper(name: str) -> t.Callable[..., "Markup"]: diff --git a/tests/test_markupsafe.py b/tests/test_markupsafe.py index 236f35e..a62ebf9 100644 --- a/tests/test_markupsafe.py +++ b/tests/test_markupsafe.py @@ -75,6 +75,8 @@ def test_escaping(escape): "<em>Foo & Bar" "<!-- inner comment about <em> -->" "</em>" + "<!-- comment\nwith\nnewlines\n-->" + "<meta content='tag\nwith\nnewlines'>" ).striptags() == "Foo & Bar" ) |