From be85a6a16d59d1905d9c6f0025af0ba587be8395 Mon Sep 17 00:00:00 2001 From: Athena Yao Date: Thu, 25 Jun 2009 09:45:47 +0000 Subject: [PATCH] [281470] handle the case where request path == "/*" and servlet mapping uses a wildcard git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@433 7e9141cc-0065-0410-87d8-b60c137991c4 --- VERSION.txt | 1 + .../src/main/java/org/eclipse/jetty/http/PathMap.java | 7 +++++-- .../src/test/java/org/eclipse/jetty/http/PathMapTest.java | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/VERSION.txt b/VERSION.txt index 67095a69184..3edc0ef961b 100644 --- a/VERSION.txt +++ b/VERSION.txt @@ -16,6 +16,7 @@ jetty-7.0.0.M3 20 June 2009 + Refactored AbstractBuffers to HttpBuffers for performance + Numerous cleanups from static code analysis + 280707 client.HttpConnection does not catch and handle non-IOExceptions + + 281470 Handle the case where request.PathInfo() should be "/*" jetty-7.0.0.M2 18 May 2009 + JETTY-937 Work around Sun JVM bugs diff --git a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java index f8b8e0f0c6d..0bfc6c53487 100644 --- a/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java +++ b/jetty-http/src/main/java/org/eclipse/jetty/http/PathMap.java @@ -461,10 +461,13 @@ public class PathMap extends HashMap implements Externalizable if (pathSpec.length()==1) return null; - if (pathSpec.equals(path)) + boolean wildcard = isPathWildcardMatch(pathSpec, path); + + // handle the case where pathSpec uses a wildcard and path info is "/*" + if (pathSpec.equals(path) && !wildcard) return null; - if (isPathWildcardMatch(pathSpec, path)) + if (wildcard) { if (path.length()==pathSpec.length()-2) return null; diff --git a/jetty-http/src/test/java/org/eclipse/jetty/http/PathMapTest.java b/jetty-http/src/test/java/org/eclipse/jetty/http/PathMapTest.java index a9b2320f016..dffa6f2cd51 100644 --- a/jetty-http/src/test/java/org/eclipse/jetty/http/PathMapTest.java +++ b/jetty-http/src/test/java/org/eclipse/jetty/http/PathMapTest.java @@ -77,6 +77,8 @@ public class PathMapTest extends TestCase { "/animal/insect/bug", "5"}, { "/animal", "5"}, { "/animal/", "5"}, + { "/animal/x", "5"}, + { "/animal/*", "5"}, { "/suffix/path.tar.gz", "6"}, { "/suffix/path.gz", "7"}, { "/animal/path.gz", "5"}, @@ -105,6 +107,7 @@ public class PathMapTest extends TestCase assertEquals("pathInfo exact", null, PathMap.pathInfo("/Foo/bar", "/Foo/bar")); assertEquals("pathInfo prefix", "/bar", PathMap.pathInfo("/Foo/*", "/Foo/bar")); + assertEquals("pathInfo prefix", "/*", PathMap.pathInfo("/Foo/*", "/Foo/*")); assertEquals("pathInfo prefix", "/", PathMap.pathInfo("/Foo/*", "/Foo/")); assertEquals("pathInfo prefix", null, PathMap.pathInfo("/Foo/*", "/Foo")); assertEquals("pathInfo suffix", null, PathMap.pathInfo("*.ext", "/Foo/bar.ext"));