Repository navigation
fix: allow whitespace before parameters in Content-Type - #70
Merged
Merged
Conversation
RFC 9110 allows optional whitespace around the ";" that starts media type parameters. The unmarshaller compared the part before ";" without trimming it, so "application/cloudevents+json ; charset=utf-8" and the batch type written the same way were rejected as unsupported. Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are reported for the Content-Type whitespace handling change.
No open issues 🎉
What changed in this PR
Fixes #69 by allowing whitespace before Content-Type parameters when recognizing structured and batch CloudEvents.
Changes:
- Trims the media type before comparison.
- Adds regression coverage for spaces in structured requests and tabs in batch requests.
| File | Description |
|---|---|
| tests/Unit/Http/UnmarshallerTest.php | Tests structured and batch requests with whitespace before parameters. |
| src/Http/Unmarshaller.php | Trims the extracted media type before matching. |
Review effort: Balanced
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.
fixes #69.
Unmarshallernow trims the media type before comparing it. the new test sends a structured event withapplication/cloudevents+json ; charset=utf-8and a batch with a tab before;. it fails onmainand passes here. tests pass on PHP 7.4 and 8.4. phpcs and psalm are clean. binary mode with a space before;also needs #66, sincedatacontenttyperejects parameters onmain.