diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java index 13b3391ff3..e1cb2df15b 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestDecoder.java @@ -780,7 +780,8 @@ public class HttpPostRequestDecoder { Attribute nameAttribute = currentFieldAttributes.get(HttpPostBodyUtil.NAME); if (currentAttribute == null) { try { - currentAttribute = factory.createAttribute(request, nameAttribute.getValue()); + currentAttribute = factory.createAttribute(request, + decodeAttribute(nameAttribute.getValue(), charset)); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); } catch (IllegalArgumentException e) { @@ -954,7 +955,8 @@ public class HttpPostRequestDecoder { String[] values = StringUtil.split(contents[i], '='); Attribute attribute; try { - attribute = factory.createAttribute(request, values[0].trim(), + attribute = factory.createAttribute(request, + decodeAttribute(values[0].trim(), charset), decodeAttribute(cleanString(values[1]), charset)); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); @@ -1014,7 +1016,8 @@ public class HttpPostRequestDecoder { } else { Attribute attribute; try { - attribute = factory.createAttribute(request, contents[0].trim(), + attribute = factory.createAttribute(request, + decodeAttribute(contents[0].trim(), charset), decodeAttribute(cleanString(contents[i]), charset)); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); @@ -1115,8 +1118,10 @@ public class HttpPostRequestDecoder { size = 0; } try { - currentFileUpload = factory.createFileUpload(request, nameAttribute.getValue(), - filenameAttribute.getValue(), contentTypeAttribute.getValue(), mechanism.value(), localCharset, + currentFileUpload = factory.createFileUpload(request, + decodeAttribute(nameAttribute.getValue(), charset), + decodeAttribute(filenameAttribute.getValue(), charset), + contentTypeAttribute.getValue(), mechanism.value(), localCharset, size); } catch (NullPointerException e) { throw new ErrorDataDecoderException(e); diff --git a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java index 1095acf3fe..7aa2197784 100644 --- a/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java +++ b/codec-http/src/main/java/io/netty/handler/codec/http/multipart/HttpPostRequestEncoder.java @@ -486,7 +486,9 @@ public class HttpPostRequestEncoder implements ChunkedMessageInput Charset localcharset = attribute.getCharset(); if (localcharset != null) { // Content-Type: charset=charset - internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + HttpHeaders.Values.CHARSET + '=' + internal.addValue(HttpHeaders.Names.CONTENT_TYPE + ": " + + HttpPostBodyUtil.DEFAULT_TEXT_CONTENT_TYPE + "; " + + HttpHeaders.Values.CHARSET + '=' + localcharset + "\r\n"); } // CRLF between body header and data