From 71b338ce17036bcb448c6c73e9a35b4971254733 Mon Sep 17 00:00:00 2001 From: cdn Date: Fri, 24 Mar 2017 14:07:43 +0900 Subject: [PATCH] Non-latin character broken on HttpHeader by HttpObjectDecoder. Motivation: Currently netty is receiving HTTP request by ByteBuf and store it as "CharSequence" on HttpObjectDecoder. During this operation, all character on ByteBuf is moving to char[] without breaking encoding. But in process() function, type casting from byte to char does not consider msb (sign-bit). So the value over 127 can be casted wrong value. (ex : 0xec in byte -> 0xffec in char). This is type casting bug. Modification: Fix type casting Result: Non-latin characters work. --- .../java/io/netty/handler/codec/http/HttpObjectDecoder.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java index 33ab2afc27..e2c657b0c3 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/HttpObjectDecoder.java @@ -805,7 +805,7 @@ public abstract class HttpObjectDecoder extends ByteToMessageDecoder { @Override public boolean process(byte value) throws Exception { - char nextByte = (char) value; + char nextByte = (char) (value & 0xFF); if (nextByte == HttpConstants.CR) { return true; }