Author: mtredinnick
Date: 2008-08-23 12:28:12 -0500 (Sat, 23 Aug 2008)
New Revision: 8490
Modified:
django/trunk/django/http/__init__.py
django/trunk/tests/regressiontests/requests/tests.py
Log:
Fixed #7494 -- Fixed build_absolute_url() for some types of (uncommon) URLs.
Patch from [EMAIL PROTECTED] and RobotAdam.
Modified: django/trunk/django/http/__init__.py
===================================================================
--- django/trunk/django/http/__init__.py 2008-08-23 17:26:00 UTC (rev
8489)
+++ django/trunk/django/http/__init__.py 2008-08-23 17:28:12 UTC (rev
8490)
@@ -1,4 +1,5 @@
import os
+import re
from Cookie import SimpleCookie, CookieError
from pprint import pformat
from urllib import urlencode
@@ -18,6 +19,8 @@
RESERVED_CHARS="!*'();:@&=+$,/?%#[]"
+absolute_http_url_re = re.compile(r"^https?://", re.I)
+
class Http404(Exception):
pass
@@ -65,7 +68,7 @@
"""
if not location:
location = self.get_full_path()
- if not ':' in location:
+ if not absolute_http_url_re.match(location):
current_uri = '%s://%s%s' % (self.is_secure() and 'https' or
'http',
self.get_host(), self.path)
location = urljoin(current_uri, location)
Modified: django/trunk/tests/regressiontests/requests/tests.py
===================================================================
--- django/trunk/tests/regressiontests/requests/tests.py 2008-08-23
17:26:00 UTC (rev 8489)
+++ django/trunk/tests/regressiontests/requests/tests.py 2008-08-23
17:28:12 UTC (rev 8490)
@@ -36,4 +36,12 @@
>>> from django.http import parse_cookie
>>> parse_cookie('invalid:key=true')
{}
+
+>>> request = HttpRequest()
+>>> print request.build_absolute_uri(location="https://www.example.com/asdf")
+https://www.example.com/asdf
+>>> request.get_host = lambda: 'www.example.com'
+>>> request.path = ''
+>>> print request.build_absolute_uri(location="/path/with:colons")
+http://www.example.com/path/with:colons
"""
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---