Expand range of whitelisted extensions by media type
This commit expands the range of whitelisted extensions by checking if an extension can be resolved to image/*, audio/*, video/*, as well as any content type that ends with +xml. Issue: SPR-13643
This commit is contained in:
@@ -47,7 +47,17 @@ public abstract class AbstractMappingContentNegotiationStrategy extends MappingM
|
||||
|
||||
@Override
|
||||
public List<MediaType> resolveMediaTypes(NativeWebRequest webRequest) throws HttpMediaTypeNotAcceptableException {
|
||||
String key = getMediaTypeKey(webRequest);
|
||||
return resolveMediaTypeKey(webRequest, getMediaTypeKey(webRequest));
|
||||
}
|
||||
|
||||
/**
|
||||
* An alternative to {@link #resolveMediaTypes(NativeWebRequest)} that accepts
|
||||
* an already extracted key.
|
||||
* @since 3.2.16
|
||||
*/
|
||||
public List<MediaType> resolveMediaTypeKey(NativeWebRequest webRequest, String key)
|
||||
throws HttpMediaTypeNotAcceptableException {
|
||||
|
||||
if (StringUtils.hasText(key)) {
|
||||
MediaType mediaType = lookupMediaType(key);
|
||||
if (mediaType != null) {
|
||||
|
||||
@@ -99,6 +99,14 @@ public class ContentNegotiationManager implements ContentNegotiationStrategy, Me
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Return the configured content negotiation strategies.
|
||||
* @since 3.2.16
|
||||
*/
|
||||
public List<ContentNegotiationStrategy> getStrategies() {
|
||||
return this.contentNegotiationStrategies;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add MediaTypeFileExtensionResolver instances.
|
||||
* <p>Note that some {@link ContentNegotiationStrategy} implementations also
|
||||
|
||||
Reference in New Issue
Block a user