From d7504a3d7b8645bdb979bab7ded0e9a9b6dccd0e Mon Sep 17 00:00:00 2001 From: Claude Paroz Date: Wed, 6 Feb 2013 21:20:43 +0100 Subject: [PATCH] Improved regex in strip_tags Thanks Pablo Recio for the report. Refs #19237. --- django/utils/html.py | 2 +- tests/regressiontests/utils/html.py | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/django/utils/html.py b/django/utils/html.py index ec7b28d330..a9ebd17935 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -33,7 +33,7 @@ link_target_attribute_re = re.compile(r'(]*?)target=[^\s>]+') html_gunk_re = re.compile(r'(?:
|<\/i>|<\/b>|<\/em>|<\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) hard_coded_bullets_re = re.compile(r'((?:

(?:%s).*?[a-zA-Z].*?

\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL) trailing_empty_content_re = re.compile(r'(?:

(?: |\s|
)*?

\s*)+\Z') -strip_tags_re = re.compile(r'])*?>', re.IGNORECASE) +strip_tags_re = re.compile(r']*=(\s*"[^"]*"|\s*\'[^\']*\'|\S*)|[^>])*?>', re.IGNORECASE) def escape(text): diff --git a/tests/regressiontests/utils/html.py b/tests/regressiontests/utils/html.py index a0226c4765..62c7dac24a 100644 --- a/tests/regressiontests/utils/html.py +++ b/tests/regressiontests/utils/html.py @@ -68,6 +68,7 @@ class TestUtilsHtml(unittest.TestCase): ('a

b

c', 'abc'), ('a

b

c', 'abc'), ('de

f', 'def'), + ('foo
bar', 'foobar'), ) for value, output in items: self.check_output(f, value, output)