Ticket #17576: 17576.patch

File 17576.patch, 2.0 KB (added by aaugustin, 2 years ago)
  • django/utils/html.py

    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 
    1818
    1919# Configuration for urlize() function.
    2020TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)']
    21 WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;')]
     21WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;'), ('"', '"'), ("'", "'")]
    2222
    2323# List of possible strings used for bullets in bulleted lists.
    2424DOTS = ['&middot;', '*', '\u2022', '&#149;', '&bull;', '&#8226;']
    def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False): 
    205205                    lead = lead + opening
    206206                # Keep parentheses at the end only if they're balanced.
    207207                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)):
    209209                    middle = middle[:-len(closing)]
    210210                    trail = closing + trail
    211211
  • tests/defaultfilters/tests.py

    diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py
    index 8596f8c..0092f4d 100644
    a b class DefaultFiltersTests(TestCase): 
    314314        self.assertEqual(urlize('see test[at[example.com'),
    315315            'see <a href="http://test[at[example.com" rel="nofollow">test[at[example.com</a>' )
    316316
     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>'}")
    317322
    318323    def test_wordcount(self):
    319324        self.assertEqual(wordcount(''), 0)
Back to Top