@@ -143,7 +143,7 @@ private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValu
143
143
StompCommand stompCommand = StompCommand .valueOf (command );
144
144
headerAccessor = StompHeaderAccessor .create (stompCommand );
145
145
initHeaders (headerAccessor );
146
- readHeaders (byteBuffer , headerAccessor );
146
+ readHeaders (stompCommand , byteBuffer , headerAccessor );
147
147
payload = readPayload (byteBuffer , headerAccessor );
148
148
}
149
149
if (payload != null ) {
@@ -215,7 +215,9 @@ private String readCommand(ByteBuffer byteBuffer) {
215
215
return StreamUtils .copyToString (command , StandardCharsets .UTF_8 );
216
216
}
217
217
218
- private void readHeaders (ByteBuffer byteBuffer , StompHeaderAccessor headerAccessor ) {
218
+ private void readHeaders (StompCommand stompCommand , ByteBuffer byteBuffer , StompHeaderAccessor headerAccessor ) {
219
+ boolean shouldUnescape = (stompCommand != StompCommand .CONNECT && stompCommand != StompCommand .STOMP
220
+ && stompCommand != StompCommand .CONNECTED );
219
221
while (true ) {
220
222
ByteArrayOutputStream headerStream = new ByteArrayOutputStream (256 );
221
223
boolean headerComplete = false ;
@@ -236,8 +238,8 @@ private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccess
236
238
}
237
239
}
238
240
else {
239
- String headerName = unescape (header .substring (0 , colonIndex ));
240
- String headerValue = unescape (header .substring (colonIndex + 1 ));
241
+ String headerName = shouldUnescape ? unescape (header .substring (0 , colonIndex )) : header . substring ( 0 , colonIndex );
242
+ String headerValue = shouldUnescape ? unescape (header .substring (colonIndex + 1 )) : header . substring ( colonIndex + 1 );
241
243
try {
242
244
headerAccessor .addNativeHeader (headerName , headerValue );
243
245
}
0 commit comments