435653 encode async dispatched requestURI

This commit is contained in:
Greg Wilkins 2014-07-19 18:55:02 +10:00
parent b38a978eac
commit c72649e150
2 changed files with 11 additions and 4 deletions

View File

@ -18,6 +18,7 @@
package org.eclipse.jetty.server; package org.eclipse.jetty.server;
import java.awt.geom.PathIterator;
import java.io.IOException; import java.io.IOException;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.net.InetAddress; import java.net.InetAddress;
@ -513,16 +514,15 @@ public class Server extends HandlerWrapper implements Attributes
final Request baseRequest=connection.getRequest(); final Request baseRequest=connection.getRequest();
final String path=event.getPath(); final String path=event.getPath();
if (path!=null) if (path!=null)
{ {
// this is a dispatch with a path // this is a dispatch with a path
ServletContext context=event.getServletContext(); ServletContext context=event.getServletContext();
HttpURI uri = new HttpURI(URIUtil.encodePath(context==null?path:URIUtil.addPaths(context.getContextPath(),path))); HttpURI uri = new HttpURI(URIUtil.addPaths(context==null?null:context.getContextPath(), path));
baseRequest.setUri(uri); baseRequest.setUri(uri);
baseRequest.setRequestURI(null); baseRequest.setRequestURI(null);
baseRequest.setPathInfo(uri.getDecodedPath()); baseRequest.setPathInfo(uri.getDecodedPath());
if (uri.getQuery()!=null) if (uri.getQuery()!=null)
baseRequest.mergeQueryParameters(uri.getQuery(), true); //we have to assume dispatch path and query are UTF8 baseRequest.mergeQueryParameters(uri.getQuery(), true); //we have to assume dispatch path and query are UTF8
} }

View File

@ -51,6 +51,7 @@ import org.eclipse.jetty.server.ServerConnector;
import org.eclipse.jetty.server.handler.RequestLogHandler; import org.eclipse.jetty.server.handler.RequestLogHandler;
import org.eclipse.jetty.toolchain.test.AdvancedRunner; import org.eclipse.jetty.toolchain.test.AdvancedRunner;
import org.eclipse.jetty.util.IO; import org.eclipse.jetty.util.IO;
import org.eclipse.jetty.util.URIUtil;
import org.eclipse.jetty.util.component.AbstractLifeCycle; import org.eclipse.jetty.util.component.AbstractLifeCycle;
import org.hamcrest.Matchers; import org.hamcrest.Matchers;
import org.junit.After; import org.junit.After;
@ -706,7 +707,13 @@ public class AsyncServletTest
{ {
((HttpServletResponse)async.getResponse()).addHeader("history","resume"); ((HttpServletResponse)async.getResponse()).addHeader("history","resume");
if (path!=null) if (path!=null)
async.dispatch(path); {
int q=path.indexOf('?');
String uriInContext=(q>=0)
?URIUtil.encodePath(path.substring(0,q))+path.substring(q)
:URIUtil.encodePath(path);
async.dispatch(uriInContext);
}
else else
async.dispatch(); async.dispatch();
} }