Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Auge2018-12-11 20:56:50 +0000
committerThomas Watson2018-12-11 22:30:36 +0000
commit06745b4298f5ad9dce5d680095cb8fea435587cd (patch)
tree8700d1e6426789e3252dc5f1569f2c995223c2b2
parent7cfd24099844b8c1b0f691831f2012c53af40a6f (diff)
downloadrt.equinox.bundles-06745b4298f5ad9dce5d680095cb8fea435587cd.tar.gz
rt.equinox.bundles-06745b4298f5ad9dce5d680095cb8fea435587cd.tar.xz
rt.equinox.bundles-06745b4298f5ad9dce5d680095cb8fea435587cd.zip
Signed-off-by: Raymond Auge <raymond.auge@liferay.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java28
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java19
2 files changed, 31 insertions, 16 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
index daac63089..f738af0cb 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java
@@ -2685,6 +2685,34 @@ public class ServletTest extends BaseTest {
}
@Test
+ public void test_PathEncodings_Bug540970() throws Exception {
+ Servlet servlet = new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected void service(HttpServletRequest req, HttpServletResponse resp)
+ throws ServletException, IOException {
+
+ PrintWriter writer = resp.getWriter();
+
+ writer.write(req.getRequestURI());
+ }
+ };
+
+ Dictionary<String, Object> props = new Hashtable<String, Object>();
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "S16");
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Servlet16/*");
+ registrations.add(getBundleContext().registerService(Servlet.class, servlet, props));
+
+ Map<String, List<String>> map = new HashMap<String, List<String>>();
+
+ Map<String, List<String>> result = requestAdvisor.request("Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", map);
+
+ Assert.assertEquals("200", result.get("responseCode").get(0));
+ Assert.assertEquals("/Servlet16/NEEO-a5056097%2Fdevice%2Fapt-neeo_io%3Avirtual%3A6jzOoAtL%2FTemperature_GF_Living%2Fnone%2F1%2Fdirectory%2Factor/default", result.get("responseBody").get(0));
+ }
+
+ @Test
public void test_ServletContext1() throws Exception {
String expected = "/org/eclipse/equinox/http/servlet/tests/tb1/resource1.txt";
String actual;
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
index 7f5b3c8f6..9e97b0a0e 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/servlet/ProxyServlet.java
@@ -60,9 +60,9 @@ public class ProxyServlet extends HttpServlet {
public void sessionIdChanged(String oldSessionId) {
httpServiceRuntimeImpl.fireSessionIdChanged(oldSessionId);
}
-
+
/**
- * get the value of path info, not decoded by the server
+ * get the value of path info, not decoded by the server
*/
private String getNotDecodedAlias(HttpServletRequest request) {
String pathInfo = HttpServletRequestWrapperImpl.getDispatchPathInfo(request);
@@ -70,20 +70,7 @@ public class ProxyServlet extends HttpServlet {
return null;
}
String requestUri = HttpServletRequestWrapperImpl.getDispatchRequestURI(request);
-
- // NOTE use split that takes a max to preserve ending SLASH
- String[] pathInfoSegments = pathInfo.split(Const.SLASH, Integer.MAX_VALUE - 1);
- String[] requestUriSegments = requestUri.split(Const.SLASH, Integer.MAX_VALUE - 1);
-
- if(pathInfoSegments.length == requestUriSegments.length) {
- return requestUri;
- }
-
- StringBuilder aliasBuilder = new StringBuilder();
- for(int i=(requestUriSegments.length - pathInfoSegments.length + 1);i<requestUriSegments.length;i++) {
- aliasBuilder.append(Const.SLASH).append(requestUriSegments[i]);
- }
- return aliasBuilder.toString();
+ return requestUri.substring(request.getContextPath().length() + request.getServletPath().length());
}
/**

Back to the top