Susimail, Console, Jetty:

- Adjust multipart size limits
- Better handling of errors when multipart limits are exceeded
- Fix multipart config for /configplugins
- Test for total size limit in susimail
This commit is contained in:
zzz
2017-12-05 21:46:11 +00:00
parent d4bafaeee8
commit f5dffb0726
7 changed files with 86 additions and 19 deletions

View File

@@ -101,6 +101,7 @@ public class RequestWrapper {
/**
* @return List of request parameter names
* @throws IllegalStateException if the request is too large
*/
public Enumeration<String> getParameterNames() {
if (isMultiPartRequest) {
@@ -117,6 +118,7 @@ public class RequestWrapper {
log(se);
} catch (IllegalStateException ise) {
log(ise);
throw ise;
}
}
return cachedParameterNames.keys();
@@ -139,6 +141,9 @@ public class RequestWrapper {
return httpRequest.getContentType();
}
/**
* @throws IllegalStateException if the request is too large
*/
public String getContentType( String partName )
{
String result = null;
@@ -153,6 +158,7 @@ public class RequestWrapper {
log(se);
} catch (IllegalStateException ise) {
log(ise);
throw ise;
}
}
return result;
@@ -162,6 +168,9 @@ public class RequestWrapper {
return httpRequest.getAttribute( string );
}
/**
* @throws IllegalStateException if the request is too large
*/
public String getParameter( String name, String defaultValue )
{
String result = defaultValue;
@@ -192,6 +201,7 @@ public class RequestWrapper {
log(se);
} catch (IllegalStateException ise) {
log(ise);
throw ise;
} finally {
if (in != null) try { in.close(); } catch (IOException ioe) {}
}
@@ -204,6 +214,9 @@ public class RequestWrapper {
return result;
}
/**
* @throws IllegalStateException if the request is too large
*/
public String getFilename(String partName )
{
String result = null;
@@ -218,11 +231,15 @@ public class RequestWrapper {
log(se);
} catch (IllegalStateException ise) {
log(ise);
throw ise;
}
}
return result;
}
/**
* @throws IllegalStateException if the request is too large
*/
public InputStream getInputStream(String partName )
{
InputStream result = null;
@@ -237,6 +254,7 @@ public class RequestWrapper {
log(se);
} catch (IllegalStateException ise) {
log(ise);
throw ise;
}
}
return result;

View File

@@ -9,6 +9,7 @@ import javax.servlet.ServletException;
import javax.servlet.ServletRequest;
import javax.servlet.ServletResponse;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* @since 0.9.14
@@ -25,6 +26,14 @@ public class XSSFilter implements Filter {
@Override
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
chain.doFilter(new XSSRequestWrapper((HttpServletRequest) request), response);
try {
chain.doFilter(new XSSRequestWrapper((HttpServletRequest) request), response);
} catch (IllegalStateException ise) {
// Multipart form error, probably file too big
// We need to send the error quickly, if we just throw a ServletException,
// the data keeps coming and the connection gets reset.
// This way we at least get the error to the browser.
((HttpServletResponse)response).sendError(413, ise.getMessage());
}
}
}