diff --git a/django/utils/html.py b/django/utils/html.py
index a9ebd17..1f48ca7 100644
a
|
b
|
from django.utils.text import normalize_newlines
|
18 | 18 | |
19 | 19 | # Configuration for urlize() function. |
20 | 20 | TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)'] |
21 | | WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>')] |
| 21 | WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>'), ('"', '"'), ("'", "'")] |
22 | 22 | |
23 | 23 | # List of possible strings used for bullets in bulleted lists. |
24 | 24 | DOTS = ['·', '*', '\u2022', '•', '•', '•'] |
… |
… |
def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
205 | 205 | lead = lead + opening |
206 | 206 | # Keep parentheses at the end only if they're balanced. |
207 | 207 | if (middle.endswith(closing) |
208 | | and middle.count(closing) == middle.count(opening) + 1): |
| 208 | and (opening == closing or middle.count(closing) == middle.count(opening) + 1)): |
209 | 209 | middle = middle[:-len(closing)] |
210 | 210 | trail = closing + trail |
211 | 211 | |
diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py
index 8596f8c..0092f4d 100644
a
|
b
|
class DefaultFiltersTests(TestCase):
|
314 | 314 | self.assertEqual(urlize('see test[at[example.com'), |
315 | 315 | 'see <a href="http://test[at[example.com" rel="nofollow">test[at[example.com</a>' ) |
316 | 316 | |
| 317 | # Check urlize handles quoted URLs properly (#17576) |
| 318 | self.assertEqual(urlize('{"link": "www.djangoproject.com"}'), |
| 319 | '{"link": "<a href="http://www.djangoproject.com" rel="nofollow">www.djangoproject.com</a>"}') |
| 320 | self.assertEqual(urlize("{'link': 'www.djangoproject.com'}"), |
| 321 | "{'link': '<a href=\"http://www.djangoproject.com\" rel=\"nofollow\">www.djangoproject.com</a>'}") |
317 | 322 | |
318 | 323 | def test_wordcount(self): |
319 | 324 | self.assertEqual(wordcount(''), 0) |