Support quoted boundary in DefaultPartHttpMessageReader
This commit makes sure that quoted boundary parameters are supported in the DefaultPartHttpMessageReader. Closes gh-26616
This commit is contained in:
parent
4af7a6863b
commit
1a79c54b01
|
|
@ -227,6 +227,10 @@ public class DefaultPartHttpMessageReader extends LoggingCodecSupport implements
|
|||
if (contentType != null) {
|
||||
String boundary = contentType.getParameter("boundary");
|
||||
if (boundary != null) {
|
||||
int len = boundary.length();
|
||||
if (len > 2 && boundary.charAt(0) == '"' && boundary.charAt(len - 1) == '"') {
|
||||
boundary = boundary.substring(1, len - 1);
|
||||
}
|
||||
return boundary.getBytes(StandardCharsets.ISO_8859_1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -233,6 +233,25 @@ public class DefaultPartHttpMessageReaderTests {
|
|||
latch.await();
|
||||
}
|
||||
|
||||
@ParameterizedDefaultPartHttpMessageReaderTest
|
||||
public void quotedBoundary(String displayName, DefaultPartHttpMessageReader reader) throws InterruptedException {
|
||||
MockServerHttpRequest request = createRequest(
|
||||
new ClassPathResource("simple.multipart", getClass()), "\"simple-boundary\"");
|
||||
|
||||
Flux<Part> result = reader.read(forClass(Part.class), request, emptyMap());
|
||||
|
||||
CountDownLatch latch = new CountDownLatch(2);
|
||||
StepVerifier.create(result)
|
||||
.consumeNextWith(part -> testPart(part, null,
|
||||
"This is implicitly typed plain ASCII text.\r\nIt does NOT end with a linebreak.", latch)).as("Part 1")
|
||||
.consumeNextWith(part -> testPart(part, null,
|
||||
"This is explicitly typed plain ASCII text.\r\nIt DOES end with a linebreak.\r\n", latch)).as("Part 2")
|
||||
.verifyComplete();
|
||||
|
||||
latch.await();
|
||||
}
|
||||
|
||||
|
||||
private void testBrowser(DefaultPartHttpMessageReader reader, Resource resource, String boundary)
|
||||
throws InterruptedException {
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue