Author Build Commit PR
flavorjones 24394 36e0f96 n/a
Repo Branch
rails/rails main
Message
Keep route redirects from a string template on the request host (#59218) * Keep route redirects from a string template on the request host For `redirect("/%{path}")`, the request `GET /old/%2Finjected` redirected to another host, because the target became `//injected`. So did a scheme in a param at the start of the template, as in `redirect("%{path}")` with `GET /old/https:%2F%2Finjected`. When interpolation would give the target a scheme or host that the template lacks, percent-encode the delimiter, so the target stays on the request host. Templates that name a scheme or host are unchanged. * Use `PathRedirect::SCHEME_OR_AUTHORITY` in `redirect_to` The regex that recognizes a target with its own scheme or host was duplicated in `redirect_to` and route redirects. Make the constant public and use it in `_compute_redirect_to_location`.

/api

Reference documentation

/guides

In-depth tutorials