GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||
GeezerVison is showing github.com — HttpUtil.getCharset() must accept whitespace before the next Content-Type parameter by hunseonglee · Pull Request #17386 · netty/netty ConversationMotivation:RFC 9110 section 5.6.6 defines media type parameters as Modification:Trim the extracted charset sequence in Result:Content-Type headers with optional whitespace before the next parameter now resolve to the correct charset instead of the default. Two regression tests added (fail on Fixes #17384.
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions…Type parameter Motivation: RFC 9110 section 5.6.6 defines 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 ; action=foo' HttpUtil.getCharset() extracted 'utf-8 ' (with the trailing space), failed to resolve the charset and silently fell back to the default charset. Modifications: Trim the extracted charset sequence in HttpUtil.getCharset() before stripping quotes and resolving the Charset. Result: Content-Type headers with optional whitespace before the next parameter now resolve to the correct charset instead of the default.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Contributor
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Author
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
Member
All reactions
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page.
|
There was an error while loading. Please reload this page.
|
@ParameterizedTest @CsvSource({ "text/html; charset=utf-8 ; action=\"foo\", UTF-8", "text/html; charset= ; action=\"foo\", ISO-8859-1" }) void test(String value, String expected) { // passes with String assertEquals(expected, HttpUtil.getCharset(value).name()); // does not pass with CharSequence CharSequence charSequence = CharBuffer.wrap(value); assertEquals(expected, HttpUtil.getCharset(charSequence).name()); } Also we want to trim only the trailing OWS but with this fix, |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Address review feedback: leading whitespace after '=' is not grammar-legal per RFC 9110 and must keep failing the charset lookup, and AsciiString.trim misbehaves for CharSequence implementations other than String and AsciiString. Trim only the trailing optional whitespace with an explicit scan over the CharSequence.
|
@violetagg Both points addressed, thanks! I replaced
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
🚨 TestLens detected 1 failed test 🚨Here is what you can do:
Test SummaryBuild PR / macos-x86_64-java11-boringssl build > Netty/Transport/Native/KQueue
🏷️ Commit: 943f13f Test FailuresKQueueDatagramUnicastIPv6MappedTest > testSimpleSendCompositeHeapByteBuf(TestInfo) (Netty/Transport/Native/KQueue in Build PR / macos-x86_64-java11-boringssl build)Rerun ControlsSelect tests to mute in this pull request:
Reuse successful test results:
Click the checkbox to trigger a rerun:
Learn more about TestLens at testlens.app/docs. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
The failing test ( |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Auto-port PR for 5.0: #17435 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Auto-port PR for 4.1: #17436 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
…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.
…e next Content-Type parameter (#17435) Auto-port of #17386 to 5.0 Cherry-picked commit: 086310c --- ### Motivation: RFC 9110 section 5.6.6 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 ; action="foo"`, `HttpUtil.getCharset()` extracted `utf-8 ` (with the trailing space), failed to resolve the charset, and silently fell back to the default charset — decoding the body with the wrong charset. The quoted form `charset="utf-8" ; ...` was broken the same way because the trailing space defeats the quote-stripping. ### Modification: Trim the extracted charset sequence in `HttpUtil.getCharset()` before stripping quotes and resolving the `Charset`. The raw-sequence API `getCharsetAsSequence` is deliberately left unchanged (its tests pin the raw behavior). ### Result: Content-Type headers with optional whitespace before the next parameter now resolve to the correct charset instead of the default. Two regression tests added (fail on `4.2`, pass with the fix); `HttpUtilTest` passes 150/150. Fixes #17384. Co-authored-by: seonghun lee <[email protected]>
…e next Content-Type parameter (#17436) Auto-port of #17386 to 4.1 Cherry-picked commit: 086310c --- ### Motivation: RFC 9110 section 5.6.6 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 ; action="foo"`, `HttpUtil.getCharset()` extracted `utf-8 ` (with the trailing space), failed to resolve the charset, and silently fell back to the default charset — decoding the body with the wrong charset. The quoted form `charset="utf-8" ; ...` was broken the same way because the trailing space defeats the quote-stripping. ### Modification: Trim the extracted charset sequence in `HttpUtil.getCharset()` before stripping quotes and resolving the `Charset`. The raw-sequence API `getCharsetAsSequence` is deliberately left unchanged (its tests pin the raw behavior). ### Result: Content-Type headers with optional whitespace before the next parameter now resolve to the correct charset instead of the default. Two regression tests added (fail on `4.2`, pass with the fix); `HttpUtilTest` passes 150/150. Fixes #17384. Co-authored-by: seonghun lee <[email protected]>
…ntent-Type parameter (#17456) 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.
…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]>
…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]>
…e next Content-Type parameter (netty#17436) Auto-port of netty#17386 to 4.1 Cherry-picked commit: 086310c --- ### Motivation: RFC 9110 section 5.6.6 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 ; action="foo"`, `HttpUtil.getCharset()` extracted `utf-8 ` (with the trailing space), failed to resolve the charset, and silently fell back to the default charset — decoding the body with the wrong charset. The quoted form `charset="utf-8" ; ...` was broken the same way because the trailing space defeats the quote-stripping. ### Modification: Trim the extracted charset sequence in `HttpUtil.getCharset()` before stripping quotes and resolving the `Charset`. The raw-sequence API `getCharsetAsSequence` is deliberately left unchanged (its tests pin the raw behavior). ### Result: Content-Type headers with optional whitespace before the next parameter now resolve to the correct charset instead of the default. Two regression tests added (fail on `4.2`, pass with the fix); `HttpUtilTest` passes 150/150. Fixes netty#17384. Co-authored-by: seonghun lee <[email protected]>
…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]>
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
HttpUtil.getCharset() falls back to the default charset when whitespace precedes the next Content-Type parameter
There was an error while loading. Please reload this page.