Loading django/http/__init__.py +4 −1 Original line number Diff line number Diff line import os import re from Cookie import SimpleCookie, CookieError from pprint import pformat from urllib import urlencode Loading @@ -18,6 +19,8 @@ from utils import * RESERVED_CHARS="!*'();:@&=+$,/?%#[]" absolute_http_url_re = re.compile(r"^https?://", re.I) class Http404(Exception): pass Loading Loading @@ -65,7 +68,7 @@ class HttpRequest(object): """ 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) Loading tests/regressiontests/requests/tests.py +8 −0 Original line number Diff line number Diff line Loading @@ -36,4 +36,12 @@ META:{}> >>> 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 """ Loading
django/http/__init__.py +4 −1 Original line number Diff line number Diff line import os import re from Cookie import SimpleCookie, CookieError from pprint import pformat from urllib import urlencode Loading @@ -18,6 +19,8 @@ from utils import * RESERVED_CHARS="!*'();:@&=+$,/?%#[]" absolute_http_url_re = re.compile(r"^https?://", re.I) class Http404(Exception): pass Loading Loading @@ -65,7 +68,7 @@ class HttpRequest(object): """ 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) Loading
tests/regressiontests/requests/tests.py +8 −0 Original line number Diff line number Diff line Loading @@ -36,4 +36,12 @@ META:{}> >>> 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 """