Merge lp://staging/~thumper/launchpad/fix-dud-referer into lp://staging/launchpad

Proposed by Tim Penhey
Status: Merged
Approved by: Tim Penhey
Approved revision: no longer in the source branch.
Merged at revision: 12775
Proposed branch: lp://staging/~thumper/launchpad/fix-dud-referer
Merge into: lp://staging/launchpad
Diff against target: 64 lines (+29/-6)
2 files modified
lib/canonical/launchpad/webapp/error.py (+9/-1)
lib/canonical/launchpad/webapp/tests/test_publication.py (+20/-5)
To merge this branch: bzr merge lp://staging/~thumper/launchpad/fix-dud-referer
Reviewer Review Type Date Requested Status
Steve Kowalik (community) code Approve
Review via email: mp+56508@code.staging.launchpad.net

Commit message

[r=stevenk][bug=752218] Fix the UnicodeDecodeError when the referer is encoded and the resource is not found.

Description of the change

I was investigating bug 44919, and looking at OOPS-979B2903, OOPS-1921EC1104 and OOPS-979C3111.

The not found page was failing to render due to a unicode decode error on the referer. This is different to the unicode decode error on bug 44919 which as to do with form data.

I managed to replicate the error first. It would oops twice, once for the not found, and a second time when trying to render the page with the bad referer.

The simplest fix was to ignore the referer if it doesn't convert nicely to unicode.

To post a comment you must log in.
Revision history for this message
Steve Kowalik (stevenk) :
review: Approve (code)
Revision history for this message
Robert Collins (lifeless) wrote :

perhaps

if type(referer) != unicode:
    referer = referer.decode('utf8', errors='replace')

instead, which will replace the bad data but leave the rest intact.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.