mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Do not attempt to decode wildcard content-types as form-data
Prior to this commit, the `DefaultServerWebExchange` would attempt to decode request bodies as form-data or multipart of the request content-type was compatible with the expected media types. If requests are sent with an invalid wildcard content-type such as "*/*" or "multipart/*", we should not attempt to decode here. Fixes gh-34660
This commit is contained in:
+3
-3
@@ -149,11 +149,11 @@ public class DefaultServerWebExchange implements ServerWebExchange {
|
||||
ServerCodecConfigurer configurer, String logPrefix) {
|
||||
|
||||
MediaType contentType = getContentType(request);
|
||||
if (contentType == null || !contentType.isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED)) {
|
||||
if (contentType == null || !contentType.isConcrete() || !contentType.isCompatibleWith(MediaType.APPLICATION_FORM_URLENCODED)) {
|
||||
return EMPTY_FORM_DATA;
|
||||
}
|
||||
|
||||
HttpMessageReader<MultiValueMap<String, String>> reader = getReader(configurer, MediaType.APPLICATION_FORM_URLENCODED, FORM_DATA_TYPE);
|
||||
HttpMessageReader<MultiValueMap<String, String>> reader = getReader(configurer, contentType, FORM_DATA_TYPE);
|
||||
if (reader == null) {
|
||||
return Mono.error(new IllegalStateException("No HttpMessageReader for " + contentType));
|
||||
}
|
||||
@@ -167,7 +167,7 @@ public class DefaultServerWebExchange implements ServerWebExchange {
|
||||
private Mono<MultiValueMap<String, Part>> initMultipartData(ServerCodecConfigurer configurer, String logPrefix) {
|
||||
|
||||
MediaType contentType = getContentType(this.request);
|
||||
if (contentType == null || !contentType.getType().equalsIgnoreCase("multipart")) {
|
||||
if (contentType == null || !contentType.isConcrete() || !contentType.getType().equalsIgnoreCase("multipart")) {
|
||||
return EMPTY_MULTIPART_DATA;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user