|
|
|
@ -76,12 +76,12 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe |
|
|
|
implements HandlerMethodReturnValueHandler { |
|
|
|
implements HandlerMethodReturnValueHandler { |
|
|
|
|
|
|
|
|
|
|
|
/* Extensions associated with the built-in message converters */ |
|
|
|
/* Extensions associated with the built-in message converters */ |
|
|
|
private static final Set<String> WHITELISTED_EXTENSIONS = new HashSet<>(Arrays.asList( |
|
|
|
private static final Set<String> SAFE_EXTENSIONS = new HashSet<>(Arrays.asList( |
|
|
|
"txt", "text", "yml", "properties", "csv", |
|
|
|
"txt", "text", "yml", "properties", "csv", |
|
|
|
"json", "xml", "atom", "rss", |
|
|
|
"json", "xml", "atom", "rss", |
|
|
|
"png", "jpe", "jpeg", "jpg", "gif", "wbmp", "bmp")); |
|
|
|
"png", "jpe", "jpeg", "jpg", "gif", "wbmp", "bmp")); |
|
|
|
|
|
|
|
|
|
|
|
private static final Set<String> WHITELISTED_MEDIA_BASE_TYPES = new HashSet<>( |
|
|
|
private static final Set<String> SAFE_MEDIA_BASE_TYPES = new HashSet<>( |
|
|
|
Arrays.asList("audio", "image", "video")); |
|
|
|
Arrays.asList("audio", "image", "video")); |
|
|
|
|
|
|
|
|
|
|
|
private static final List<MediaType> ALL_APPLICATION_MEDIA_TYPES = |
|
|
|
private static final List<MediaType> ALL_APPLICATION_MEDIA_TYPES = |
|
|
|
@ -133,7 +133,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe |
|
|
|
|
|
|
|
|
|
|
|
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager()); |
|
|
|
this.contentNegotiationManager = (manager != null ? manager : new ContentNegotiationManager()); |
|
|
|
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions()); |
|
|
|
this.safeExtensions.addAll(this.contentNegotiationManager.getAllFileExtensions()); |
|
|
|
this.safeExtensions.addAll(WHITELISTED_EXTENSIONS); |
|
|
|
this.safeExtensions.addAll(SAFE_EXTENSIONS); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -406,8 +406,8 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Check if the path has a file extension and whether the extension is |
|
|
|
* Check if the path has a file extension and whether the extension is either |
|
|
|
* either {@link #WHITELISTED_EXTENSIONS whitelisted} or explicitly |
|
|
|
* on the list of {@link #SAFE_EXTENSIONS safe extensions} or explicitly |
|
|
|
* {@link ContentNegotiationManager#getAllFileExtensions() registered}. |
|
|
|
* {@link ContentNegotiationManager#getAllFileExtensions() registered}. |
|
|
|
* If not, and the status is in the 2xx range, a 'Content-Disposition' |
|
|
|
* If not, and the status is in the 2xx range, a 'Content-Disposition' |
|
|
|
* header with a safe attachment file name ("f.txt") is added to prevent |
|
|
|
* header with a safe attachment file name ("f.txt") is added to prevent |
|
|
|
@ -491,7 +491,7 @@ public abstract class AbstractMessageConverterMethodProcessor extends AbstractMe |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private boolean safeMediaType(MediaType mediaType) { |
|
|
|
private boolean safeMediaType(MediaType mediaType) { |
|
|
|
return (WHITELISTED_MEDIA_BASE_TYPES.contains(mediaType.getType()) || |
|
|
|
return (SAFE_MEDIA_BASE_TYPES.contains(mediaType.getType()) || |
|
|
|
mediaType.getSubtype().endsWith("+xml")); |
|
|
|
mediaType.getSubtype().endsWith("+xml")); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|