Skip to content

Commit

Permalink
Fixed #16753 -- Supported network-path references in the syndication …
Browse files Browse the repository at this point in the history
…framework. Thanks cato for the report and patch.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@17108 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information
aaugustin committed Nov 18, 2011
1 parent 6f66b55 commit 40b9532
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 5 additions & 5 deletions django/contrib/syndication/views.py
Expand Up @@ -9,15 +9,15 @@
from django.utils.timezone import is_naive

def add_domain(domain, url, secure=False):
if not (url.startswith('http://')
protocol = 'https' if secure else 'http'
if url.startswith('//'):
# Support network-path reference (see #16753) - RSS requires a protocol
url = '%s:%s' % (protocol, url)
elif not (url.startswith('http://')
or url.startswith('https://')
or url.startswith('mailto:')):
# 'url' must already be ASCII and URL-quoted, so no need for encoding
# conversions here.
if secure:
protocol = 'https'
else:
protocol = 'http'
url = iri_to_uri(u'%s://%s%s' % (protocol, domain, url))
return url

Expand Down
4 changes: 4 additions & 0 deletions tests/regressiontests/syndication/tests.py
Expand Up @@ -305,3 +305,7 @@ def test_add_domain(self):
views.add_domain('example.com', 'mailto:uhoh@djangoproject.com'),
'mailto:uhoh@djangoproject.com'
)
self.assertEqual(
views.add_domain('example.com', '//example.com/foo/?arg=value'),
'http://example.com/foo/?arg=value'
)

0 comments on commit 40b9532

Please sign in to comment.