Opened 10 years ago

Closed 10 years ago

#24681 closed Bug (fixed)

BrokenLinkEmailsMiddleware UnicodeDecodeError

Reported by: Oliver Bristow Owned by: Oliver Bristow
Component: HTTP handling Version: dev
Severity: Normal Keywords: BrokenLinkEmailsMiddleware UnicodeDecodeError
Cc: Triage Stage: Ready for checkin
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: yes UI/UX: no

Description (last modified by Oliver Bristow)

Using Python 2.7.6 and Django 1.7.6 we got an internal server error when there were Referer and non-ASCII User-Agent headers on a request that lead to a 404 response:

Traceback (most recent call last):
  File ".../django/core/handlers/base.py", line 204, in get_response
    response = middleware_method(request, response)
  File ".../django/middleware/common.py", line 156, in process_response
    "IP address: %s\n" % (referer, path, ua, ip),
UnicodeDecodeError: 'ascii' codec can't decode byte 0xd0 in position 0: ordinal not in range(128)

This is a problem goes back to at least 1.4.x and is still a on 1.8.x.

I have a fix with a test that I will create a pull request for.

Change History (6)

comment:1 by Oliver Bristow, 10 years ago

Description: modified (diff)
Keywords: BrokenLinkEmailsMiddleware added; CommonMiddleware removed
Owner: changed from nobody to Oliver Bristow
Status: newassigned
Summary: CommonMiddleware UnicodeDecodeErrorBrokenLinkEmailsMiddleware UnicodeDecodeError

comment:2 by Oliver Bristow, 10 years ago

Created pull request on Github.

comment:3 by Claude Paroz, 10 years ago

Triage Stage: UnreviewedReady for checkin

Looks good, except a minor note added on the PR.

comment:4 by Oliver Bristow, 10 years ago

Thanks - I added check for partially decoded user agent string in email body.

comment:5 by Oliver Bristow, 10 years ago

Cleaned up code following pointers.

comment:6 by Claude Paroz <claude@…>, 10 years ago

Resolution: fixed
Status: assignedclosed

In 4cd72709:

Fixed #24681 -- Removed Unicode bug in BrokenLinkEmailMiddleware

Note: See TracTickets for help on using tickets.
Back to Top