|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2015 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
|
25 | 25 |
|
26 | 26 | import org.springframework.messaging.Message;
|
27 | 27 |
|
28 |
| -import static org.junit.Assert.*; |
| 28 | +import static org.junit.Assert.assertEquals; |
| 29 | +import static org.junit.Assert.assertNull; |
| 30 | +import static org.junit.Assert.fail; |
29 | 31 |
|
30 | 32 | /**
|
31 | 33 | * Unit tests for {@link BufferingStompDecoder}.
|
@@ -177,13 +179,30 @@ public void incompleteCommand() {
|
177 | 179 | assertEquals(0, messages.size());
|
178 | 180 | }
|
179 | 181 |
|
180 |
| - @Test(expected = StompConversionException.class) // SPR-12418 |
181 |
| - public void endingBackslashHeaderValueCheck() { |
| 182 | + // SPR-13416 |
| 183 | + |
| 184 | + @Test |
| 185 | + public void incompleteHeaderWithPartialEscapeSequence() throws Exception { |
182 | 186 | BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128);
|
183 |
| - String payload = "SEND\na:alpha\\\n\nMessage body\0"; |
| 187 | + String chunk = "SEND\na:long\\"; |
| 188 | + |
| 189 | + List<Message<byte[]>> messages = stompDecoder.decode(toByteBuffer(chunk)); |
| 190 | + assertEquals(0, messages.size()); |
| 191 | + } |
| 192 | + |
| 193 | + @Test(expected = StompConversionException.class) |
| 194 | + public void invalidEscapeSequence() { |
| 195 | + BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128); |
| 196 | + String payload = "SEND\na:alpha\\x\\n\nMessage body\0"; |
184 | 197 | stompDecoder.decode(toByteBuffer(payload));
|
185 | 198 | }
|
186 | 199 |
|
| 200 | + @Test(expected = StompConversionException.class) |
| 201 | + public void invalidEscapeSequenceWithSingleSlashAtEndOfHeaderValue() { |
| 202 | + BufferingStompDecoder stompDecoder = new BufferingStompDecoder(STOMP_DECODER, 128); |
| 203 | + String payload = "SEND\na:alpha\\\n\nMessage body\0"; |
| 204 | + stompDecoder.decode(toByteBuffer(payload)); |
| 205 | + } |
187 | 206 |
|
188 | 207 | private ByteBuffer toByteBuffer(String chunk) {
|
189 | 208 | return ByteBuffer.wrap(chunk.getBytes(Charset.forName("UTF-8")));
|
|
0 commit comments