Fix a bug in HttpPostRequestDecoder where character encoding is ignored when reading a line

- Fixed #992 (backported from 3)
  - 9650cda163
  - b38bde2d2b
This commit is contained in:
Trustin Lee 2013-01-29 15:59:15 +09:00
parent a54217053f
commit c5ccaee506

View File

@ -1186,18 +1186,19 @@ public class HttpPostRequestDecoder {
private String readLineStandard() throws NotEnoughDataDecoderException {
int readerIndex = undecodedChunk.readerIndex();
try {
StringBuilder sb = new StringBuilder(64);
ByteBuf line = buffer(64);
while (undecodedChunk.readable()) {
byte nextByte = undecodedChunk.readByte();
if (nextByte == HttpConstants.CR) {
nextByte = undecodedChunk.readByte();
if (nextByte == HttpConstants.LF) {
return sb.toString();
return line.toString(charset);
}
} else if (nextByte == HttpConstants.LF) {
return sb.toString();
return line.toString(charset);
} else {
sb.append((char) nextByte);
line.writeByte(nextByte);
}
}
} catch (IndexOutOfBoundsException e) {
@ -1225,7 +1226,8 @@ public class HttpPostRequestDecoder {
}
int readerIndex = undecodedChunk.readerIndex();
try {
StringBuilder sb = new StringBuilder(64);
ByteBuf line = buffer(64);
while (sao.pos < sao.limit) {
byte nextByte = sao.bytes[sao.pos++];
if (nextByte == HttpConstants.CR) {
@ -1233,16 +1235,16 @@ public class HttpPostRequestDecoder {
nextByte = sao.bytes[sao.pos++];
if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
return line.toString(charset);
}
} else {
sb.append((char) nextByte);
line.writeByte(nextByte);
}
} else if (nextByte == HttpConstants.LF) {
sao.setReadPosition(0);
return sb.toString();
return line.toString(charset);
} else {
sb.append((char) nextByte);
line.writeByte(nextByte);
}
}
} catch (IndexOutOfBoundsException e) {