Merge branch '5.1.x'
This commit is contained in:
commit
e89fd5c3be
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright 2002-2018 the original author or authors.
|
* Copyright 2002-2019 the original author or authors.
|
||||||
*
|
*
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
* you may not use this file except in compliance with the License.
|
* you may not use this file except in compliance with the License.
|
||||||
|
|
@ -331,6 +331,7 @@ public final class ContentDisposition {
|
||||||
do {
|
do {
|
||||||
int nextIndex = index + 1;
|
int nextIndex = index + 1;
|
||||||
boolean quoted = false;
|
boolean quoted = false;
|
||||||
|
boolean escaped = false;
|
||||||
while (nextIndex < headerValue.length()) {
|
while (nextIndex < headerValue.length()) {
|
||||||
char ch = headerValue.charAt(nextIndex);
|
char ch = headerValue.charAt(nextIndex);
|
||||||
if (ch == ';') {
|
if (ch == ';') {
|
||||||
|
|
@ -338,9 +339,10 @@ public final class ContentDisposition {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (ch == '"') {
|
else if (!escaped && ch == '"') {
|
||||||
quoted = !quoted;
|
quoted = !quoted;
|
||||||
}
|
}
|
||||||
|
escaped = (!escaped && ch == '\\');
|
||||||
nextIndex++;
|
nextIndex++;
|
||||||
}
|
}
|
||||||
String part = headerValue.substring(index + 1, nextIndex).trim();
|
String part = headerValue.substring(index + 1, nextIndex).trim();
|
||||||
|
|
|
||||||
|
|
@ -81,6 +81,14 @@ public class ContentDispositionTests {
|
||||||
.filename("中文.txt", StandardCharsets.UTF_8).build());
|
.filename("中文.txt", StandardCharsets.UTF_8).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test // gh-23077
|
||||||
|
public void parseWithEscapedQuote() {
|
||||||
|
ContentDisposition disposition = ContentDisposition.parse(
|
||||||
|
"form-data; name=\"file\"; filename=\"\\\"The Twilight Zone\\\".txt\"; size=123");
|
||||||
|
assertThat(ContentDisposition.builder("form-data").name("file")
|
||||||
|
.filename("\\\"The Twilight Zone\\\".txt").size(123L).build()).isEqualTo(disposition);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void parseEmpty() {
|
public void parseEmpty() {
|
||||||
assertThatIllegalArgumentException().isThrownBy(() ->
|
assertThatIllegalArgumentException().isThrownBy(() ->
|
||||||
|
|
|
||||||
|
|
@ -338,12 +338,10 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||||
sendErrorMessage(session, ex);
|
sendErrorMessage(session, ex);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Message<byte[]> message = getErrorHandler().handleClientMessageProcessingError(clientMessage, ex);
|
Message<byte[]> message = getErrorHandler().handleClientMessageProcessingError(clientMessage, ex);
|
||||||
if (message == null) {
|
if (message == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
StompHeaderAccessor accessor = MessageHeaderAccessor.getAccessor(message, StompHeaderAccessor.class);
|
||||||
Assert.state(accessor != null, "No StompHeaderAccessor");
|
Assert.state(accessor != null, "No StompHeaderAccessor");
|
||||||
sendToClient(session, accessor, message.getPayload());
|
sendToClient(session, accessor, message.getPayload());
|
||||||
|
|
@ -366,6 +364,14 @@ public class StompSubProtocolHandler implements SubProtocolHandler, ApplicationE
|
||||||
// Could be part of normal workflow (e.g. browser tab closed)
|
// Could be part of normal workflow (e.g. browser tab closed)
|
||||||
logger.debug("Failed to send STOMP ERROR to client", ex);
|
logger.debug("Failed to send STOMP ERROR to client", ex);
|
||||||
}
|
}
|
||||||
|
finally {
|
||||||
|
try {
|
||||||
|
session.close(CloseStatus.PROTOCOL_ERROR);
|
||||||
|
}
|
||||||
|
catch (IOException ex) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean detectImmutableMessageInterceptor(MessageChannel channel) {
|
private boolean detectImmutableMessageInterceptor(MessageChannel channel) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue