mozilla-services / mozservices

INACTIVE - http://mzl.la/ghe-archive - Various utilities for Pyramid-based Mozilla applications
33 stars 17 forks source link

Bug 1365328 - Gracefully handle non-utf8 URL paths #40

Closed rfk closed 7 years ago

rfk commented 7 years ago

In https://bugzilla.mozilla.org/show_bug.cgi?id=1365328 we discovered that the tokenserver returns a "500 server error" when requesting a URL with invalid utf8 in the path component, such as "/%FF". There's no harm in erroring out, but let's do it cleanly so that the server logs aren't filled with spurious 500 errors.

This adds an exception view to convert the exception into a 404, which appears to be the recommended approach for pyramid. It also slightly adjusts the metrics-gathering code, which assumes that the path can be converted to a string, and which was previously running before pyramid got a chance to route-match the path and detect it as invalid.

@Natim r?

rfk commented 7 years ago

Hrm, looks like some trouble installing dependencies on python 2.6, I think we should just drop support for it at this stage.