Merge remote-tracking branch 'origin/jetty-8'

Conflicts:
	jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java
This commit is contained in:
Greg Wilkins 2013-01-17 11:00:20 +11:00
commit 46e13b305b
5 changed files with 79 additions and 8 deletions

View File

@ -566,7 +566,7 @@ public class UrlEncoded extends MultiMap<String> implements Cloneable
StringWriter buf = new StringWriter(8192);
IO.copy(input,buf,maxLength);
decodeTo(buf.getBuffer().toString(),map,ENCODING,maxKeys);
decodeTo(buf.getBuffer().toString(),map,StringUtil.__UTF16,maxKeys);
}
/* -------------------------------------------------------------- */

View File

@ -175,16 +175,16 @@ public class URLEncodedTest
{
String [][] charsets = new String[][]
{
{StringUtil.__UTF8,null},
{StringUtil.__ISO_8859_1,StringUtil.__ISO_8859_1},
{StringUtil.__UTF8,StringUtil.__UTF8},
{StringUtil.__UTF16,StringUtil.__UTF16},
{StringUtil.__UTF8,null,"%30"},
{StringUtil.__ISO_8859_1,StringUtil.__ISO_8859_1,"%30"},
{StringUtil.__UTF8,StringUtil.__UTF8,"%30"},
{StringUtil.__UTF16,StringUtil.__UTF16,"%00%30"},
};
for (int i=0;i<charsets.length;i++)
{
ByteArrayInputStream in = new ByteArrayInputStream("name\n=value+%30&name1=&name2&n\u00e3me3=value+3".getBytes(charsets[i][0]));
ByteArrayInputStream in = new ByteArrayInputStream(("name\n=value+"+charsets[i][2]+"&name1=&name2&n\u00e3me3=value+3").getBytes(charsets[i][0]));
MultiMap<String> m = new MultiMap<>();
UrlEncoded.decodeTo(in, m, charsets[i][1]==null?null:Charset.forName(charsets[i][1]), -1,-1);
assertEquals(charsets[i][1]+" stream length",4,m.size());

View File

@ -0,0 +1,65 @@
//
// ========================================================================
// Copyright (c) 1995-2013 Mort Bay Consulting Pty. Ltd.
// ------------------------------------------------------------------------
// All rights reserved. This program and the accompanying materials
// are made available under the terms of the Eclipse Public License v1.0
// and Apache License v2.0 which accompanies this distribution.
//
// The Eclipse Public License is available at
// http://www.eclipse.org/legal/epl-v10.html
//
// The Apache License v2.0 is available at
// http://www.opensource.org/licenses/apache2.0.php
//
// You may elect to redistribute this code under either of these licenses.
// ========================================================================
//
package org.eclipse.jetty.test.jsp;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class FakeJspServlet extends HttpServlet
{
/* ------------------------------------------------------------ */
/*
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
*/
protected void doGet(HttpServletRequest req, HttpServletResponse response) throws ServletException, IOException
{
String path = req.getServletPath();
URL url =getServletContext().getResource(path);
if (url==null)
{
response.sendError(404);
return;
}
try
{
File file=new File(url.toURI());
if (file.exists())
{
response.sendError(200,"fake JSP response");
return;
}
}
catch (Exception e)
{
e.printStackTrace();
}
response.sendError(404);
}
}

View File

@ -34,6 +34,7 @@ import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.Server;
import org.eclipse.jetty.server.nio.SelectChannelConnector;
import org.eclipse.jetty.servlet.DefaultServlet;
import org.eclipse.jetty.servlet.NoJspServlet;
import org.eclipse.jetty.servlet.ServletContextHandler;
import org.eclipse.jetty.servlet.ServletHolder;
import org.eclipse.jetty.toolchain.test.MavenTestingUtils;
@ -106,7 +107,8 @@ public class JspAndDefaultWithAliasesTest
defaultServHolder.setInitParameter("aliases","true"); // important! must be TRUE
// add jsp
ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp");
ServletHolder jsp = new ServletHolder(new FakeJspServlet());
context.addServlet(jsp,"*.jsp");
jsp.setInitParameter("classpath",context.getClassPath());
// add context
@ -157,6 +159,9 @@ public class JspAndDefaultWithAliasesTest
return;
}
if (conn.getResponseCode()!=404)
System.err.println(conn.getResponseMessage());
// Of other possible paths, only 404 Not Found is expected
Assert.assertThat("Response Code",conn.getResponseCode(),is(404));
}

View File

@ -106,7 +106,8 @@ public class JspAndDefaultWithoutAliasesTest
defaultServHolder.setInitParameter("aliases","false"); // important! must be FALSE
// add jsp
ServletHolder jsp = context.addServlet(JspServlet.class,"*.jsp");
ServletHolder jsp = new ServletHolder(new FakeJspServlet());
context.addServlet(jsp,"*.jsp");
jsp.setInitParameter("classpath",context.getClassPath());
// add context