netty/netty

JSON in POST request treated as body attribute in HttpPostStandardRequestDecoder

Closed this issue · 0 comments

Expected behavior

JSON in POST request shouldn't be counted as body attribute in HttpPostStandardRequestDecoder, as in releases <4.1.108-Final (checked on 4.1.107.Final and 4.1.106.Final)

Actual behavior

JSON in POST request is treated as body attribute in HttpPostStandardRequestDecoder, and an attribute is created with key equal to JSON and empty value

Steps to reproduce

Send a POST request to netty >=4.1.108-Final, decode the request using HttpPostRequestDecoder and check .getBodyHttpDatas() The resulting list will contain Attribute HttpData where the key is a JSON sent by a client, and value is empty

Minimal yet complete reproducer code (or URL to code)

public class NettyReproduction {
    public static void main(String[] args) {
        FullHttpRequest request = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, HttpMethod.POST, "/netty/reproduction",
            Unpooled.wrappedBuffer("""
                {
                    "netty": "reproduction"
                }
                """.getBytes(StandardCharsets.UTF_8)));
        var decoder = new HttpPostRequestDecoder(request);
        var result = decoder.getBodyHttpDatas();
        System.out.println(result); 
    }
}

results in:
[Mixed: { "netty": "reproduction"}=] on 4.1.109.Final and 4.1.108.Final

but results in:
[] on 4.1.107.Final and 4.1.106.Final

Netty version

as above

JVM version (e.g. java -version)

Java 21

OS version (e.g. uname -a)

Windows 10,
and @Rufusmen reproduced on Linux (Ubuntu 22.04.4 LTS x86_64)

We suspect that the reason for such change is this PR: #13908 , thus we are wondering if such behaviour is desired, if the decoder decodes something different than x-www-form-urlencoded