Code

Ticket #7494: fix_absolute_url_check_in_get_absolute_url.diff

File fix_absolute_url_check_in_get_absolute_url.diff, 890 bytes (added by tom@…, 6 years ago)

Patch that fixes the problem

Line 
1Index: django/http/__init__.py
2===================================================================
3--- django/http/__init__.py     (revision 7686)
4+++ django/http/__init__.py     (working copy)
5@@ -1,4 +1,5 @@
6 import os
7+import re
8 from Cookie import SimpleCookie, CookieError
9 from pprint import pformat
10 from urllib import urlencode
11@@ -16,6 +17,7 @@
12 
13 RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
14 
15+absolute_http_url_re = re.compile("^https?://", re.I)
16 
17 class Http404(Exception):
18     pass
19@@ -73,7 +75,7 @@
20         """
21         if not location:
22             location = self.get_full_path()
23-        if not ':' in location:
24+        if not absolute_http_url_re.match(location):           
25             current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http',
26                                          self.get_host(), self.path)
27             location = urljoin(current_uri, location)