From c230afaed17fd1c3134f0d5448e0b5a8f5d69a0d Mon Sep 17 00:00:00 2001 From: Frederic Bregier Date: Sun, 5 May 2013 17:05:24 +0200 Subject: [PATCH] Fix for #1313 and #1332 Add TEXTPLAIN in HttpHeaders Remove all coding/decoding Attribute using URL scheme for name and attribute Add text/plain to contant-type --- .../http/multipart/HttpPostRequestDecoder.java | 15 ++++++++++----- .../http/multipart/HttpPostRequestEncoder.java | 4 +++- 2 files changed, 13 insertions(+), 6 deletions(-) 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