Loading django/utils/html.py +2 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ from .html_parser import HTMLParser, HTMLParseError # Configuration for urlize() function. TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)'] WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>')] TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)', '"', '\''] WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>'), ('"', '"'), ('\'', '\'')] # List of possible strings used for bullets in bulleted lists. DOTS = ['·', '*', '\u2022', '•', '•', '•'] Loading tests/defaultfilters/tests.py +18 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,24 @@ class DefaultFiltersTests(TestCase): 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) Loading Loading
django/utils/html.py +2 −2 Original line number Diff line number Diff line Loading @@ -15,8 +15,8 @@ from .html_parser import HTMLParser, HTMLParseError # Configuration for urlize() function. TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)'] WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>')] TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)', '"', '\''] WRAPPING_PUNCTUATION = [('(', ')'), ('<', '>'), ('[', ']'), ('<', '>'), ('"', '"'), ('\'', '\'')] # List of possible strings used for bullets in bulleted lists. DOTS = ['·', '*', '\u2022', '•', '•', '•'] Loading
tests/defaultfilters/tests.py +18 −0 Original line number Diff line number Diff line Loading @@ -324,6 +324,24 @@ class DefaultFiltersTests(TestCase): 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) Loading