Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Improved regex in strip_tags

Thanks Pablo Recio for the report. Refs #19237.
  • Loading branch information...
commit d7504a3d7b8645bdb979bab7ded0e9a9b6dccd0e 1 parent afa3e16
Claude Paroz authored February 06, 2013
2  django/utils/html.py
@@ -33,7 +33,7 @@
33 33
 html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE)
34 34
 hard_coded_bullets_re = re.compile(r'((?:<p>(?:%s).*?[a-zA-Z].*?</p>\s*)+)' % '|'.join([re.escape(x) for x in DOTS]), re.DOTALL)
35 35
 trailing_empty_content_re = re.compile(r'(?:<p>(?:&nbsp;|\s|<br \/>)*?</p>\s*)+\Z')
36  
-strip_tags_re = re.compile(r'</?\S([^=]*=(\s*"[^"]*"|\s*\'[^\']*\'|\S*)|[^>])*?>', re.IGNORECASE)
  36
+strip_tags_re = re.compile(r'</?\S([^=>]*=(\s*"[^"]*"|\s*\'[^\']*\'|\S*)|[^>])*?>', re.IGNORECASE)
37 37
 
38 38
 
39 39
 def escape(text):
1  tests/regressiontests/utils/html.py
@@ -68,6 +68,7 @@ def test_strip_tags(self):
68 68
             ('a<p onclick="alert(\'<test>\')">b</p>c', 'abc'),
69 69
             ('a<p a >b</p>c', 'abc'),
70 70
             ('d<a:b c:d>e</p>f', 'def'),
  71
+            ('<strong>foo</strong><a href="http://example.com">bar</a>', 'foobar'),
71 72
         )
72 73
         for value, output in items:
73 74
             self.check_output(f, value, output)

0 notes on commit d7504a3

Please sign in to comment.
Something went wrong with that request. Please try again.