Conversation
…nt dev toolbar injection into 204 responses
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.
The defect
A successful DELETE request returns
204 No Content, but the development toolbar middleware does not account for204responses._stage_dev_toolbar_inject()currently checks whether dev mode is enabled and whether the response is HTML, but it does not check the response status code. Tina4 responses default totext/html; charset=utf-8, so a204response can pass the HTML check even though it must not contain a response body.The toolbar is then appended to the otherwise empty response. This produces an invalid
204response containing development-toolbar HTML, which can cause DELETE requests to fail when running in development mode.The issue is only present with development mode enabled. Disabling dev mode bypasses the toolbar middleware and allows the DELETE request to complete successfully.
The fix
Updated
_stage_dev_toolbar_inject()to skip204 No Contentresponses:This ensures the development toolbar only modifies responses that are appropriate for HTML injection.
A successful DELETE now remains:
with no response body, as required.
Verification
Verified the issue by testing the same DELETE request with development mode enabled and disabled.
Before the fix:
204response.After the fix:
204response is returned without the development toolbar being injected.Scope
This change is limited to the development toolbar response stage. It does not change DELETE route behaviour, database operations, or production responses.
The existing
204 No Contentresponse from the DELETE endpoint remains unchanged; the fix prevents development middleware from modifying it.