Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #16753 -- Supported network-path references in the syndication …

…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...
commit 40b9532668b5e4d956c7be15f721be41d3defa3e 1 parent 6f66b55
Aymeric Augustin authored November 18, 2011
10  django/contrib/syndication/views.py
@@ -9,15 +9,15 @@
9 9
 from django.utils.timezone import is_naive
10 10
 
11 11
 def add_domain(domain, url, secure=False):
12  
-    if not (url.startswith('http://')
  12
+    protocol = 'https' if secure else 'http'
  13
+    if url.startswith('//'):
  14
+        # Support network-path reference (see #16753) - RSS requires a protocol
  15
+        url = '%s:%s' % (protocol, url)
  16
+    elif not (url.startswith('http://')
13 17
             or url.startswith('https://')
14 18
             or url.startswith('mailto:')):
15 19
         # 'url' must already be ASCII and URL-quoted, so no need for encoding
16 20
         # conversions here.
17  
-        if secure:
18  
-            protocol = 'https'
19  
-        else:
20  
-            protocol = 'http'
21 21
         url = iri_to_uri(u'%s://%s%s' % (protocol, domain, url))
22 22
     return url
23 23
 
4  tests/regressiontests/syndication/tests.py
@@ -305,3 +305,7 @@ def test_add_domain(self):
305 305
             views.add_domain('example.com', 'mailto:uhoh@djangoproject.com'),
306 306
             'mailto:uhoh@djangoproject.com'
307 307
         )
  308
+        self.assertEqual(
  309
+            views.add_domain('example.com', '//example.com/foo/?arg=value'),
  310
+            'http://example.com/foo/?arg=value'
  311
+        )

0 notes on commit 40b9532

Please sign in to comment.
Something went wrong with that request. Please try again.