fix(514): fix compatibility with rack 3#555
Merged
fletchto99 merged 3 commits intogithub:feature-7.2from Dec 16, 2025
Merged
Conversation
Do not join cookies with new like if they weren't before
Add `Rack::Headers` wrapping to middleware to prevent header manipulation issues. Added a test to verify cookies remain as an array when flagged if already in array format.
There was a problem hiding this comment.
Pull Request Overview
This PR fixes compatibility with Rack 3 by updating the handling of cookie headers, ensuring that cookies passed as either an array or a newline-delimited string are correctly processed.
- Update test expectations to use newline-delimited strings for cookie headers
- Modify middleware to handle cookies based on their original type (array vs. string)
- Add a new test to verify that an array remains an array after processing
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| spec/lib/secure_headers/middleware_spec.rb | Updates test cases for handling cookie header formats |
| lib/secure_headers/middleware.rb | Adjusts cookie processing logic for Rack 3 compatibility |
Comments suppressed due to low confidence (1)
spec/lib/secure_headers/middleware_spec.rb:86
- [nitpick] Ensure that this test also covers possible edge cases, such as improper formatting or unexpected delimiters in the cookie header, to provide comprehensive validation of the splitting logic.
cookie_middleware = Middleware.new(lambda { |env| [200, env.merge("Set-Cookie" => "_session=foobar\n_guest=true"), "app"] })
KyFaSt
approved these changes
Dec 16, 2025
fletchto99
approved these changes
Dec 16, 2025
Member
fletchto99
left a comment
There was a problem hiding this comment.
Thank you for the PR and apologies for the delay in getting this reviewed. We plan for this to be in the upcoming 7.2 release.
Open
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.
All PRs:
fixes #514 by adding compatibility with Rack 3 which doesn't support muplitple headers joined with
\n