Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fixed #18644 -- Made urlize trim trailing period followed by parenthesis #216

Merged
merged 1 commit into from

3 participants

@ljosa

Added '.)' to TRAILING_PUNCTUATION so that a period will be stripped from URLs also when it is followed by a close parenthesis. See Ticket #18644.

@claudep
Collaborator

urlize is already extensively tested in regressionttests/defaultfilters/tests.py. Please move your test there.

@ljosa

@claudep Thanks for showing me where the test should go. Moved it and amended the existing commit.

@apollo13 apollo13 merged commit 59d9977 into django:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
View
2  django/utils/html.py
@@ -13,7 +13,7 @@
from django.utils.text import normalize_newlines
# Configuration for urlize() function.
-TRAILING_PUNCTUATION = ['.', ',', ':', ';']
+TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)']
WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('&lt;', '&gt;')]
# List of possible strings used for bullets in bulleted lists.
View
4 tests/regressiontests/defaultfilters/tests.py
@@ -297,6 +297,10 @@ def test_urlize(self):
self.assertEqual(urlize('HTTPS://github.com/'),
'<a href="https://github.com/" rel="nofollow">HTTPS://github.com/</a>')
+ # Check urlize trims trailing period when followed by parenthesis - see #18644
+ self.assertEqual(urlize('(Go to http://www.example.com/foo.)'),
+ '(Go to <a href="http://www.example.com/foo" rel="nofollow">http://www.example.com/foo</a>.)')
+
def test_wordcount(self):
self.assertEqual(wordcount(''), 0)
self.assertEqual(wordcount('oneword'), 1)
Something went wrong with that request. Please try again.