Merge remote-tracking branch 'origin/jetty-9.2.x'

This commit is contained in:
Greg Wilkins 2014-12-31 16:16:57 +01:00
commit 2e3c223917
5 changed files with 108 additions and 15 deletions

View File

@ -284,7 +284,7 @@ CYGWIN*) JETTY_STATE="`cygpath -w $JETTY_STATE`";;
esac
JETTY_ARGS=("$JETTY_ARGS" "jetty.state=$JETTY_STATE")
JETTY_ARGS=(${JETTY_ARGS[*]} "jetty.state=$JETTY_STATE")
##################################################
# Get the list of config.xml files from jetty.conf
@ -306,14 +306,14 @@ then
do
if [ -r "$XMLFILE" ] && [ -f "$XMLFILE" ]
then
JETTY_ARGS=("$JETTY_ARGS" "$XMLFILE")
JETTY_ARGS=(${JETTY_ARGS[*]} "$XMLFILE")
else
echo "** WARNING: Cannot read '$XMLFILE' specified in '$JETTY_CONF'"
fi
done
else
# assume it's a command line parameter (let start.jar deal with its validity)
JETTY_ARGS=("$JETTY_ARGS" "$CONF")
JETTY_ARGS=(${JETTY_ARGS[*]} "$CONF")
fi
done < "$JETTY_CONF"
fi
@ -350,7 +350,7 @@ then
CYGWIN*) JETTY_LOGS="`cygpath -w $JETTY_LOGS`";;
esac
JAVA_OPTIONS=("$JAVA_OPTIONS" "-Djetty.logs=$JETTY_LOGS")
JAVA_OPTIONS=(${JAVA_OPTIONS[*]} "-Djetty.logs=$JETTY_LOGS")
fi
#####################################################
@ -374,7 +374,7 @@ TMPDIR="`cygpath -w $TMPDIR`"
;;
esac
JAVA_OPTIONS=("$JAVA_OPTIONS" "-Djetty.home=$JETTY_HOME" "-Djetty.base=$JETTY_BASE" "-Djava.io.tmpdir=$TMPDIR")
JAVA_OPTIONS=(${JAVA_OPTIONS[*]} "-Djetty.home=$JETTY_HOME" "-Djetty.base=$JETTY_BASE" "-Djava.io.tmpdir=$TMPDIR")
#####################################################
# This is how the Jetty server will be started

View File

@ -271,7 +271,7 @@ public class MongoSessionManager extends NoSqlSessionManager
if (currentMaxIdle != null && getMaxInactiveInterval() > 0 && getMaxInactiveInterval() < currentMaxIdle)
sets.put(__MAX_IDLE, getMaxInactiveInterval());
if (currentExpiry != null && expiry > 0 && expiry != currentExpiry)
sets.put(__EXPIRY, currentExpiry);
sets.put(__EXPIRY, expiry);
}
}

View File

@ -246,14 +246,14 @@ public class TestNamingEntries
{
ScopeA scope = new ScopeA();
InitialContext icontext = new InitialContext();
Link link = new Link ("resourceA", "resourceB");
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "resourceA");
Link link = new Link ("linked-resourceA", "resourceB");
NamingEntry ne = NamingEntryUtil.lookupNamingEntry(null, "linked-resourceA");
assertNotNull(ne);
assertTrue(ne instanceof Link);
assertEquals(icontext.lookup("resourceA"), "resourceB");
assertEquals(icontext.lookup("linked-resourceA"), "resourceB");
link = new Link (scope, "jdbc/resourceX", "jdbc/resourceY");
ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/resourceX");
link = new Link (scope, "jdbc/linked-resourceX", "jdbc/linked-resourceY");
ne = NamingEntryUtil.lookupNamingEntry(scope, "jdbc/linked-resourceX");
assertNotNull(ne);
assertTrue(ne instanceof Link);
}

View File

@ -495,10 +495,8 @@ public class Request implements HttpServletRequest
}
catch (IOException | ServletException e)
{
if (LOG.isDebugEnabled())
LOG.warn(e);
else
LOG.warn(e.toString());
LOG.warn(e);
throw new RuntimeException(e);
}
}

View File

@ -276,6 +276,67 @@ public class RequestTest
// System.err.println(responses);
assertTrue(responses.startsWith("HTTP/1.1 200"));
}
@Test
public void testBadMultiPart() throws Exception
{
//a bad multipart where one of the fields has no name
final File testTmpDir = File.createTempFile("badmptest", null);
if (testTmpDir.exists())
testTmpDir.delete();
testTmpDir.mkdir();
testTmpDir.deleteOnExit();
assertTrue(testTmpDir.list().length == 0);
ContextHandler contextHandler = new ContextHandler();
contextHandler.setContextPath("/foo");
contextHandler.setResourceBase(".");
contextHandler.setHandler(new BadMultiPartRequestHandler(testTmpDir));
contextHandler.addEventListener(new Request.MultiPartCleanerListener()
{
@Override
public void requestDestroyed(ServletRequestEvent sre)
{
MultiPartInputStreamParser m = (MultiPartInputStreamParser)sre.getServletRequest().getAttribute(Request.__MULTIPART_INPUT_STREAM);
ContextHandler.Context c = (ContextHandler.Context)sre.getServletRequest().getAttribute(Request.__MULTIPART_CONTEXT);
assertNotNull (m);
assertNotNull (c);
assertTrue(c == sre.getServletContext());
super.requestDestroyed(sre);
String[] files = testTmpDir.list();
assertTrue(files.length == 0);
}
});
_server.stop();
_server.setHandler(contextHandler);
_server.start();
String multipart = "--AaB03x\r\n"+
"content-disposition: form-data; name=\"xxx\"\r\n"+
"\r\n"+
"Joe Blow\r\n"+
"--AaB03x\r\n"+
"content-disposition: form-data; filename=\"foo.upload\"\r\n"+
"Content-Type: text/plain;charset=ISO-8859-1\r\n"+
"\r\n"+
"000000000000000000000000000000000000000000000000000\r\n"+
"--AaB03x--\r\n";
String request="GET /foo/x.html HTTP/1.1\r\n"+
"Host: whatever\r\n"+
"Content-Type: multipart/form-data; boundary=\"AaB03x\"\r\n"+
"Content-Length: "+multipart.getBytes().length+"\r\n"+
"Connection: close\r\n"+
"\r\n"+
multipart;
String responses=_connector.getResponses(request);
//System.err.println(responses);
assertTrue(responses.startsWith("HTTP/1.1 500"));
}
@Test
public void testBadUtf8ParamExtraction() throws Exception
@ -1286,4 +1347,38 @@ public class RequestTest
}
}
}
private class BadMultiPartRequestHandler extends AbstractHandler
{
File tmpDir;
public BadMultiPartRequestHandler(File tmpDir)
{
this.tmpDir = tmpDir;
}
@Override
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
((Request)request).setHandled(true);
try
{
MultipartConfigElement mpce = new MultipartConfigElement(tmpDir.getAbsolutePath(),-1, -1, 2);
request.setAttribute(Request.__MULTIPART_CONFIG_ELEMENT, mpce);
//We should get an error when we getParams if there was a problem parsing the multipart
String field1 = request.getParameter("xxx");
//A 200 response is actually wrong here
}
catch (RuntimeException e)
{
response.sendError(500);
}
}
}
}