Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRaymond Augé2020-05-11 15:41:47 +0000
committerRaymond Augé2020-05-11 16:36:14 +0000
commit7dada08bc8358093b5e09b58cbfc4573513e1798 (patch)
tree2f327bf4e7bfdb9ddb5e0a33c7457051bd33374e
parentb0229b70ed4d823a36c4ecaf5eb2cbfc344ac538 (diff)
downloadrt.equinox.bundles-7dada08bc8358093b5e09b58cbfc4573513e1798.tar.gz
rt.equinox.bundles-7dada08bc8358093b5e09b58cbfc4573513e1798.tar.xz
rt.equinox.bundles-7dada08bc8358093b5e09b58cbfc4573513e1798.zip
Bug 562843 - Do not decode already decoded servletPaths
Signed-off-by: Raymond Augé <raymond.auge@liferay.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java4
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java83
2 files changed, 86 insertions, 1 deletions
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
index 60bfe342..809779fa 100644
--- a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/testbase/AllTests.java
@@ -15,6 +15,7 @@ package org.eclipse.equinox.http.servlet.testbase;
import org.eclipse.equinox.http.servlet.tests.AuthenticationTest;
import org.eclipse.equinox.http.servlet.tests.Bug500783_Test;
+import org.eclipse.equinox.http.servlet.tests.Bug562843_2_Test;
import org.eclipse.equinox.http.servlet.tests.Bug562843_Test;
import org.eclipse.equinox.http.servlet.tests.ContextHelperCustomizerTests;
import org.eclipse.equinox.http.servlet.tests.DispatchingTest;
@@ -98,7 +99,8 @@ import org.junit.runners.Suite.SuiteClasses;
TestUpload.class,
ContextHelperCustomizerTests.class,
Bug500783_Test.class,
- Bug562843_Test.class
+ Bug562843_Test.class,
+ Bug562843_2_Test.class
})
public class AllTests {
// see @SuiteClasses
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java
new file mode 100644
index 00000000..29cd1049
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/Bug562843_2_Test.java
@@ -0,0 +1,83 @@
+package org.eclipse.equinox.http.servlet.tests;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.URLEncoder;
+import java.util.Dictionary;
+import java.util.Hashtable;
+import java.util.concurrent.atomic.AtomicReference;
+
+import javax.servlet.Servlet;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.eclipse.equinox.http.servlet.testbase.BaseTest;
+import org.junit.Assert;
+import org.junit.Test;
+import org.osgi.service.http.whiteboard.HttpWhiteboardConstants;
+
+public class Bug562843_2_Test extends BaseTest {
+
+ @Test
+ public void test_Bug562843_testEncodedSpace() throws Exception {
+ final AtomicReference<String> requestURI = new AtomicReference<>();
+ final AtomicReference<String> servletPath = new AtomicReference<>();
+ final AtomicReference<String> pathInfo = new AtomicReference<>();
+ Servlet servlet = new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+ @Override
+ protected void doGet(
+ final HttpServletRequest req, final HttpServletResponse resp)
+ throws IOException {
+ requestURI.set(req.getRequestURI());
+ servletPath.set(req.getServletPath());
+ pathInfo.set(req.getPathInfo());
+ PrintWriter writer = resp.getWriter();
+ writer.write("OK");
+ }
+ };
+ Dictionary<String, Object> props = new Hashtable<>();
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "Bug 562843");
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Bug562843/*");
+ registrations.add(getBundleContext().registerService(Servlet.class, servlet, props));
+ String path = "Bug562843/" + URLEncoder.encode("topic .html", "UTF-8");
+ String result = requestAdvisor.request(path);
+ Assert.assertEquals("OK", result);
+ Assert.assertEquals("/Bug562843/topic+.html", requestURI.get());
+ Assert.assertEquals("/Bug562843", servletPath.get());
+ Assert.assertEquals("/topic .html", pathInfo.get());
+ }
+
+
+ @Test
+ public void test_Bug562843_testEncodedPercentSign() throws Exception {
+ final AtomicReference<String> requestURI = new AtomicReference<>();
+ final AtomicReference<String> servletPath = new AtomicReference<>();
+ final AtomicReference<String> pathInfo = new AtomicReference<>();
+ Servlet servlet = new HttpServlet() {
+ private static final long serialVersionUID = 1L;
+ @Override
+ protected void doGet(
+ final HttpServletRequest req, final HttpServletResponse resp)
+ throws IOException {
+ requestURI.set(req.getRequestURI());
+ servletPath.set(req.getServletPath());
+ pathInfo.set(req.getPathInfo());
+ PrintWriter writer = resp.getWriter();
+ writer.write("OK");
+ }
+ };
+ Dictionary<String, Object> props = new Hashtable<>();
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_NAME, "Bug 562843");
+ props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, "/Bug562843/*");
+ registrations.add(getBundleContext().registerService(Servlet.class, servlet, props));
+ String path = "Bug562843/" + URLEncoder.encode("topic%.html", "UTF-8");
+ String result = requestAdvisor.request(path);
+ Assert.assertEquals("OK", result);
+ Assert.assertEquals("/Bug562843/topic%25.html", requestURI.get());
+ Assert.assertEquals("/Bug562843", servletPath.get());
+ Assert.assertEquals("/topic%.html", pathInfo.get());
+ }
+
+}

Back to the top