Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGreg Wilkins2009-05-16 01:00:46 +0000
committerGreg Wilkins2009-05-16 01:00:46 +0000
commitcdf04bc3763d1515d01e7413462d545e2f18fec5 (patch)
tree681e3687d5cea2010d243c3dc1b1424f23648824
parentc2f8201aed1dda23477d6e57592c74d44401e9a1 (diff)
downloadorg.eclipse.jetty.project-cdf04bc3763d1515d01e7413462d545e2f18fec5.tar.gz
org.eclipse.jetty.project-cdf04bc3763d1515d01e7413462d545e2f18fec5.tar.xz
org.eclipse.jetty.project-cdf04bc3763d1515d01e7413462d545e2f18fec5.zip
JETTY-1004 improved test harness and reapplied fix
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@219 7e9141cc-0065-0410-87d8-b60c137991c4
-rw-r--r--jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java100
-rw-r--r--jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java5
2 files changed, 69 insertions, 36 deletions
diff --git a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
index 7e4c766ce2..99f33fa9f8 100644
--- a/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
+++ b/jetty-servlet/src/test/java/org/eclipse/jetty/servlet/DefaultServletTest.java
@@ -180,6 +180,7 @@ public class DefaultServletTest extends TestCase
defholder.setInitParameter("dirAllowed","true");
defholder.setInitParameter("redirectWelcome","false");
defholder.setInitParameter("gzip","false");
+ defholder.setInitParameter("aliases","true");
File testDir = new File("target/tests/" + getName());
prepareEmptyTestDir(testDir);
@@ -187,14 +188,12 @@ public class DefaultServletTest extends TestCase
/* create some content in the docroot */
File resBase = new File(testDir, "docroot");
resBase.mkdirs();
- new File(resBase, "one").mkdir();
- new File(resBase, "two").mkdir();
- new File(resBase, "three").mkdir();
- File wackyDir = new File(resBase, "dir");
+
+ File index = new File(resBase, "index.html");
+ createFile(index, "<h>Hello Index</h1>");
+
+ File wackyDir = new File(resBase, "dir?");
assertTrue(wackyDir.mkdirs());
- new File(wackyDir, "four").mkdir();
- new File(wackyDir, "five").mkdir();
- new File(wackyDir, "six").mkdir();
wackyDir = new File(resBase, "dir;");
assertTrue(wackyDir.mkdirs());
@@ -208,14 +207,9 @@ public class DefaultServletTest extends TestCase
/* At this point we have the following
* testListingContextBreakout/
* |-- docroot
- * | |-- dir
- * | | |-- five
- * | | |-- four
- * | | `-- six
+ * | |-- index.html
+ * | |-- dir?
* | |-- dir;
- * | |-- one
- * | |-- three
- * | `-- two
* `-- sekret
* `-- pass
*/
@@ -223,38 +217,80 @@ public class DefaultServletTest extends TestCase
String resBasePath = resBase.getAbsolutePath();
defholder.setInitParameter("resourceBase",resBasePath);
- String response = connector.getResponses("GET /context/dir/?/../../sekret/pass HTTP/1.0\r\n\r\n");
+ String response;
- assertResponseContains("/four/",response);
- assertResponseContains("/five/",response);
- assertResponseContains("/six/",response);
- assertResponseNotContains("Sssh",response);
+ connector.reopen();
+ response= connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("Directory: /context/<",response);
connector.reopen();
- response = connector.getResponses("GET /context/dir/../../../sekret/pass HTTP/1.0\r\n\r\n");
- assertResponseNotContains("Sssh",response);
+ response= connector.getResponses("GET /context/dir?/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("404",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir/%3F/../../sekret/pass HTTP/1.0\r\n\r\n");
- assertResponseNotContains("Sssh",response);
+ response= connector.getResponses("GET /context/dir%3F/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("Directory: /context/dir?/<",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/index.html HTTP/1.0\r\n\r\n");
+ assertResponseContains("Hello Index",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir/%3F/../../../sekret/pass HTTP/1.0\r\n\r\n");
+ response= connector.getResponses("GET /context/dir%3F/../index.html HTTP/1.0\r\n\r\n");
+ assertResponseContains("Hello Index",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir%3F/../../ HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Directory: ",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir%3F/../../sekret/pass HTTP/1.0\r\n\r\n");
assertResponseNotContains("Sssh",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir%3F/../../sekret/pass HTTP/1.0\r\n\r\n");
+ response= connector.getResponses("GET /context/dir?/../../ HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Directory: ",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir?/../../sekret/pass HTTP/1.0\r\n\r\n");
assertResponseNotContains("Sssh",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir%3B/ HTTP/1.0\r\n\r\n");
+ response= connector.getResponses("GET /context/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("Directory: /context/<",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir;/ HTTP/1.0\r\n\r\n");
+ assertResponseContains("404",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir%3B/ HTTP/1.0\r\n\r\n");
assertResponseContains("Directory: /context/dir;/<",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir/../ HTTP/1.0\r\n\r\n");
- assertResponseContains("Directory: /context/<",response);
+ response= connector.getResponses("GET /context/index.html HTTP/1.0\r\n\r\n");
+ assertResponseContains("Hello Index",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir%3B/../ HTTP/1.0\r\n\r\n");
- assertResponseContains("Directory: /context/<",response);
+ response= connector.getResponses("GET /context/dir%3B/../index.html HTTP/1.0\r\n\r\n");
+ assertResponseContains("Hello Index",response);
+
connector.reopen();
- response = connector.getResponses("GET /context/dir%3B/../../sekret/pass HTTP/1.0\r\n\r\n");
- assertResponseContains("Not Found",response);
+ response= connector.getResponses("GET /context/dir%3B/../../ HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Directory: ",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir%3B/../../sekret/pass HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Sssh",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir;/../../ HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Directory: ",response);
+
+ connector.reopen();
+ response= connector.getResponses("GET /context/dir;/../../sekret/pass HTTP/1.0\r\n\r\n");
+ assertResponseNotContains("Sssh",response);
}
private void createFile(File file, String str) throws IOException
diff --git a/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java b/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java
index 76bb6668dc..6c246d2f30 100644
--- a/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java
+++ b/jetty-util/src/main/java/org/eclipse/jetty/util/URIUtil.java
@@ -395,10 +395,7 @@ public class URIUtil
return path;
int end=path.length();
-
- int queryIdx=path.indexOf('?');
- int start = path.lastIndexOf('/', (queryIdx > 0 ? queryIdx : end));
- // int start = path.lastIndexOf('/', end);
+ int start = path.lastIndexOf('/', end);
search:
while (end>0)

Back to the top