summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaude Paroz <claude@2xlibre.net>2013-02-06 21:20:43 +0100
committerClaude Paroz <claude@2xlibre.net>2013-02-06 21:20:43 +0100
commitd7504a3d7b8645bdb979bab7ded0e9a9b6dccd0e (patch)
tree5c0399dedda6cce3f817c7cfb8bc3a13d402ccb1
parentafa3e1633431137f4e76c7efc359b579f4d9c08e (diff)
Improved regex in strip_tags
Thanks Pablo Recio for the report. Refs #19237.
-rw-r--r--django/utils/html.py2
-rw-r--r--tests/regressiontests/utils/html.py1
2 files changed, 2 insertions, 1 deletions
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'(<a [^>]*?)target=[^\s>]+')
html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE)
hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL)
trailing_empty_content_re = re.compile(r'(?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Z')
-strip_tags_re = re.compile(r'</?\S([^=]*=(\s*"[^"]*"|\s*\'[^\']*\'|\S*)|[^>])*?>', re.IGNORECASE)
+strip_tags_re = re.compile(r'</?\S([^=>]*=(\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<p onclick="alert(\'<test>\')">b</p>c', 'abc'),
('a<p a >b</p>c', 'abc'),
('d<a:b c:d>e</p>f', 'def'),
+ ('<strong>foo</strong><a href="http://example.com">bar</a>', 'foobar'),
)
for value, output in items:
self.check_output(f, value, output)