Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

[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

Open
yoeunes wants to merge1 commit intosymfony:7.3
base:7.3
Choose a base branch
Loading
fromyoeunes:httpfoundation-acceptheader-params

Conversation

@yoeunes
Copy link
Contributor

QA
Branch?7.3
Bug fix?yes
New feature?no
BC breaks?no
Deprecations?no
IssuesFixes#62282
LicenseMIT

This PR fixes a bug inAcceptHeader where items with the same media type but different parameters (e.g.,text/plain;format=flowed andtext/plain;format=fixed) would overwrite each other.

Theadd() method now uses a canonical key that includes all parameters (exceptq), ensuring distinct items are stored correctly.

Consequently, theget() 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.

andesk reacted with heart emoji
@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch 2 times, most recently fromb72a7a0 toc99d747CompareNovember 3, 2025 10:02
@Spomky
Copy link
Contributor

Hi@yoeunes,

From what I understand, this looks more like an enhancement of the existing behaviour rather than a bug fix. Is that correct?
If it is indeed a bug fix, it should probably target 6.4 instead of 7.4.

Thanks!

@yoeunes
Copy link
ContributorAuthor

yoeunes commentedNov 3, 2025
edited
Loading

Hi@Spomky, I consider this a bug fix because the current implementation incorrectly overwrites header items (e.g.,text/plain;format=flowed (q=1.0) is lost iftext/plain;format=fixed (q=0.4) is also present) which breaks content negotiation

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

Copy link
Contributor

@andeskandesk left a 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?

@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch 6 times, most recently from9e19845 tobebe53dCompareNovember 3, 2025 19:36
@yoeunes
Copy link
ContributorAuthor

Hi@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 usingstrtolower() when building the canonical key. This aligns with RFC 9110 (Section 5.6.6) and correctly handles duplicates (e.g.,Charset vscharset).
https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.6

The PR should be ready for another look. Thanks!

@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch frombebe53d toc1dee8fCompareNovember 3, 2025 19:57
Copy link
Member

@derrabusderrabus left a 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.

@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch 2 times, most recently from7f880eb to284531eCompareNovember 5, 2025 12:57
@yoeunes
Copy link
ContributorAuthor

Hi@derrabus, thank you for your review and feedback!

I've just pushed an update to add the requested tests forRequest::getAcceptableContentTypes() andRequest::getPreferredFormat(), covering scenarios with parameters, quality sorting, wildcards, case-insensitivity

Let me know if anything else is needed.

@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch from284531e to9b1fb5cCompareNovember 5, 2025 13:28
@yoeunesyoeunesforce-pushed thehttpfoundation-acceptheader-params branch from9b1fb5c to33f535eCompareNovember 6, 2025 20:06
Copy link
Contributor

@SpomkySpomky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

👍 Many thanks!

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@nicolas-grekasnicolas-grekasnicolas-grekas left review comments

@SpomkySpomkySpomky approved these changes

@derrabusderrabusderrabus approved these changes

+1 more reviewer

@andeskandeskandesk left review comments

Reviewers whose approvals may not affect merge requirements

Assignees

No one assigned

Projects

None yet

Milestone

7.3

Development

Successfully merging this pull request may close these issues.

6 participants

@yoeunes@Spomky@andesk@nicolas-grekas@derrabus@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp