Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Watson2019-03-05 15:31:44 -0500
committerRaymond Auge2019-03-05 17:25:38 -0500
commitf8f0c5e1536a1fff5f0c6dcccbd5d77ec9ac6cf3 (patch)
tree1a38ebf62c16949b575de6b07e8c33b5cd225cbf
parent775dd74aa404e745a1beac5903cc642782d15115 (diff)
downloadrt.equinox.bundles-R4_11_maintenance.tar.gz
rt.equinox.bundles-R4_11_maintenance.tar.xz
rt.equinox.bundles-R4_11_maintenance.zip
M2 Change-Id: Ica97acc6ad2e8ec564f2ec92dadb2ec07469088c Signed-off-by: Thomas Watson <tjwatson@us.ibm.com>
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/ServletTest.java20
-rw-r--r--bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt1
-rw-r--r--bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java15
3 files changed, 30 insertions, 6 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 299c6feb..e820cef8 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
@@ -1969,6 +1969,26 @@ public class ServletTest extends BaseTest {
}
@Test
+ public void test_ResourceAliasNormal() throws Exception {
+ HttpService extendedHttpService = getHttpService();
+
+ extendedHttpService.registerResources("/testalias", "/org/eclipse/equinox/http/servlet/tests", null);
+
+ String actual = requestAdvisor.request("testalias/resource2.txt");
+ Assert.assertEquals("Wrong value.", "test", actual);
+ }
+
+ @Test
+ public void test_ResourceAliasSlash() throws Exception {
+ HttpService extendedHttpService = getHttpService();
+
+ extendedHttpService.registerResources("/", "/org/eclipse/equinox/http/servlet/tests", null);
+
+ String actual = requestAdvisor.request("resource2.txt");
+ Assert.assertEquals("Wrong value.", "test", actual);
+ }
+
+ @Test
public void test_ResourceRangeRequest_Complete() throws Exception {
Bundle bundle = installBundle(TEST_BUNDLE_2);
ServletContextHelper customSCH = new ServletContextHelper(bundle) {
diff --git a/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt
new file mode 100644
index 00000000..30d74d25
--- /dev/null
+++ b/bundles/org.eclipse.equinox.http.servlet.tests/src/org/eclipse/equinox/http/servlet/tests/resource2.txt
@@ -0,0 +1 @@
+test \ No newline at end of file
diff --git a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
index f2e3f2b9..ecd7b2c1 100644
--- a/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
+++ b/bundles/org.eclipse.equinox.http.servlet/src/org/eclipse/equinox/http/servlet/internal/HttpServiceRuntimeImpl.java
@@ -771,15 +771,18 @@ public class HttpServiceRuntimeImpl
throw new IllegalArgumentException("Name cannot be null"); //$NON-NLS-1$
}
String pattern = alias;
- if (pattern.startsWith("/*.")) { //$NON-NLS-1$
+ if (pattern.startsWith(Const.SLASH_STAR_DOT)) {
pattern = pattern.substring(1);
}
- else if (!pattern.contains("*.") && //$NON-NLS-1$
- !pattern.endsWith(Const.SLASH_STAR) &&
- !pattern.endsWith(Const.SLASH)) {
- pattern += Const.SLASH_STAR;
+ // need to make sure exact matching aliases are converted to wildcard pattern matches
+ if (!pattern.endsWith(Const.SLASH_STAR) && !pattern.startsWith(Const.STAR_DOT) && !pattern.contains(Const.SLASH_STAR_DOT)) {
+ if (pattern.endsWith(Const.SLASH)) {
+ pattern = pattern + '*';
+ } else {
+ pattern = pattern + Const.SLASH_STAR;
+ }
}
-
+ // check the pattern against the original input
ContextController.checkPattern(alias);
synchronized (legacyMappings) {

Back to the top