Skip to content

Commit 2db6795

Browse files
committed
Polishing contribution
Closes gh-27722
1 parent 5d91560 commit 2db6795

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValu
143143
StompCommand stompCommand = StompCommand.valueOf(command);
144144
headerAccessor = StompHeaderAccessor.create(stompCommand);
145145
initHeaders(headerAccessor);
146-
readHeaders(stompCommand, byteBuffer, headerAccessor);
146+
readHeaders(byteBuffer, headerAccessor, stompCommand);
147147
payload = readPayload(byteBuffer, headerAccessor);
148148
}
149149
if (payload != null) {
@@ -215,9 +215,12 @@ private String readCommand(ByteBuffer byteBuffer) {
215215
return StreamUtils.copyToString(command, StandardCharsets.UTF_8);
216216
}
217217

218-
private void readHeaders(StompCommand stompCommand, ByteBuffer byteBuffer, StompHeaderAccessor headerAccessor) {
219-
boolean shouldUnescape = (stompCommand != StompCommand.CONNECT && stompCommand != StompCommand.STOMP
220-
&& stompCommand != StompCommand.CONNECTED);
218+
private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccessor, StompCommand command) {
219+
220+
boolean shouldUnescape = (command != StompCommand.CONNECT &&
221+
command != StompCommand.CONNECTED &&
222+
command != StompCommand.STOMP);
223+
221224
while (true) {
222225
ByteArrayOutputStream headerStream = new ByteArrayOutputStream(256);
223226
boolean headerComplete = false;

spring-messaging/src/test/java/org/springframework/messaging/simp/stomp/StompDecoderTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2020 the original author or authors.
2+
* Copyright 2002-2021 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -159,7 +159,7 @@ public void decodeFrameWithEscapedHeaders() {
159159
assertThat(headers.getFirstNativeHeader("a:\r\n\\b")).isEqualTo("alpha:bravo\r\n\\");
160160
}
161161

162-
@Test
162+
@Test // gh-27722
163163
public void decodeFrameWithHeaderWithBackslashValue() {
164164
String accept = "accept-version:1.1\n";
165165
String keyAndValueWithBackslash = "key:\\value\n";

0 commit comments

Comments
 (0)