Ticket #7472: 7472-2.patch

File 7472-2.patch, 3.5 KB (added by Fraser Nevett, 16 years ago)
  • django/core/handlers/base.py

     
    124124            else:
    125125                # When DEBUG is False, send an error message to the admins.
    126126                subject = 'Error (%s IP): %s' % ((request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS and 'internal' or 'EXTERNAL'), request.path)
    127                 try:
    128                     request_repr = repr(request)
    129                 except:
    130                     request_repr = "Request repr() unavailable"
     127                if request.is_secure():
     128                    request_repr = "Request details omitted because HTTPS was used."
     129                else:
     130                    try:
     131                        request_repr = repr(request)
     132                    except:
     133                        request_repr = "Request repr() unavailable"
    131134                message = "%s\n\n%s" % (self._get_traceback(exc_info), request_repr)
    132135                mail_admins(subject, message, fail_silently=True)
    133136                # Return an HttpResponse that displays a friendly error message.
  • django/middleware/common.py

     
    9696                is_internal = _is_internal_request(domain, referer)
    9797                path = request.get_full_path()
    9898                if referer and not _is_ignorable_404(path) and (is_internal or '?' not in referer):
    99                     ua = request.META.get('HTTP_USER_AGENT', '<none>')
    100                     ip = request.META.get('REMOTE_ADDR', '<none>')
     99                    if request.is_secure():
     100                        message = "Request details omitted because HTTPS was used."
     101                    else:
     102                        ua = request.META.get('HTTP_USER_AGENT', '<none>')
     103                        ip = request.META.get('REMOTE_ADDR', '<none>')
     104                        message = "Referrer: %s\nRequested URL: %s\nUser agent: %s\nIP address: %s\n" \
     105                            % (referer, request.get_full_path(), ua, ip)
    101106                    mail_managers("Broken %slink on %s" % ((is_internal and 'INTERNAL ' or ''), domain),
    102                         "Referrer: %s\nRequested URL: %s\nUser agent: %s\nIP address: %s\n" \
    103                                   % (referer, request.get_full_path(), ua, ip))
     107                        message)
    104108                return response
    105109
    106110        # Use ETags, if requested.
  • docs/settings.txt

     
    12391239
    12401240To disable this behavior, just remove all entries from the ``ADMINS`` setting.
    12411241
     1242The notification email contains information about the request which triggered
     1243the error, including GET data, POST data, cookies and other headers. If the
     1244request was made over HTTPS, this information is omitted for security reasons.
     1245
    12421246404 errors
    12431247----------
    12441248
     
    12591263be reported. Neither will any URL starting with ``/phpmyadmin/``.
    12601264
    12611265To disable this behavior, just remove all entries from the ``MANAGERS`` setting.
     1266
     1267The notification email contains information about the request which triggered
     1268the 404, including the referer, user agent and client IP. If the request was
     1269made over HTTPS, this information is omitted for security reasons.
Back to Top