mirror of
https://github.com/spring-projects/spring-framework.git
synced 2026-10-02 20:49:02 +00:00
Detect all common size exceptions from Tomcat and Commons FileUpload 2.x
Closes gh-36317
This commit is contained in:
+4
-3
@@ -117,10 +117,11 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
// MaxUploadSizeExceededException ?
|
||||
Throwable cause = ex;
|
||||
do {
|
||||
String msg = cause.getMessage();
|
||||
String msg = cause.toString();
|
||||
if (msg != null) {
|
||||
msg = msg.toLowerCase(Locale.ROOT);
|
||||
if ((msg.contains("exceed") && (msg.contains("size") || msg.contains("length"))) ||
|
||||
if (((msg.contains("exceed") || msg.contains("limit")) &&
|
||||
(msg.contains("size") || msg.contains("length") || msg.contains("count"))) ||
|
||||
(msg.contains("request") && (msg.contains("big") || msg.contains("large")))) {
|
||||
throw new MaxUploadSizeExceededException(-1, ex);
|
||||
}
|
||||
@@ -266,7 +267,7 @@ public class StandardMultipartHttpServletRequest extends AbstractMultipartHttpSe
|
||||
if (dest.isAbsolute() && !dest.exists()) {
|
||||
// Servlet Part.write is not guaranteed to support absolute file paths:
|
||||
// may translate the given path to a relative location within a temp dir
|
||||
// (for example, on Jetty whereas Tomcat detects absolute paths).
|
||||
// (for example, on Jetty whereas Tomcat and Undertow detect absolute paths).
|
||||
// At least we offloaded the file from memory storage; it'll get deleted
|
||||
// from the temp dir eventually in any case. And for our user's purposes,
|
||||
// we can manually copy it to the requested location as a fallback.
|
||||
|
||||
Reference in New Issue
Block a user