Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[HttpFoundation] Fix AcceptHeader overwrites items with different parameters#62287
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:7.3
Are you sure you want to change the base?
Conversation
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
b72a7a0 toc99d747CompareHi@yoeunes, From what I understand, this looks more like an enhancement of the existing behaviour rather than a bug fix. Is that correct? Thanks! |
yoeunes commentedNov 3, 2025 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Hi@Spomky, I consider this a bug fix because the current implementation incorrectly overwrites header items (e.g., If it's confirmed as a bug fix, should I rebase this onto 6.4 instead? Let me know your thoughts or if more details are needed |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thanks for taking the time to look into the issue I've created yesterday! 👍
It feels like the implementation might be a bit brittle in regards of some assumptions made on the case-(in)sensitivity comparison of two media type strings? Also, certainly having more data to take into account for matching makes things harder. Having test coverage is great, maybe we can improve/simplify the logic still in some areas?
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
9e19845 tobebe53dCompareHi@andesk, I'm consolidating my responses to your comments here to keep the thread tidy. Thanks for the detailed review. I've pushed a full refactor that applies your suggestions, makes the code more readable, and adds explanatory comments. Regarding case-insensitivity, you are correct. I'm now normalizing parameter names using The PR should be ready for another look. Thanks! |
bebe53d toc1dee8fCompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Thank you for working on this issue.
I think, we should add additional tests forRequest::getAcceptableContentTypes() andRequest::getPreferredFormat() because they're directly impacted by this change.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
7f880eb to284531eCompareHi@derrabus, thank you for your review and feedback! I've just pushed an update to add the requested tests for Let me know if anything else is needed. |
284531e to9b1fb5cCompare9b1fb5c to33f535eCompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
👍 Many thanks!
This PR fixes a bug in
AcceptHeaderwhere items with the same media type but different parameters (e.g.,text/plain;format=flowedandtext/plain;format=fixed) would overwrite each other.The
add()method now uses a canonical key that includes all parameters (exceptq), ensuring distinct items are stored correctly.Consequently, the
get()method has been updated to perform proper content negotiation (as described in RFC 9110), including matching parameters and sorting by specificity (e.g.,text/plain>text/*>*/*). New tests are added to cover these cases.