Generated with the help of an LLM.
Problem/Motivation
"Add redirect" on the redirect_404 log decodes the logged path twice, so a 404 for /a%2Bb becomes a redirect from a b.
redirect_404 logs the request path after core has decoded it (a+b). Redirect404Operations passes it to the add form as ?source=, which Symfony decodes once when reading the query. RedirectForm::form() then runs urldecode() on it again, which turns + into a space.
Steps to reproduce
- Enable redirect_404.
- Visit
/a%2Bb, which doesn't exist. - Go to the "Fix 404 pages" tab at
/admin/config/search/redirect/404. The path is listed as/a+b. - Click "Add redirect". The "From" field shows
a b, nota+b.
Proposed resolution
Remove the urldecode() calls on the source and redirect query values in RedirectForm::form(): Symfony already decodes query values. Add a test that fixes a 404 for a%2Bb and checks the new redirect's source is a+b.
Remaining tasks
- Check nothing else links to the add form with an encoded
sourceorredirect. - Patch and tests.
AI disclosure
Claude Code (Claude Opus 5.5) found this while I was working on #2884630: Add support for encoded URLs (with spaces or other special characters) with it. It traced the cause through Redirect404Operations and RedirectForm and drafted this summary. I reviewed the code paths and reproduced the steps on a local site.
Comments