Skip to content

Commit

Permalink
Polishing contribution
Browse files Browse the repository at this point in the history
Closes gh-27722
  • Loading branch information
rstoyanchev committed Dec 13, 2021
1 parent 5d91560 commit 2db6795
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ private Message<byte[]> decodeMessage(ByteBuffer byteBuffer, @Nullable MultiValu
StompCommand stompCommand = StompCommand.valueOf(command);
headerAccessor = StompHeaderAccessor.create(stompCommand);
initHeaders(headerAccessor);
readHeaders(stompCommand, byteBuffer, headerAccessor);
readHeaders(byteBuffer, headerAccessor, stompCommand);
payload = readPayload(byteBuffer, headerAccessor);
}
if (payload != null) {
Expand Down Expand Up @@ -215,9 +215,12 @@ private String readCommand(ByteBuffer byteBuffer) {
return StreamUtils.copyToString(command, StandardCharsets.UTF_8);
}

private void readHeaders(StompCommand stompCommand, ByteBuffer byteBuffer, StompHeaderAccessor headerAccessor) {
boolean shouldUnescape = (stompCommand != StompCommand.CONNECT && stompCommand != StompCommand.STOMP
&& stompCommand != StompCommand.CONNECTED);
private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccessor, StompCommand command) {

boolean shouldUnescape = (command != StompCommand.CONNECT &&
command != StompCommand.CONNECTED &&
command != StompCommand.STOMP);

while (true) {
ByteArrayOutputStream headerStream = new ByteArrayOutputStream(256);
boolean headerComplete = false;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2020 the original author or authors.
* Copyright 2002-2021 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -159,7 +159,7 @@ public void decodeFrameWithEscapedHeaders() {
assertThat(headers.getFirstNativeHeader("a:\r\n\\b")).isEqualTo("alpha:bravo\r\n\\");
}

@Test
@Test // gh-27722
public void decodeFrameWithHeaderWithBackslashValue() {
String accept = "accept-version:1.1\n";
String keyAndValueWithBackslash = "key:\\value\n";
Expand Down

0 comments on commit 2db6795

Please sign in to comment.