summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLarryBrid <camfulton@gmail.com>2014-07-02 11:51:51 -0400
committerTim Graham <timograham@gmail.com>2014-07-02 20:36:53 -0400
commita93ee5112d42d37187e30aa4edcc1864a79d384a (patch)
tree7b389395df6528f56c68d83f7c8e7a93fd2a018e
parent42f5c8f39710691ce1606289698ee321a8ac0627 (diff)
Fixed #22941 - Added support for domain-only links with chars after the TLD to urlize.
It now works with something like google.com/foo/bar
-rw-r--r--django/utils/html.py2
-rw-r--r--docs/ref/templates/builtins.txt6
-rw-r--r--docs/releases/1.8.txt4
-rw-r--r--tests/defaultfilters/tests.py2
4 files changed, 12 insertions, 2 deletions
diff --git a/django/utils/html.py b/django/utils/html.py
index 7c843cf25e..1ab27b4461 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -25,7 +25,7 @@ DOTS = ['&middot;', '*', '\u2022', '&#149;', '&bull;', '&#8226;']
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'(<a [^>]*?)target=[^\s>]+')
html_gunk_re = re.compile(r'(?:<br clear="all">|<i><\/i>|<b><\/b>|<em><\/em>|<strong><\/strong>|<\/?smallcaps>|<\/?uppercase>)', re.IGNORECASE)
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index efa7188990..97860d1463 100644
--- a/docs/ref/templates/builtins.txt
+++ b/docs/ref/templates/builtins.txt
@@ -2277,6 +2277,12 @@ It also supports domain-only links ending in one of the original top level
domains (``.com``, ``.edu``, ``.gov``, ``.int``, ``.mil``, ``.net``, and
``.org``). For example, ``djangoproject.com`` gets converted.
+.. versionchanged:: 1.8
+
+ Support for domain-only links that include characters after the top-level
+ domain (e.g. ``djangoproject.com/`` and ``djangoproject.com/download/``)
+ was added.
+
Links can have trailing punctuation (periods, commas, close-parens) and leading
punctuation (opening parens), and ``urlize`` will still do the right thing.
diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt
index 8a736aeb45..3e2790c602 100644
--- a/docs/releases/1.8.txt
+++ b/docs/releases/1.8.txt
@@ -207,7 +207,9 @@ Signals
Templates
^^^^^^^^^
-* ...
+* :tfilter:`urlize` now supports domain-only links that include characters after
+ the top-level domain (e.g. ``djangoproject.com/`` and
+ ``djangoproject.com/download/``).
Requests and Responses
^^^^^^^^^^^^^^^^^^^^^^
diff --git a/tests/defaultfilters/tests.py b/tests/defaultfilters/tests.py
index 7ebef193fa..2e70a1c23b 100644
--- a/tests/defaultfilters/tests.py
+++ b/tests/defaultfilters/tests.py
@@ -264,6 +264,8 @@ class DefaultFiltersTests(TestCase):
'<a href="http://www.google.com" rel="nofollow">www.google.com</a>')
self.assertEqual(urlize('djangoproject.org'),
'<a href="http://djangoproject.org" rel="nofollow">djangoproject.org</a>')
+ self.assertEqual(urlize('djangoproject.org/'),
+ '<a href="http://djangoproject.org/" rel="nofollow">djangoproject.org/</a>')
self.assertEqual(urlize('info@djangoproject.org'),
'<a href="mailto:info@djangoproject.org">info@djangoproject.org</a>')