Repository navigation
Conversation
The guard in redirect() only validated non-integer status codes, so any integer passed: redirect($url, 200) sent "200 OK" with a Location header. The check was also skipped entirely when the redirect fell back to JavaScript. The status is now validated with isRedirectState() before anything is sent, in every branch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary of Changes
The guard in
AbstractWebApplication::redirect()readsif (!\is_int($status) && !$this->isRedirectState($status)), so only non-integer values were checked and every integer passed:redirect('http://x.test/', 200)sendsHTTP/1.1 200 OKplus aLocationheader. The check also sat inside the header branch, so the JavaScript fallbacks (headers already sent, Trident with non-ASCII URL) skipped it completely.The status is now checked with
isRedirectState()at the start ofredirect(), before anything is output, and anInvalidArgumentExceptionis thrown for anything that is not a known 3xx code.Behaviour change in 4.x: calls that passed a non-3xx integer (which produced a broken response) now throw.
Testing Instructions
vendor/bin/phpunit --filter testRedirectWithInvalidStatuscovers 200, 404, an unknown 3xx code (399) and a non-numeric string, with headers already sent so that the JavaScript branch is exercised too. All four cases fail without the change insrc/; the existing redirect tests still pass.Documentation Changes Required
docs/web-application.mddescribed the permissive check as a pitfall; it now describes the validation.docs/api-reference.mdmentions the exception.🤖 Generated with Claude Code