Skip to content

Commit 7f75460

Browse files
committed
Fixed django#19070 -- urlize filter no longer raises exceptions on 2.7
Thanks to claudep for the patch.
1 parent 146ed13 commit 7f75460

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

django/utils/html.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
# Configuration for urlize() function.
2020
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)']
21-
WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('&lt;', '&gt;')]
21+
WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;')]
2222

2323
# List of possible strings used for bullets in bulleted lists.
2424
DOTS = ['&middot;', '*', '\u2022', '&#149;', '&bull;', '&#8226;']

tests/regressiontests/defaultfilters/tests.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -304,7 +304,12 @@ def test_urlize(self):
304304

305305
# Check urlize trims trailing period when followed by parenthesis - see #18644
306306
self.assertEqual(urlize('(Go to http://www.example.com/foo.)'),
307-
'(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)')
307+
'(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)')
308+
309+
# Check urlize doesn't crash when square bracket is appended to url (#19070)
310+
self.assertEqual(urlize('[see www.example.com]'),
311+
'[see <a href="http://www.example.com" rel="nofollow">www.example.com</a>]' )
312+
308313

309314
def test_wordcount(self):
310315
self.assertEqual(wordcount(''), 0)

0 commit comments

Comments
 (0)