Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #20364 -Added a passing test that confirms URLs in quotes followed by commas are handled correctly by Chris Piwoński's patch. #1662

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions django/utils/html.py
Expand Up @@ -15,8 +15,8 @@


# Configuration for urlize() function.
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)']
WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;')]
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)', '"', '\'']
WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('&lt;', '&gt;'), ('"', '"'), ('\'', '\'')]

# List of possible strings used for bullets in bulleted lists.
DOTS = ['&middot;', '*', '\u2022', '&#149;', '&bull;', '&#8226;']
Expand Down
18 changes: 18 additions & 0 deletions tests/defaultfilters/tests.py
Expand Up @@ -324,6 +324,24 @@ def test_urlize(self):
self.assertEqual(urlize('http://[2001:db8:cafe::2]/api/9'),
'<a href="http://[2001:db8:cafe::2]/api/9" rel="nofollow">http://[2001:db8:cafe::2]/api/9</a>')

# Check urlize correctly include quotation marks in links - #20364
self.assertEqual(urlize('before "hi@example.com" afterwards'),
u'before "<a href="mailto:hi@example.com">hi@example.com</a>" afterwards')
self.assertEqual(urlize('before hi@example.com" afterwards'),
u'before <a href="mailto:hi@example.com">hi@example.com</a>" afterwards')
self.assertEqual(urlize('before "hi@example.com afterwards'),
u'before "<a href="mailto:hi@example.com">hi@example.com</a> afterwards')
self.assertEqual(urlize('before \'hi@example.com\' afterwards'),
u'before \'<a href="mailto:hi@example.com">hi@example.com</a>\' afterwards')
self.assertEqual(urlize('before hi@example.com\' afterwards'),
u'before <a href="mailto:hi@example.com">hi@example.com</a>\' afterwards')
self.assertEqual(urlize('before \'hi@example.com afterwards'),
u'before \'<a href="mailto:hi@example.com">hi@example.com</a> afterwards')

# Check urlize copes with commas following URLs in quotes - see #20364
self.assertEqual(urlize('Email us at "hi@example.com", or phone us at +xx.yy'),
'Email us at "<a href="mailto:hi@example.com">hi@example.com</a>", or phone us at +xx.yy')

def test_wordcount(self):
self.assertEqual(wordcount(''), 0)
self.assertEqual(wordcount('oneword'), 1)
Expand Down