Bug 805323 - Double-decode slashes in reasons parameter in middleware.

This contains a few edge-case bug fixes, and the middleware-side fix for bug 805323 for both the current and next versions.