Skip to content

fix: allow whitespace before parameters in Content-Type - #70

Merged
duglin merged 1 commit into
cloudevents:mainfrom
EmiRZx:fix-content-type-ows
Dec 3, 2026
Merged

duglin merged 1 commit into
cloudevents:mainfrom
EmiRZx:fix-content-type-ows

Conversation

@EmiRZx

@EmiRZx EmiRZx commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

fixes #69. Unmarshaller now trims the media type before comparing it. the new test sends a structured event with application/cloudevents+json ; charset=utf-8 and a batch with a tab before ;. it fails on main and 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, since datacontenttype rejects parameters on main.

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>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟢 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

@duglin
duglin merged commit 6be3518 into cloudevents:main Dec 3, 2026
10 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Content-Type with whitespace before parameters isn't recognized

3 participants