Permalink
Browse files

Fixed #19070 -- urlize filter no longer raises exceptions on 2.7

Thanks to claudep for the patch.
  • Loading branch information...
1 parent 0dcaddb commit f1be2c7a81b6364e353b351919eca588d288d4a4 @andrewgodwin andrewgodwin committed Oct 31, 2012
Showing with 7 additions and 2 deletions.
  1. +1 −1 django/utils/html.py
  2. +6 −1 tests/regressiontests/defaultfilters/tests.py
View
2 django/utils/html.py
@@ -18,7 +18,7 @@
# Configuration for urlize() function.
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)']
-WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('&lt;', '&gt;')]
+WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;')]
# List of possible strings used for bullets in bulleted lists.
DOTS = ['&middot;', '*', '\u2022', '&#149;', '&bull;', '&#8226;']
View
7 tests/regressiontests/defaultfilters/tests.py
@@ -304,7 +304,12 @@ def test_urlize(self):
# Check urlize trims trailing period when followed by parenthesis - see #18644
self.assertEqual(urlize('(Go to http://www.example.com/foo.)'),
- '(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)')
+ '(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)')
+
+ # Check urlize doesn't crash when square bracket is appended to url (#19070)
+ self.assertEqual(urlize('[see www.example.com]'),
+ '[see <a href="http://www.example.com" rel="nofollow">www.example.com</a>]' )
+
def test_wordcount(self):
self.assertEqual(wordcount(''), 0)

0 comments on commit f1be2c7

Please sign in to comment.