From: Ben Soares Date: Tue, 28 May 2024 21:14:17 +0000 (+0100) Subject: JAL-4409 JAL-4160 Don't let getdown turn jalviewX:// URIs into absolute local file... X-Git-Tag: Release_2_11_4_0~28^2~4 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=ca3071875159ff8ab35d786f2c8e5359d0370e27;p=jalview.git JAL-4409 JAL-4160 Don't let getdown turn jalviewX:// URIs into absolute local file paths. Allow getdown CLI memory setting with double-dash --jvmmemX --- diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 9a6626f..61ee4e5 100644 Binary files a/getdown/lib/getdown-core.jar and b/getdown/lib/getdown-core.jar differ diff --git a/getdown/lib/getdown-launcher-local.jar b/getdown/lib/getdown-launcher-local.jar index 3ba56f5..8f7d6c8 100644 Binary files a/getdown/lib/getdown-launcher-local.jar and b/getdown/lib/getdown-launcher-local.jar differ diff --git a/getdown/lib/getdown-launcher.jar b/getdown/lib/getdown-launcher.jar index e6b43ab..d86a00f 100644 Binary files a/getdown/lib/getdown-launcher.jar and b/getdown/lib/getdown-launcher.jar differ diff --git a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java index fca6b4d..dade5de 100644 --- a/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java +++ b/getdown/src/getdown/core/src/main/java/com/threerings/getdown/data/Application.java @@ -1142,6 +1142,14 @@ public class Application jvmmemmax = argString.substring(11); continue; } + if (argString.startsWith("--jvmmempc=")) { + jvmmempc = argString.substring(11); + continue; + } + if (argString.startsWith("--jvmmemmax=")) { + jvmmemmax = argString.substring(12); + continue; + } } // use saved preferences if no cmdline args @@ -1198,7 +1206,7 @@ public class Application // almost finally check the startup file arguments for (String f : _startupFiles) { - _appargs.add(HttpUtils.startsWithHttpOrHttps(f)?f:new File(f).getAbsolutePath()); + _appargs.add(HttpUtils.startsWithHttpOrHttpsOrJalviewScheme(f)?f:new File(f).getAbsolutePath()); } // check if one arg with recognised extension diff --git a/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java b/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java index 04a820d..c607840 100644 --- a/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java +++ b/getdown/src/getdown/core/src/main/java/jalview/util/HttpUtils.java @@ -28,9 +28,11 @@ import java.net.ProtocolException; import java.net.URI; import java.net.URISyntaxException; import java.net.URL; +import java.net.URLConnection; public class HttpUtils { + public final static String JALVIEWSCHEMEPREFIX = "jalview"; /** * Returns true if it is possible to open an input stream at the given URL, @@ -74,6 +76,15 @@ public class HttpUtils return file.startsWith("http://") || file.startsWith("https://"); } + public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file) + { + if (startsWithHttpOrHttps(file)) + { + return true; + } + return isJalviewSchemeUri(file); + } + /** * wrapper to get/post to a URL or check headers * @@ -149,13 +160,13 @@ public class HttpUtils * url * @return HttpUrlConnection conn */ - public static HttpURLConnection openConnection(URL url) throws IOException + public static URLConnection openConnection(URL url) throws IOException { if (url == null) { return null; } - HttpURLConnection conn = null; + URLConnection conn = null; String protocol = url.getProtocol(); if ("http".equals(protocol) || "https".equals(protocol)) { @@ -169,6 +180,10 @@ public class HttpUtils conn = conn0; } } + else + { + conn = url.openConnection(); + } return conn; } @@ -222,14 +237,15 @@ public class HttpUtils return false; } String scheme = jalviewUri.getScheme(); - if (scheme == null || !scheme.startsWith("jalview")) + if (scheme == null || !scheme.startsWith(JALVIEWSCHEMEPREFIX)) { return false; } - return scheme.length() == 7 // jalview - || scheme.length() == 8 // jalviewX - || scheme.substring(7).equals("http") // jalviewhttp - || scheme.substring(7).equals("https"); // jalviewhttps + int jspl = JALVIEWSCHEMEPREFIX.length(); + return scheme.length() == jspl // jalview + || scheme.length() == jspl + 1 // jalviewX + || scheme.substring(jspl).equals("http") // jalviewhttp + || scheme.substring(jspl).equals("https"); // jalviewhttps } /** @@ -256,13 +272,15 @@ public class HttpUtils } String scheme = jalviewUri.getScheme(); String host = jalviewUri.getHost(); - if (host != null && host.length() > 0 - || scheme.substring(7).startsWith("http")) + if (host != null && host.length() > 0 || scheme + .substring(JALVIEWSCHEMEPREFIX.length()).startsWith("http")) { URI newUri; try { - newUri = new URI(scheme.equals("jalviewhttp") ? "http" : "https", + newUri = new URI( + scheme.equals(JALVIEWSCHEMEPREFIX + "http") ? "http" + : "https", jalviewUri.getUserInfo(), host, jalviewUri.getPort(), jalviewUri.getPath(), jalviewUri.getQuery(), jalviewUri.getFragment()); diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 9a6626f..61ee4e5 100644 Binary files a/j11lib/getdown-core.jar and b/j11lib/getdown-core.jar differ diff --git a/j8lib/getdown-core.jar b/j8lib/getdown-core.jar index 9a6626f..61ee4e5 100644 Binary files a/j8lib/getdown-core.jar and b/j8lib/getdown-core.jar differ diff --git a/src/jalview/util/HttpUtils.java b/src/jalview/util/HttpUtils.java index d6e4c14..c607840 100644 --- a/src/jalview/util/HttpUtils.java +++ b/src/jalview/util/HttpUtils.java @@ -32,6 +32,7 @@ import java.net.URLConnection; public class HttpUtils { + public final static String JALVIEWSCHEMEPREFIX = "jalview"; /** * Returns true if it is possible to open an input stream at the given URL, @@ -75,6 +76,15 @@ public class HttpUtils return file.startsWith("http://") || file.startsWith("https://"); } + public static boolean startsWithHttpOrHttpsOrJalviewScheme(String file) + { + if (startsWithHttpOrHttps(file)) + { + return true; + } + return isJalviewSchemeUri(file); + } + /** * wrapper to get/post to a URL or check headers * @@ -227,14 +237,15 @@ public class HttpUtils return false; } String scheme = jalviewUri.getScheme(); - if (scheme == null || !scheme.startsWith("jalview")) + if (scheme == null || !scheme.startsWith(JALVIEWSCHEMEPREFIX)) { return false; } - return scheme.length() == 7 // jalview - || scheme.length() == 8 // jalviewX - || scheme.substring(7).equals("http") // jalviewhttp - || scheme.substring(7).equals("https"); // jalviewhttps + int jspl = JALVIEWSCHEMEPREFIX.length(); + return scheme.length() == jspl // jalview + || scheme.length() == jspl + 1 // jalviewX + || scheme.substring(jspl).equals("http") // jalviewhttp + || scheme.substring(jspl).equals("https"); // jalviewhttps } /** @@ -261,13 +272,15 @@ public class HttpUtils } String scheme = jalviewUri.getScheme(); String host = jalviewUri.getHost(); - if (host != null && host.length() > 0 - || scheme.substring(7).startsWith("http")) + if (host != null && host.length() > 0 || scheme + .substring(JALVIEWSCHEMEPREFIX.length()).startsWith("http")) { URI newUri; try { - newUri = new URI(scheme.equals("jalviewhttp") ? "http" : "https", + newUri = new URI( + scheme.equals(JALVIEWSCHEMEPREFIX + "http") ? "http" + : "https", jalviewUri.getUserInfo(), host, jalviewUri.getPort(), jalviewUri.getPath(), jalviewUri.getQuery(), jalviewUri.getFragment());