From 1bb1d3168b813e050df757ff40cdaf2feab45fdb Mon Sep 17 00:00:00 2001 From: LarryBrid Date: Thu, 3 Jul 2014 16:37:56 -0400 Subject: [PATCH] Updated urlize regex following a93ee5112d4 Prevent urlize from turning some.organization, an.intern etc. into urls. Refs #22941. --- django/utils/html.py | 2 +- tests/defaultfilters/tests.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/django/utils/html.py b/django/utils/html.py index 1ab27b44613..38fe90d1a92 100644 --- a/django/utils/html.py +++ b/django/utils/html.py @@ -25,7 +25,7 @@ DOTS = ['·', '*', '\u2022', '•', '•', '•'] unencoded_ampersands_re = re.compile(r'&(?!(\w+|#\d+);)') word_split_re = re.compile(r'(\s+)') simple_url_re = re.compile(r'^https?://\[?\w', re.IGNORECASE) -simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)(.*)$', re.IGNORECASE) +simple_url_2_re = re.compile(r'^www\.|^(?!http)\w[^@]+\.(com|edu|gov|int|mil|net|org)($|/.*)$', re.IGNORECASE) simple_email_re = re.compile(r'^\S+@\S+\.\S+$') link_target_attribute_re = re.compile(r'(]*?)target=[^\s>]+') html_gunk_re = re.compile(r'(?:
|<\/i>|<\/b>|<\/em>|<\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE) diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py index 2e70a1c23b2..22dc04666ee 100644 --- a/tests/defaultfilters/tests.py +++ b/tests/defaultfilters/tests.py @@ -268,6 +268,8 @@ class DefaultFiltersTests(TestCase): '
djangoproject.org/') self.assertEqual(urlize('info@djangoproject.org'), 'info@djangoproject.org') + self.assertEqual(urlize('some.organization'), + 'some.organization'), # Check urlize with https addresses self.assertEqual(urlize('https://google.com'),