From 7f75460fd6befbef805fee3c91608efb0e9f444d Mon Sep 17 00:00:00 2001 From: Andrew Godwin Date: Wed, 31 Oct 2012 10:58:14 +0000 Subject: [PATCH] Fixed #19070 -- urlize filter no longer raises exceptions on 2.7 Thanks to claudep for the patch. --- django/utils/html.py | 2 +- tests/regressiontests/defaultfilters/tests.py | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/django/utils/html.py b/django/utils/html.py index cc8372906b..9816b9accb 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -18,7 +18,7 @@ from django.utils.text import normalize_newlines # Configuration for urlize() function. TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)'] -WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('<', '>')] +WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>')] # List of possible strings used for bullets in bulleted lists. DOTS = ['·', '*', '\u2022', '•', '•', '•'] diff --git a/tests/regressiontests/defaultfilters/tests.py b/tests/regressiontests/defaultfilters/tests.py index d00203e304..52268da2ec 100644 --- a/tests/regressiontests/defaultfilters/tests.py +++ b/tests/regressiontests/defaultfilters/tests.py @@ -304,7 +304,12 @@ class DefaultFiltersTests(TestCase): # Check urlize trims trailing period when followed by parenthesis - see #18644 self.assertEqual(urlize('(Go to http://www.example.com/foo.)'), - '(Go to http://www.example.com/foo.)') + '(Go to http://www.example.com/foo.)') + + # Check urlize doesn't crash when square bracket is appended to url (#19070) + self.assertEqual(urlize('[see www.example.com]'), + '[see www.example.com]' ) + def test_wordcount(self): self.assertEqual(wordcount(''), 0)