Ticket #3228: changes.diff
File changes.diff, 1.9 KB (added by , 17 years ago) |
---|
-
django/middleware/common.py
1 import md5 2 import re 3 1 4 from django.conf import settings 2 5 from django import http 3 6 from django.core.mail import mail_managers 4 import md5 5 import re 7 from django.utils.http import urlquote 6 8 7 9 class CommonMiddleware(object): 8 10 """ … … 32 34 return http.HttpResponseForbidden('<h1>Forbidden</h1>') 33 35 34 36 # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW 35 host = http.get_host(request)37 host = request.get_host() 36 38 old_url = [host, request.path] 37 39 new_url = old_url[:] 38 40 if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'): … … 46 48 if new_url != old_url: 47 49 # Redirect 48 50 if new_url[0]: 49 newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], new_url[1])51 newurl = "%s://%s%s" % (request.is_secure() and 'https' or 'http', new_url[0], urlquote(new_url[1])) 50 52 else: 51 newurl = new_url[1]53 newurl = urlquote(new_url[1]) 52 54 if request.GET: 53 55 newurl += '?' + request.GET.urlencode() 54 56 return http.HttpResponsePermanentRedirect(newurl) … … 61 63 if settings.SEND_BROKEN_LINK_EMAILS: 62 64 # If the referrer was from an internal link or a non-search-engine site, 63 65 # send a note to the managers. 64 domain = http.get_host(request)66 domain = request.get_host() 65 67 referer = request.META.get('HTTP_REFERER', None) 66 68 is_internal = _is_internal_request(domain, referer) 67 69 path = request.get_full_path()