aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVioleta Georgieva2010-11-11 10:30:45 (EST)
committerChristopher Frost2010-11-11 10:30:45 (EST)
commitb98b5fe08ff61ff958b39fe6b7988e1c242a1af6 (patch)
treed944c73dfabee18431fac2723424a6a02d93b7cc
parentd7f786fb02e24aff7396c048eddc6d55e8563e10 (diff)
downloadorg.eclipse.gemini.web.gemini-web-container-b98b5fe08ff61ff958b39fe6b7988e1c242a1af6.zip
org.eclipse.gemini.web.gemini-web-container-b98b5fe08ff61ff958b39fe6b7988e1c242a1af6.tar.gz
org.eclipse.gemini.web.gemini-web-container-b98b5fe08ff61ff958b39fe6b7988e1c242a1af6.tar.bz2
Bug 329566: HttpServlet.getRealPath fixed
-rw-r--r--org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java4
-rw-r--r--org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java7
-rw-r--r--org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java8
3 files changed, 18 insertions, 1 deletions
diff --git a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
index acb2338..0c2587a 100644
--- a/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
+++ b/org.eclipse.gemini.web.test/src/test/java/org/eclipse/gemini/web/test/tomcat/TomcatServletContainerTests.java
@@ -425,7 +425,9 @@ public class TomcatServletContainerTests {
File indexJsp = new File(webAppDir, "index.jsp");
createFileWithContent(indexJsp, "Hello World!\n"
+ "config.getServletContext().getResourcePaths(/): <%=config.getServletContext().getResourcePaths(\"/\")%>\n"
- + "config.getServletContext().getRealPath(/): <%=config.getServletContext().getRealPath(\"/\")%>");
+ + "config.getServletContext().getRealPath(/): <%=config.getServletContext().getRealPath(\"/\")%>\n"
+ + "************** REAL PATH: <%=request.getRealPath(\".\")%>\n"
+ + "************** REAL PATH: <%=request.getRealPath(\"META-INF/.\")%>\n");
Bundle bundle = this.bundleContext.installBundle(LOCATION_PREFIX + webAppDir.getAbsolutePath() + "?Web-ContextPath=/simple-web-app-dir");
bundle.start();
diff --git a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java
index 8404b24..c23ebaf 100644
--- a/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java
+++ b/org.eclipse.gemini.web.tomcat/src/main/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntry.java
@@ -28,6 +28,8 @@ import org.osgi.framework.Bundle;
public final class BundleEntry {
private static final String PATH_SEPARATOR = "/";
+
+ private static final String DOT = ".";
private final String path;
@@ -128,6 +130,11 @@ public final class BundleEntry {
searchPath = path.substring(0, lastSlashIndex);
searchFile = path.substring(lastSlashIndex + 1);
}
+
+ if (searchFile.equals(DOT)) {
+ return this.bundle.getEntry(path.substring(0, path.length() - 1));
+ }
+
Enumeration<?> entries = this.bundle.findEntries(searchPath,
searchFile, false);
diff --git a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java
index 8d113b3..4633f39 100644
--- a/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java
+++ b/org.eclipse.gemini.web.tomcat/src/test/java/org/eclipse/gemini/web/tomcat/internal/loading/BundleEntryTests.java
@@ -104,9 +104,17 @@ public class BundleEntryTests {
assertNotNull(entry.getEntry("sub/one.txt"));
assertNotNull(entry.getEntry("sub/another.sub/"));
assertNotNull(entry.getEntry("sub/another.sub/two.txt"));
+ assertNotNull(entry.getEntry("."));
+ assertNotNull(entry.getEntry("sub/."));
+ assertNotNull(entry.getEntry(""));
+ assertNotNull(entry.getEntry("/"));
assertTrue(entry.getEntry("sub/").isDirectory());
assertTrue(entry.getEntry("sub/another.sub/").isDirectory());
+ assertTrue(entry.getEntry(".").isDirectory());
+ assertTrue(entry.getEntry("sub/.").isDirectory());
+ assertTrue(entry.getEntry("").isDirectory());
+ assertTrue(entry.getEntry("/").isDirectory());
}
@Test