aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiri Vanek <[email protected]>2013-06-10 13:22:53 +0200
committerJiri Vanek <[email protected]>2013-06-10 13:22:53 +0200
commitfaffea863331de3cb97e5654313922fafd61745c (patch)
treec7f73df08ef79b55c657c7ec2e4854ef9e27b8fc
parent1de22aca7c4d0627a8fbbec23fffd4ca463969ea (diff)
Handled semicolon in internal server (with reproducers)
-rw-r--r--ChangeLog18
-rw-r--r--tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.html48
-rw-r--r--tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.jnlp53
-rw-r--r--tests/reproducers/simple/StripHttpPathParams/srcs/StripHttpPathParams.java51
-rw-r--r--tests/reproducers/simple/StripHttpPathParams/testcases/StripHttpPathParamsTest.java68
-rw-r--r--tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java28
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java24
7 files changed, 290 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index b10ca3f..38599c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,22 @@
2013-06-06 Jiri Vanek <[email protected]>
+ Andrew Azores <[email protected]>
+
+ Handled semicolon in internal server
+ * tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java:
+ added stripHttpPathParams method to remove semicolon-delimited "tags"
+ from end of JAR URLs
+ * tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java:
+ added test case for new method in TinyHttpdImpl
+ * tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.html:
+ browser-launched applet test case for reproducer
+ * tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.jnlp:
+ JNLP test case for reproducer
+ * tests/reproducers/simple/StripHttpPathParams/srcs/StripHttpPathParams.java:
+ reproducer
+ * tests/reproducers/simple/StripHttpPathParams/testcases/StripHttpPathParamsTest.java:
+ Testcase to above reproducer
+
+2013-06-06 Jiri Vanek <[email protected]>
Made all tests running wit junit4.10 and higher
* tests/junit-runner/CommandLine.java: (runMain) is no longer overriding
diff --git a/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.html b/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.html
new file mode 100644
index 0000000..028ae1a
--- /dev/null
+++ b/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.html
@@ -0,0 +1,48 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+ -->
+<html>
+ <head></head>
+ <body>
+ <applet code="StripHttpPathParams.class"
+ archive="StripHttpPathParams.jar;foo_bar"
+ codebase="."
+ width="800"
+ height="600">
+ </applet>
+ </body>
+</html>
diff --git a/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.jnlp b/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.jnlp
new file mode 100644
index 0000000..ef4374d
--- /dev/null
+++ b/tests/reproducers/simple/StripHttpPathParams/resources/StripHttpPathParams.jnlp
@@ -0,0 +1,53 @@
+<!--
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+IcedTea is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to the
+Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+
+ -->
+<?xml version="1.0" encoding="utf-8"?>
+<jnlp spec="1.0" href="StripHttpPathParams.jnlp" codebase=".">
+ <information>
+ <title>StripHttpPathParams</title>
+ <vendor>IcedTea</vendor>
+ <homepage href="http://icedtea.classpath.org/wiki/IcedTea-Web#Testing_IcedTea-Web"/>
+ <description>Remove HTTP Path Parameters from JAR URLs</description>
+ <offline/>
+ </information>
+ <resources>
+ <j2se version="1.4+"/>
+ <jar href="StripHttpPathParams.jar;foo_bar"/>
+ </resources>
+ <application-desc main-class="StripHttpPathParams">
+ </application-desc>
+</jnlp>
diff --git a/tests/reproducers/simple/StripHttpPathParams/srcs/StripHttpPathParams.java b/tests/reproducers/simple/StripHttpPathParams/srcs/StripHttpPathParams.java
new file mode 100644
index 0000000..535366e
--- /dev/null
+++ b/tests/reproducers/simple/StripHttpPathParams/srcs/StripHttpPathParams.java
@@ -0,0 +1,51 @@
+/* StripHttpPathParams.java
+Copyright (C) 2011 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import java.applet.Applet;
+
+public class StripHttpPathParams extends Applet {
+ private static final String appletCloseString = "*** APPLET FINISHED ***";
+
+ public static void main(String[] args) {
+ System.out.println("running");
+ }
+
+ @Override
+ public void init() {
+ System.out.println(appletCloseString);
+ }
+}
diff --git a/tests/reproducers/simple/StripHttpPathParams/testcases/StripHttpPathParamsTest.java b/tests/reproducers/simple/StripHttpPathParams/testcases/StripHttpPathParamsTest.java
new file mode 100644
index 0000000..b036faa
--- /dev/null
+++ b/tests/reproducers/simple/StripHttpPathParams/testcases/StripHttpPathParamsTest.java
@@ -0,0 +1,68 @@
+/* StripHttpPathParamsTest.java
+Copyright (C) 2011 Red Hat, Inc.
+
+This file is part of IcedTea.
+
+IcedTea is free software; you can redistribute it and/or
+modify it under the terms of the GNU General Public License as published by
+the Free Software Foundation, version 2.
+
+IcedTea is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with IcedTea; see the file COPYING. If not, write to
+the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+02110-1301 USA.
+
+Linking this library statically or dynamically with other modules is
+making a combined work based on this library. Thus, the terms and
+conditions of the GNU General Public License cover the whole
+combination.
+
+As a special exception, the copyright holders of this library give you
+permission to link this library with independent modules to produce an
+executable, regardless of the license terms of these independent
+modules, and to copy and distribute the resulting executable under
+terms of your choice, provided that you also meet, for each linked
+independent module, the terms and conditions of the license of that
+module. An independent module is a module which is not derived from
+or based on this library. If you modify this library, you may extend
+this exception to your version of the library, but you are not
+obligated to do so. If you do not wish to do so, delete this
+exception statement from your version.
+ */
+
+import net.sourceforge.jnlp.ProcessResult;
+import net.sourceforge.jnlp.ServerAccess.AutoClose;
+import net.sourceforge.jnlp.annotations.KnownToFail;
+import net.sourceforge.jnlp.annotations.NeedsDisplay;
+import net.sourceforge.jnlp.annotations.TestInBrowsers;
+import net.sourceforge.jnlp.browsertesting.BrowserTest;
+import net.sourceforge.jnlp.browsertesting.Browsers;
+import net.sourceforge.jnlp.closinglisteners.AutoOkClosingListener;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+public class StripHttpPathParamsTest extends BrowserTest {
+
+ private static final String appletCloseString = AutoOkClosingListener.MAGICAL_OK_CLOSING_STRING;
+
+ @Test
+ public void testStripHttpPathParamsLaunch() throws Exception {
+ ProcessResult pr = server.executeJavawsHeadless("/StripHttpPathParams.jnlp");
+ Assert.assertTrue("stdout should contain \"running\" but did not", pr.stdout.contains("running"));
+ }
+
+ @NeedsDisplay
+ @Test
+ @TestInBrowsers(testIn={Browsers.one})
+ public void testStripHttpPathParamsApplet() throws Exception {
+ ProcessResult pr = server.executeBrowser("/StripHttpPathParams.html", AutoClose.CLOSE_ON_BOTH);
+ Assert.assertTrue("stdout should contain " + appletCloseString + " but did not", pr.stdout.contains(appletCloseString));
+ }
+
+}
diff --git a/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java b/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java
index 25415be..3ddd09e 100644
--- a/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java
+++ b/tests/test-extensions-tests/net/sourceforge/jnlp/ServerAccessTest.java
@@ -217,6 +217,34 @@ public class ServerAccessTest {
Assert.assertArrayEquals(b2, bb[1]);
Assert.assertArrayEquals(b3, bb[2]);
}
+
+ @Test
+ public void stripHttpPathParamTest() {
+ String[] testBaseUrls = {
+ "http://foo.com/bar",
+ "localhost:8080",
+ "https://bar.co.uk/site;para/baz?u=param1&v=param2"
+ };
+
+ String[] testJarNames = {
+ "jar",
+ "foo.jar",
+ "bar;baz.jar",
+ "nom.jar;",
+ "rhat.jar.pack.gz;tag"
+ };
+
+ for (String url : testBaseUrls) {
+ for (String jar : testJarNames) {
+ String newUrl = TinyHttpdImpl.stripHttpPathParams(url),
+ newJar = TinyHttpdImpl.stripHttpPathParams(jar),
+ path = newUrl + "/" + newJar;
+ Assert.assertTrue("Base URL should not have been modified: " + url + " => " + newUrl, newUrl.equals(url));
+ Assert.assertTrue("JAR name should not be altered other than removing path param: " + jar + " => " + newJar, jar.startsWith(newJar));
+ Assert.assertTrue("New path should be a substring of old path: " + path + " => " + url + "/" + jar, (url + "/" + jar).startsWith(path));
+ }
+ }
+ }
private void printArrays(byte[][] bb) {
System.out.println("[][] l=" + bb.length);
diff --git a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java
index 561926a..4ef6450 100644
--- a/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java
+++ b/tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java
@@ -127,6 +127,7 @@ public class TinyHttpdImpl extends Thread {
p = URLDecoder.decode(p, "UTF-8");
p = p.replaceAll("\\?.*", "");
p = (".".concat((p.endsWith("/")) ? p.concat("index.html") : p)).replace('/', File.separatorChar);
+ p = stripHttpPathParams(p);
ServerAccess.logNoReprint("Serving: " + p);
File pp = new File(dir, p);
int l = (int) pp.length();
@@ -203,4 +204,27 @@ public class TinyHttpdImpl extends Thread {
}
return array;
}
+
+ /**
+ * This function removes the HTTP Path Parameter from a given JAR URL, assuming that the
+ * path param delimiter is a semicolon
+ * @param url - the URL from which to remove the path parameter
+ * @return the URL with the path parameter removed
+ */
+ public static String stripHttpPathParams(String url) {
+ if (url == null) {
+ return null;
+ }
+
+ // If JNLP specifies JAR URL with .JAR extension (as it should), then look for any semicolons
+ // after this position. If one is found, remove it and any following characters.
+ int fileExtension = url.toUpperCase().lastIndexOf(".JAR");
+ if (fileExtension != -1) {
+ int firstSemiColon = url.indexOf(';', fileExtension);
+ if (firstSemiColon != -1) {
+ url = url.substring(0, firstSemiColon);
+ }
+ }
+ return url;
+ }
}