GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — HttpUtil.getMimeType() must not include whitespace before the next Content-Type parameter by ohchanKyu · Pull Request #17456 · netty/netty

Conversation

@ohchanKyu

@ohchanKyu ohchanKyu commented Sep 13, 2026

Copy link
Copy Markdown
Contributor

Motivation:

RFC 9110 section 8.3.1 defines media type parameters as *( OWS ";" OWS [ parameter ] ), so optional whitespace is allowed before the semicolon that starts the next parameter. For a header like text/html ; charset=utf-8, HttpUtil.getMimeType() returned text/html with the trailing space, so comparisons against constants such as HttpHeaderValues.TEXT_HTML failed for a well-formed header. This is the same class of bug that #17386 fixed for getCharset(), and after that fix the two helpers were inconsistent on the same input.

Modifications:

  • Trim trailing OWS from the media type extracted by HttpUtil.getMimeType() before returning it, reusing the existing isOws(...) helper.
  • Add a regression test covering SP, HTAB and mixed OWS before the semicolon, for both the CharSequence and the HttpMessage overload.

Result:

HttpUtil.getMimeType() returns only the type/subtype part of a Content-Type value even when optional whitespace precedes the parameter delimiter.

Fixes #17455.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@ohchanKyu
HttpUtil.getMimeType() must not include whitespace before the next Co…
422ac7c
…ntent-Type parameter

Motivation:

RFC 9110 section 8.3.1 defines media type parameters as
`*( OWS ";" OWS [ parameter ] )`, so optional whitespace is allowed
before the semicolon that starts the next parameter. For a header like
`text/html ; charset=utf-8`, `HttpUtil.getMimeType()` returned
`text/html ` with the trailing space, so comparisons against constants
such as `HttpHeaderValues.TEXT_HTML` failed for a well-formed header.
This is the same class of bug that netty#17386 fixed for `getCharset()`, and
after that fix the two helpers were inconsistent on the same input.

Modifications:

- Trim trailing OWS from the media type extracted by
  `HttpUtil.getMimeType()` before returning it, reusing the existing
  `isOws(...)` helper.
- Add a regression test covering SP, HTAB and mixed OWS before the
  semicolon, for both the `CharSequence` and the `HttpMessage` overload.

Result:

`HttpUtil.getMimeType()` returns only the `type/subtype` part of a
Content-Type value even when optional whitespace precedes the parameter
delimiter.

Fixes netty#17455.
@ohchanKyu ohchanKyu changed the title HttpUtil.getMimeType() must not include whitespace before the next Co… HttpUtil.getMimeType() must not include whitespace before the next Content-Type parameter Sep 13, 2026
@normanmaurer
normanmaurer requested review from violetagg and yawkat September 14, 2026 10:17
@normanmaurer normanmaurer added this to the 4.2.19.Final milestone Sep 14, 2026
@normanmaurer

normanmaurer commented Sep 14, 2026

Copy link
Copy Markdown
Member

Looks valid to me.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

normanmaurer
normanmaurer approved these changes Sep 14, 2026
View reviewed changes
@normanmaurer normanmaurer added needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. labels Sep 14, 2026
violetagg
violetagg approved these changes Sep 14, 2026
View reviewed changes
@testlens-app

testlens-app Bot commented Sep 14, 2026

Copy link
Copy Markdown

✅ All tests passed ✅

🏷️ Commit: 422ac7c
▶️ Tests: 451636 executed
⚪️ Checks: 29/29 completed


Learn more about TestLens at testlens.app/docs.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

yawkat
yawkat approved these changes Sep 15, 2026
View reviewed changes
@normanmaurer
normanmaurer merged commit 4b3de16 into netty:4.2 Sep 16, 2026
30 checks passed

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Sep 16, 2026
Auto-port 4.1: HttpUtil.getMimeType() must not include whitespace before the next Content-Type parameter #17494
Merged
@netty-project-bot

netty-project-bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 4.1: #17494

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@github-actions github-actions Bot removed the needs-cherry-pick-4.1 This PR should be cherry-picked to 4.1 once merged. label Sep 16, 2026
@netty-project-bot

netty-project-bot commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

Auto-port PR for 5.0: #17496

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@netty-project-bot netty-project-bot mentioned this pull request Sep 16, 2026
Auto-port 5.0: HttpUtil.getMimeType() must not include whitespace before the next Content-Type parameter #17496
Merged
@github-actions github-actions Bot removed the needs-cherry-pick-5.0 This PR should be cherry-picked to 5.0 once merged. label Sep 16, 2026
normanmaurer pushed a commit that referenced this pull request Sep 16, 2026
@netty-project-bot @ohchanKyu
Auto-port 4.1: HttpUtil.getMimeType() must not include whitespace bef…
f60b495
…ore the next Content-Type parameter (#17494)

Auto-port of #17456 to 4.1
Cherry-picked commit: 4b3de16

---
Motivation:

RFC 9110 section 8.3.1 defines media type parameters as `*( OWS ";" OWS
[ parameter ] )`, so optional whitespace is allowed before the semicolon
that starts the next parameter. For a header like `text/html ;
charset=utf-8`, `HttpUtil.getMimeType()` returned `text/html ` with the
trailing space, so comparisons against constants such as
`HttpHeaderValues.TEXT_HTML` failed for a well-formed header. This is
the same class of bug that #17386 fixed for `getCharset()`, and after
that fix the two helpers were inconsistent on the same input.

Modifications:

- Trim trailing OWS from the media type extracted by
`HttpUtil.getMimeType()` before returning it, reusing the existing
`isOws(...)` helper.
- Add a regression test covering SP, HTAB and mixed OWS before the
semicolon, for both the `CharSequence` and the `HttpMessage` overload.

Result:

`HttpUtil.getMimeType()` returns only the `type/subtype` part of a
Content-Type value even when optional whitespace precedes the parameter
delimiter.

Fixes #17455.

Co-authored-by: 오규찬 (B팀 서버) <[email protected]>
normanmaurer pushed a commit that referenced this pull request Sep 16, 2026
@netty-project-bot @ohchanKyu
Auto-port 5.0: HttpUtil.getMimeType() must not include whitespace bef…
8622c85
…ore the next Content-Type parameter (#17496)

Auto-port of #17456 to 5.0
Cherry-picked commit: 4b3de16

---
Motivation:

RFC 9110 section 8.3.1 defines media type parameters as `*( OWS ";" OWS
[ parameter ] )`, so optional whitespace is allowed before the semicolon
that starts the next parameter. For a header like `text/html ;
charset=utf-8`, `HttpUtil.getMimeType()` returned `text/html ` with the
trailing space, so comparisons against constants such as
`HttpHeaderValues.TEXT_HTML` failed for a well-formed header. This is
the same class of bug that #17386 fixed for `getCharset()`, and after
that fix the two helpers were inconsistent on the same input.

Modifications:

- Trim trailing OWS from the media type extracted by
`HttpUtil.getMimeType()` before returning it, reusing the existing
`isOws(...)` helper.
- Add a regression test covering SP, HTAB and mixed OWS before the
semicolon, for both the `CharSequence` and the `HttpMessage` overload.

Result:

`HttpUtil.getMimeType()` returns only the `type/subtype` part of a
Content-Type value even when optional whitespace precedes the parameter
delimiter.

Fixes #17455.

Co-authored-by: 오규찬 (B팀 서버) <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Oct 1, 2026
child5 #17695
Closed
lltopk pushed a commit to lltopk/netty that referenced this pull request Oct 24, 2026
@netty-project-bot @ohchanKyu @lltopk
Auto-port 4.1: HttpUtil.getMimeType() must not include whitespace bef…
4551e97
…ore the next Content-Type parameter (netty#17494)

Auto-port of netty#17456 to 4.1
Cherry-picked commit: 4b3de16

---
Motivation:

RFC 9110 section 8.3.1 defines media type parameters as `*( OWS ";" OWS
[ parameter ] )`, so optional whitespace is allowed before the semicolon
that starts the next parameter. For a header like `text/html ;
charset=utf-8`, `HttpUtil.getMimeType()` returned `text/html ` with the
trailing space, so comparisons against constants such as
`HttpHeaderValues.TEXT_HTML` failed for a well-formed header. This is
the same class of bug that netty#17386 fixed for `getCharset()`, and after
that fix the two helpers were inconsistent on the same input.

Modifications:

- Trim trailing OWS from the media type extracted by
`HttpUtil.getMimeType()` before returning it, reusing the existing
`isOws(...)` helper.
- Add a regression test covering SP, HTAB and mixed OWS before the
semicolon, for both the `CharSequence` and the `HttpMessage` overload.

Result:

`HttpUtil.getMimeType()` returns only the `type/subtype` part of a
Content-Type value even when optional whitespace precedes the parameter
delimiter.

Fixes netty#17455.

Co-authored-by: 오규찬 (B팀 서버) <[email protected]>
@normanmaurer normanmaurer mentioned this pull request Oct 26, 2026
crisp nova cceda091 #18109
Closed
He-Pin added a commit to He-Pin/incubator-pekko-http that referenced this pull request Nov 15, 2026
@He-Pin
fix: accept empty Content-Type parameter slots
565b9fd
Motivation:
RFC 9110 allows empty parameter slots, but Pekko HTTP requires a
named parameter after each semicolon in Content-Type.

Modification:
Ignore empty slots in the Content-Type rule without changing shared
media-type parsing. Cover trailing and interleaved slots, quoted
semicolons, and an incomplete named parameter.

Result:
Valid Content-Type values are parsed without losing actual parameters.
Incomplete named parameters still fail parsing.

References:
- RFC 9110 §§ 5.6.6 and 8.3.1: https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.6
- Netty #17456: netty/netty#17456
@He-Pin He-Pin mentioned this pull request Nov 15, 2026
fix: accept empty Content-Type parameter slots apache/pekko-http#1471
Merged
pjfanning pushed a commit to He-Pin/incubator-pekko-http that referenced this pull request Nov 17, 2026
@He-Pin @pjfanning
fix: accept empty Content-Type parameter slots
3b34cd2
Motivation:
RFC 9110 allows empty parameter slots, but Pekko HTTP requires a
named parameter after each semicolon in Content-Type.

Modification:
Ignore empty slots in the Content-Type rule without changing shared
media-type parsing. Cover trailing and interleaved slots, quoted
semicolons, and an incomplete named parameter.

Result:
Valid Content-Type values are parsed without losing actual parameters.
Incomplete named parameters still fail parsing.

References:
- RFC 9110 §§ 5.6.6 and 8.3.1: https://www.rfc-editor.org/rfc/rfc9110.html#section-5.6.6
- Netty #17456: netty/netty#17456
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@normanmaurer normanmaurer normanmaurer approved these changes
@violetagg violetagg violetagg approved these changes
@yawkat yawkat yawkat approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

4.2.19.Final

Development

Successfully merging this pull request may close these issues.

HttpUtil.getMimeType() keeps trailing whitespace when OWS precedes the next Content-Type parameter

Uh oh!

There was an error while loading. Please reload this page.

5 participants

@ohchanKyu @normanmaurer @netty-project-bot @violetagg @yawkat
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.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.