Repository navigation
fix: accept media types with parameters in datacontenttype - #66
Merged
Merged
Conversation
The check only allowed [-\w] around the slash, so valid types such as application/json; charset=utf-8 (the HTTP binding's own example), application/vnd.apache.thrift.binary and image/svg+xml were rejected, and a binary request with a charset parameter failed to unmarshal. It also accepted a trailing newline. The check now uses RFC 9110 tokens for the type and subtype and allows parameters without control characters. Signed-off-by: emir <52245396+EmiRZx@users.noreply.github.com>
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues are recorded for the expanded CloudEvent content-type validation.
No open issues 🎉
What changed in this PR
Fixes #65 by expanding CloudEvent datacontenttype validation to accept media types with parameters, dots, and plus signs while rejecting trailing newlines.
Changes:
- Uses RFC 9110 tokens for media type and subtype validation.
- Adds valid and invalid content-type test cases.
- Tests binary HTTP unmarshalling with
charset=utf-8.
| File | Description |
|---|---|
tests/Unit/V1/CloudEventTest.php |
Adds content-type validation tests. |
tests/Unit/Http/UnmarshallerTest.php |
Tests binary requests with content-type parameters. |
src/V1/CloudEventTrait.php |
Expands media-type validation and rejects trailing newlines. |
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 #65. the type and subtype are now RFC 9110 tokens. parameters are allowed as long as they have no control characters. a trailing newline or a CRLF is rejected. new tests cover valid and invalid values and a binary request with
charset=utf-8. they fail onmainand pass here. tests pass on PHP 7.4 and 8.4. phpcs and psalm are clean.