Ticket #3228: changes.diff

File changes.diff, 1.9 KB (added by Andy Gayton <andy-django@…>, 17 years ago)

changes since smartslash-2.diff was created

  • django/middleware/common.py

     
     1import md5
     2import re
     3
    14from django.conf import settings
    25from django import http
    36from django.core.mail import mail_managers
    4 import md5
    5 import re
     7from django.utils.http import urlquote
    68
    79class CommonMiddleware(object):
    810    """
     
    3234                    return http.HttpResponseForbidden('<h1>Forbidden</h1>')
    3335
    3436        # Check for a redirect based on settings.APPEND_SLASH and settings.PREPEND_WWW
    35         host = http.get_host(request)
     37        host = request.get_host()
    3638        old_url = [host, request.path]
    3739        new_url = old_url[:]
    3840        if settings.PREPEND_WWW and old_url[0] and not old_url[0].startswith('www.'):
     
    4648        if new_url != old_url:
    4749            # Redirect
    4850            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]))
    5052            else:
    51                 newurl = new_url[1]
     53                newurl = urlquote(new_url[1])
    5254            if request.GET:
    5355                newurl += '?' + request.GET.urlencode()
    5456            return http.HttpResponsePermanentRedirect(newurl)
     
    6163            if settings.SEND_BROKEN_LINK_EMAILS:
    6264                # If the referrer was from an internal link or a non-search-engine site,
    6365                # send a note to the managers.
    64                 domain = http.get_host(request)
     66                domain = request.get_host()
    6567                referer = request.META.get('HTTP_REFERER', None)
    6668                is_internal = _is_internal_request(domain, referer)
    6769                path = request.get_full_path()
Back to Top