diff --git a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java index b8c5e6cbf727..ff179a87815d 100644 --- a/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java +++ b/spring-messaging/src/main/java/org/springframework/messaging/simp/stomp/StompDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2020 the original author or authors. + * Copyright 2002-2022 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. @@ -264,9 +264,12 @@ private void readHeaders(ByteBuffer byteBuffer, StompHeaderAccessor headerAccess * "Value Encoding". */ private String unescape(String inString) { + int index = inString.indexOf('\\'); + if (index == -1) { + return inString; + } StringBuilder sb = new StringBuilder(inString.length()); int pos = 0; // position in the old string - int index = inString.indexOf('\\'); while (index >= 0) { sb.append(inString, pos, index);