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 — Reject non-token characters in HTTP/2 header names by daguimu · Pull Request #16762 · netty/netty

Reject non-token characters in HTTP/2 header names #16762

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.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
normanmaurer merged 3 commits into netty:4.2 from daguimu:fix/http2-header-name-token-validation-11975
Jun 30, 2026

Uh oh!

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

Merged

Reject non-token characters in HTTP/2 header names #16762

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit Hold shift + click to select a range
e4612ec
Reject non-token characters in HTTP/2 header names
daguimu May 7, 2026
b2e186b
Merge branch '4.2' into fix/http2-header-name-token-validation-11975
normanmaurer Jun 18, 2026
4d36ccf
Address review: keep the non-ASCII header test end-to-end, drop dupli…
daguimu Jun 21, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

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

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

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

Diff view
Diff view
Prev Previous commit
Address review: keep the non-ASCII header test end-to-end, drop dupli…
…cate

Per review feedback:
- InboundHttp2ToHttpAdapterTest.clientRequestSingleHeaderNonAsciiShouldThrow:
  instead of asserting the add() throws, disable validation on the client
  side (new DefaultHttp2Headers(false)) so the non-ASCII header reaches the
  wire and is rejected by the server, keeping the test end-to-end and
  showing the rejection surfaces as a stream error.
- DefaultHttp2HeadersTest: remove uppercaseHeaderNameStillRejected, already
  covered by the existing testHeaderNameValidation.
  • Loading branch information

Uh oh!

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

@daguimu
daguimu committed Jun 21, 2026
commit 4d36ccf220471094bca671334285c87b47eb79c3

Some comments aren't visible on the classic Files Changed page.

There are no files selected for viewing

12 changes: 0 additions & 12 deletions 12 codec-http2/src/test/java/io/netty/handler/codec/http2/DefaultHttp2HeadersTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -248,18 +248,6 @@ static Stream<Arguments> nonTokenBytesInHeaderName() {
);
}

@Test
public void uppercaseHeaderNameStillRejected() {
// Regression: pre-existing rejection of upper-case header names must continue to fire.
final Http2Headers headers = new DefaultHttp2Headers();
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() throws Throwable {
headers.add(of("X-Custom"), of("test"));
}
});
}

@Test
public void acceptValidLowercaseTokenHeaderName() {
// Regression: valid RFC 7230 token (lower-case ALPHA, DIGIT, "!#$%&'*+-.^_`|~") must be accepted.
Expand Down
23 changes: 13 additions & 10 deletions 23 codec-http2/src/test/java/io/netty/handler/codec/http2/InboundHttp2ToHttpAdapterTest.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.function.Executable;
import org.mockito.ArgumentCaptor;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
Expand All @@ -65,7 +64,6 @@
import static java.util.concurrent.TimeUnit.SECONDS;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
Expand Down Expand Up @@ -242,20 +240,25 @@ public void run() throws Http2Exception {
@Test
public void clientRequestSingleHeaderNonAsciiShouldThrow() throws Exception {
boostrapEnv(1, 1, 1);
// Adding a non-ASCII byte sequence as a header name now fails immediately at validation time
// (RFC 9113 §8.2.1 requires HTTP/2 field names to be valid HTTP/1.1 tokens).
final Http2Headers http2Headers = new DefaultHttp2Headers()
// Disable validation on the client side so the non-ASCII header name reaches the wire; the
// server-side validation (RFC 9113 §8.2.1 requires field names to be valid HTTP/1.1 tokens)
// then rejects it, which surfaces as a stream error.
final Http2Headers http2Headers = new DefaultHttp2Headers(false)
.method(new AsciiString("GET"))
.scheme(new AsciiString("https"))
.authority(new AsciiString("example.org"))
.path(new AsciiString("/some/path/resource2"));
assertThrows(Http2Exception.class, new Executable() {
@Override
public void execute() {
http2Headers.add(new AsciiString("çã".getBytes(CharsetUtil.UTF_8)),
.path(new AsciiString("/some/path/resource2"))
.add(new AsciiString("çã".getBytes(CharsetUtil.UTF_8)),
new AsciiString("Ãã".getBytes(CharsetUtil.UTF_8)));
runInChannel(clientChannel, new Http2Runnable() {
@Override
public void run() throws Http2Exception {
clientHandler.encoder().writeHeaders(ctxClient(), 3, http2Headers, 0, true, newPromiseClient());
clientChannel.flush();
}
});
awaitResponses();
assertTrue(isStreamError(clientException));
}

@Test
Expand Down
Loading
Oops, something went wrong.

Uh oh!

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

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.