Django

Code

Changeset 8490

Show
Ignore:
Timestamp:
08/23/08 12:28:12 (3 months ago)
Author:
mtredinnick
Message:

Fixed #7494 -- Fixed build_absolute_url() for some types of (uncommon) URLs.
Patch from tom@almostobsolete.net and RobotAdam?.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/http/__init__.py

    r8460 r8490  
    11import os 
     2import re 
    23from Cookie import SimpleCookie, CookieError 
    34from pprint import pformat 
     
    1819 
    1920RESERVED_CHARS="!*'();:@&=+$,/?%#[]" 
     21 
     22absolute_http_url_re = re.compile(r"^https?://", re.I) 
    2023 
    2124class Http404(Exception): 
     
    6669        if not location: 
    6770            location = self.get_full_path() 
    68         if not ':' in location
     71        if not absolute_http_url_re.match(location)
    6972            current_uri = '%s://%s%s' % (self.is_secure() and 'https' or 'http', 
    7073                                         self.get_host(), self.path) 
  • django/trunk/tests/regressiontests/requests/tests.py

    r8015 r8490  
    3737>>> parse_cookie('invalid:key=true') 
    3838{} 
     39 
     40>>> request = HttpRequest() 
     41>>> print request.build_absolute_uri(location="https://www.example.com/asdf") 
     42https://www.example.com/asdf 
     43>>> request.get_host = lambda: 'www.example.com' 
     44>>> request.path = '' 
     45>>> print request.build_absolute_uri(location="/path/with:colons") 
     46http://www.example.com/path/with:colons 
    3947"""