diff options
5 files changed, 79 insertions, 8 deletions
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java index 5460db93e8..f62e025121 100644 --- a/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java +++ b/jetty-util/src/main/java/org/eclipse/jetty/util/UrlEncoded.java @@ -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); } /* -------------------------------------------------------------- */ diff --git a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java index 80cde73822..258d023e46 100644 --- a/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java +++ b/jetty-util/src/test/java/org/eclipse/jetty/util/URLEncodedTest.java @@ -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()); diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java new file mode 100644 index 0000000000..2397faec6c --- /dev/null +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/FakeJspServlet.java @@ -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); + } + +} diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java index 6dc439d017..019a3c7003 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithAliasesTest.java @@ -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)); } diff --git a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java index 8ff5160924..3a82d88b4c 100644 --- a/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java +++ b/tests/test-integration/src/test/java/org/eclipse/jetty/test/jsp/JspAndDefaultWithoutAliasesTest.java @@ -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 |