Skip to content

Commit

Permalink
[playframework#420] Bug in routing HTTP request with domain inside
Browse files Browse the repository at this point in the history
  • Loading branch information
Jean-Philippe Briend authored and guillaumebort committed Dec 8, 2010
1 parent 8e415ec commit 61c53a7
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions framework/src/play/server/PlayHandler.java
Expand Up @@ -411,10 +411,18 @@ public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyR
Logger.trace("parseRequest: URI = " + nettyRequest.getUri());
int index = nettyRequest.getUri().indexOf("?");
String querystring = "";
String path = URLDecoder.decode(nettyRequest.getUri(), "UTF-8");

String uri = nettyRequest.getUri();
// Remove domain and port from URI if it's present.
if (uri.startsWith("http://") || uri.startsWith("https://")) {
// Begins searching / after 9th character (last / of https://)
uri = uri.substring(uri.indexOf("/", 9));
}

String path = URLDecoder.decode(uri, "UTF-8");
if (index != -1) {
path = URLDecoder.decode(nettyRequest.getUri().substring(0, index), "UTF-8");
querystring = nettyRequest.getUri().substring(index + 1);
path = URLDecoder.decode(uri.substring(0, index), "UTF-8");
querystring = uri.substring(index + 1);
}

final Request request = new Request();
Expand Down Expand Up @@ -452,7 +460,7 @@ public static Request parseRequest(ChannelHandlerContext ctx, HttpRequest nettyR
request.body = new ByteArrayInputStream(n);
}

request.url = nettyRequest.getUri();
request.url = uri;
request.host = nettyRequest.getHeader(HOST);
request.isLoopback = ((InetSocketAddress) ctx.getChannel().getRemoteAddress()).getAddress().isLoopbackAddress() && request.host.matches("^127\\.0\\.0\\.1:?[0-9]*$");

Expand Down

0 comments on commit 61c53a7

Please sign in to comment.