Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
private final Map<String, List<FileItem>> nameToItems = new LinkedHashMap<String, List<FileItem>>();
private final Set<String> fileParamNames = new HashSet<String>();

private final int PARTHEADERSIZEMAX = Integer.getInteger("jackrabbit-server-PartHeaderSizeMax", -1);

Check warning on line 48 in jackrabbit-jcr-server/src/main/java/org/apache/jackrabbit/server/util/HttpMultipartPost.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rename this field "PARTHEADERSIZEMAX" to match the regular expression '^[a-z][a-zA-Z0-9]*$'.

See more on https://sonarcloud.io/project/issues?id=apache_jackrabbit&issues=AZ69CPdE_9fPBXM2rUmI&open=AZ69CPdE_9fPBXM2rUmI&pullRequest=357

private boolean initialized;

Expand All @@ -69,6 +69,9 @@
ServletFileUpload upload = new ServletFileUpload(getFileItemFactory(tmpDir));
if (PARTHEADERSIZEMAX > 0) {
upload.setPartHeaderSizeMax(PARTHEADERSIZEMAX);
} else {
// override the default limit of 512 in commons-fileupload 1.6
upload.setPartHeaderSizeMax(4096);
}
// make sure the content disposition headers are read with the charset
// specified in the request content type (or UTF-8 if no charset is specified).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.*;


import javax.servlet.ServletInputStream;
import java.io.ByteArrayInputStream;
import java.io.IOException;
Expand Down Expand Up @@ -212,12 +211,13 @@ public void testMultipartPostWithShorterFilename() throws Exception {

@Test(expected=IOException.class)
public void testMultipartPostWithExtremelyLongFilename() throws Exception {
buildRequestWithFilenameOfVaryingLength(1000);
// tests against the new default value of 4096
buildRequestWithFilenameOfVaryingLength(5000);
File testTmpDir = tempFolder.newFolder("jackrabbit_long_filename");
RequestData requestData = new RequestData(mockRequest, testTmpDir);
try {
assertTrue(
requestData.getParameter("fileUpload").length() > 950);
requestData.getParameter("fileUpload").length() > 4900);
} finally {
requestData.dispose();
}
Expand All @@ -226,13 +226,13 @@ public void testMultipartPostWithExtremelyLongFilename() throws Exception {
@Test
public void testMultipartPostWithExtremelyLongFilenameNButHigherConfig() throws Exception {
try {
System.setProperty("jackrabbit-server-PartHeaderSizeMax", "2048");
buildRequestWithFilenameOfVaryingLength(1000);
System.setProperty("jackrabbit-server-PartHeaderSizeMax", "8192");
buildRequestWithFilenameOfVaryingLength(7500);
File testTmpDir = tempFolder.newFolder("jackrabbit_long_filename");
RequestData requestData = new RequestData(mockRequest, testTmpDir);
try {
assertTrue(
requestData.getParameter("fileUpload").length() > 950);
requestData.getParameter("fileUpload").length() > 7500);
} finally {
requestData.dispose();
}
Expand Down
Loading