Check STOMP headers against ending backslash

Issue: SPR-12418
This commit is contained in:
Sebastien Deleuze 2014-11-10 17:12:08 +01:00
parent 1988f8c75f
commit 18033486ae
2 changed files with 10 additions and 0 deletions

View File

@ -260,6 +260,9 @@ public class StompDecoder {
while (index >= 0) {
sb.append(inString.substring(pos, index));
if((index + 1) >= inString.length()) {
throw new StompConversionException("Illegal escape sequence at index " + index + ": " + inString);
}
Character c = inString.charAt(index + 1);
if (c == 'r') {
sb.append('\r');

View File

@ -185,6 +185,13 @@ public class BufferingStompDecoderTests {
assertEquals(0, messages.size());
}
@Test(expected = StompConversionException.class) // SPR-12418
public void endingBackslashHeaderValueCheck() throws InterruptedException {
BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
String payload = "SEND\na:alpha\\\n\nMessage body\0";
stompDecoder.decode(toByteBuffer(payload));
}
private ByteBuffer toByteBuffer(String chunk) {
return ByteBuffer.wrap(chunk.getBytes(Charset.forName("UTF-8")));