Ticket #16020: urlize_test.diff

File urlize_test.diff, 2.0 KB (added by beneliott, 13 years ago)
  • tests/regressiontests/defaultfilters/tests.py

     
    212212            u'<a href="http://djangoproject.org" rel="nofollow">djangoproject.org</a>')
    213213        self.assertEqual(urlize('info@djangoproject.org'),
    214214            u'<a href="mailto:info@djangoproject.org">info@djangoproject.org</a>')
    215 
     215       
    216216        # Check urlize with https addresses
    217217        self.assertEqual(urlize('https://google.com'),
    218218            u'<a href="https://google.com" rel="nofollow">https://google.com</a>')
     219        # Check with escaped characters
     220        self.assertEqual(urlize('http://google.com/django%20project'),
     221            u'<a href="http://google.com/django%20project" rel="nofollow">http://google.com/django%20project</a>')
     222       
    219223
    220224    def test_wordcount(self):
    221225        self.assertEqual(wordcount(''), 0)
  • django/utils/html.py

     
    129129            # Make URL we want to point to.
    130130            url = None
    131131            if middle.startswith('http://') or middle.startswith('https://'):
    132                 url = urlquote(middle, safe='/&=:;#?+*')
     132                url = urlquote(middle, safe='/&=:;#?+*%')
    133133            elif middle.startswith('www.') or ('@' not in middle and \
    134134                    middle and middle[0] in string.ascii_letters + string.digits and \
    135135                    (middle.endswith('.org') or middle.endswith('.net') or middle.endswith('.com'))):
    136                 url = urlquote('http://%s' % middle, safe='/&=:;#?+*')
     136                url = urlquote('http://%s' % middle, safe='/&=:;#?+*%')
    137137            elif '@' in middle and not ':' in middle and simple_email_re.match(middle):
    138138                url = 'mailto:%s' % middle
    139139                nofollow_attr = ''
Back to Top