[#1313] Fix for Multipart name and value that should not be encoded, except charset if specified
This commit is contained in:
parent
60695012ab
commit
1615009f5a
@ -784,7 +784,7 @@ public class HttpPostRequestDecoder {
|
|||||||
if (currentAttribute == null) {
|
if (currentAttribute == null) {
|
||||||
try {
|
try {
|
||||||
currentAttribute = factory.createAttribute(request,
|
currentAttribute = factory.createAttribute(request,
|
||||||
decodeAttribute(cleanString(nameAttribute.getValue()), charset));
|
cleanString(nameAttribute.getValue()));
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -960,8 +960,7 @@ public class HttpPostRequestDecoder {
|
|||||||
Attribute attribute;
|
Attribute attribute;
|
||||||
try {
|
try {
|
||||||
attribute = factory.createAttribute(request,
|
attribute = factory.createAttribute(request,
|
||||||
decodeAttribute(cleanString(values[0].trim()), charset),
|
cleanString(values[0]), values[1]);
|
||||||
decodeAttribute(cleanString(values[1]), charset));
|
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -1032,8 +1031,7 @@ public class HttpPostRequestDecoder {
|
|||||||
Attribute attribute;
|
Attribute attribute;
|
||||||
try {
|
try {
|
||||||
attribute = factory.createAttribute(request,
|
attribute = factory.createAttribute(request,
|
||||||
decodeAttribute(cleanString(contents[0].trim()), charset),
|
cleanString(contents[0]), contents[i]);
|
||||||
decodeAttribute(cleanString(contents[i]), charset));
|
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
throw new ErrorDataDecoderException(e);
|
throw new ErrorDataDecoderException(e);
|
||||||
} catch (IllegalArgumentException e) {
|
} catch (IllegalArgumentException e) {
|
||||||
@ -1147,8 +1145,7 @@ public class HttpPostRequestDecoder {
|
|||||||
try {
|
try {
|
||||||
currentFileUpload = factory.createFileUpload(
|
currentFileUpload = factory.createFileUpload(
|
||||||
request,
|
request,
|
||||||
decodeAttribute(cleanString(nameAttribute.getValue()), charset),
|
cleanString(nameAttribute.getValue()), cleanString(filenameAttribute.getValue()),
|
||||||
decodeAttribute(cleanString(filenameAttribute.getValue()), charset),
|
|
||||||
contentTypeAttribute.getValue(), mechanism.value(),
|
contentTypeAttribute.getValue(), mechanism.value(),
|
||||||
localCharset, size);
|
localCharset, size);
|
||||||
} catch (NullPointerException e) {
|
} catch (NullPointerException e) {
|
||||||
|
@ -457,8 +457,7 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
|||||||
Attribute attribute = (Attribute) data;
|
Attribute attribute = (Attribute) data;
|
||||||
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
||||||
HttpPostBodyUtil.FORM_DATA + "; " +
|
HttpPostBodyUtil.FORM_DATA + "; " +
|
||||||
HttpPostBodyUtil.NAME + "=\"" +
|
HttpPostBodyUtil.NAME + "=\"" + attribute.getName() + "\"\r\n");
|
||||||
encodeAttribute(attribute.getName(), charset) + "\"\r\n");
|
|
||||||
Charset localcharset = attribute.getCharset();
|
Charset localcharset = attribute.getCharset();
|
||||||
if (localcharset != null) {
|
if (localcharset != null) {
|
||||||
// Content-Type: charset=charset
|
// Content-Type: charset=charset
|
||||||
@ -529,15 +528,14 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
|||||||
globalBodySize -= pastAttribute.size();
|
globalBodySize -= pastAttribute.size();
|
||||||
String replacement = HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
String replacement = HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
||||||
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
|
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
|
||||||
encodeAttribute(fileUpload.getName(), charset) + "\"\r\n";
|
fileUpload.getName() + "\"\r\n";
|
||||||
replacement += HttpHeaders.Names.CONTENT_TYPE + ": " +
|
replacement += HttpHeaders.Names.CONTENT_TYPE + ": " +
|
||||||
HttpPostBodyUtil.MULTIPART_MIXED + "; " + HttpHeaders.Values.BOUNDARY +
|
HttpPostBodyUtil.MULTIPART_MIXED + "; " + HttpHeaders.Values.BOUNDARY +
|
||||||
'=' + multipartMixedBoundary + "\r\n\r\n";
|
'=' + multipartMixedBoundary + "\r\n\r\n";
|
||||||
replacement += "--" + multipartMixedBoundary + "\r\n";
|
replacement += "--" + multipartMixedBoundary + "\r\n";
|
||||||
replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
replacement += HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
||||||
HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
|
HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
|
||||||
encodeAttribute(fileUpload.getFilename(), charset) +
|
fileUpload.getFilename() + "\"\r\n";
|
||||||
"\"\r\n";
|
|
||||||
pastAttribute.setValue(replacement, 1);
|
pastAttribute.setValue(replacement, 1);
|
||||||
// update past size
|
// update past size
|
||||||
globalBodySize += pastAttribute.size();
|
globalBodySize += pastAttribute.size();
|
||||||
@ -563,16 +561,16 @@ public class HttpPostRequestEncoder implements ChunkedInput {
|
|||||||
// Content-Disposition: file; filename="file1.txt"
|
// Content-Disposition: file; filename="file1.txt"
|
||||||
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
||||||
HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
|
HttpPostBodyUtil.FILE + "; " + HttpPostBodyUtil.FILENAME + "=\"" +
|
||||||
encodeAttribute(fileUpload.getFilename(), charset) +
|
fileUpload.getFilename() +
|
||||||
"\"\r\n");
|
"\"\r\n");
|
||||||
} else {
|
} else {
|
||||||
internal.addValue("--" + multipartDataBoundary + "\r\n");
|
internal.addValue("--" + multipartDataBoundary + "\r\n");
|
||||||
// Content-Disposition: form-data; name="files"; filename="file1.txt"
|
// Content-Disposition: form-data; name="files"; filename="file1.txt"
|
||||||
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
internal.addValue(HttpPostBodyUtil.CONTENT_DISPOSITION + ": " +
|
||||||
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
|
HttpPostBodyUtil.FORM_DATA + "; " + HttpPostBodyUtil.NAME + "=\"" +
|
||||||
encodeAttribute(fileUpload.getName(), charset) + "\"; " +
|
fileUpload.getName() + "\"; " +
|
||||||
HttpPostBodyUtil.FILENAME + "=\"" +
|
HttpPostBodyUtil.FILENAME + "=\"" +
|
||||||
encodeAttribute(fileUpload.getFilename(), charset) +
|
fileUpload.getFilename() +
|
||||||
"\"\r\n");
|
"\"\r\n");
|
||||||
}
|
}
|
||||||
// Content-Type: image/gif
|
// Content-Type: image/gif
|
||||||
|
Loading…
Reference in New Issue
Block a user