aboutsummaryrefslogtreecommitdiffstats
path: root/tests/test-extensions/net
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 /tests/test-extensions/net
parent1de22aca7c4d0627a8fbbec23fffd4ca463969ea (diff)
Handled semicolon in internal server (with reproducers)
Diffstat (limited to 'tests/test-extensions/net')
-rw-r--r--tests/test-extensions/net/sourceforge/jnlp/TinyHttpdImpl.java24
1 files changed, 24 insertions, 0 deletions
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;
+ }
}