From: Ben Soares Date: Wed, 29 May 2024 15:11:38 +0000 (+0100) Subject: JAL-4409 Allow more URI schemes (e.g. file) to filter through to Jalview X-Git-Tag: Release_2_11_4_0~28^2~1 X-Git-Url: http://source.jalview.org/gitweb/?a=commitdiff_plain;h=fe88522a1771e72d1e21f81764b823a1f708cc1f;p=jalview.git JAL-4409 Allow more URI schemes (e.g. file) to filter through to Jalview --- diff --git a/getdown/lib/getdown-core.jar b/getdown/lib/getdown-core.jar index 61ee4e5..b2b4fae 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 8f7d6c8..149c9e6 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 d86a00f..6a0f1a1 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 dade5de..f83add3 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 @@ -1206,7 +1206,7 @@ public class Application // almost finally check the startup file arguments for (String f : _startupFiles) { - _appargs.add(HttpUtils.startsWithHttpOrHttpsOrJalviewScheme(f)?f:new File(f).getAbsolutePath()); + _appargs.add(HttpUtils.isPlausibleUri(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 c607840..44880a0 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 @@ -34,6 +34,31 @@ public class HttpUtils { public final static String JALVIEWSCHEMEPREFIX = "jalview"; + public static boolean isPlausibleUri(String s) + { + if (s == null) + { + return false; + } + if (startsWithHttpOrHttps(s) || isJalviewSchemeUri(s)) + { + return true; + } + try + { + URI u = new URI(s); + // allow file:/home/... as well as file:///home... as java copes + if (s.startsWith("file:/")) + { + return true; + } + } catch (URISyntaxException e) + { + return false; + } + return false; + } + /** * Returns true if it is possible to open an input stream at the given URL, * else false. The input stream is closed. @@ -76,15 +101,6 @@ 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 * diff --git a/j11lib/getdown-core.jar b/j11lib/getdown-core.jar index 61ee4e5..b2b4fae 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 61ee4e5..b2b4fae 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 c607840..44880a0 100644 --- a/src/jalview/util/HttpUtils.java +++ b/src/jalview/util/HttpUtils.java @@ -34,6 +34,31 @@ public class HttpUtils { public final static String JALVIEWSCHEMEPREFIX = "jalview"; + public static boolean isPlausibleUri(String s) + { + if (s == null) + { + return false; + } + if (startsWithHttpOrHttps(s) || isJalviewSchemeUri(s)) + { + return true; + } + try + { + URI u = new URI(s); + // allow file:/home/... as well as file:///home... as java copes + if (s.startsWith("file:/")) + { + return true; + } + } catch (URISyntaxException e) + { + return false; + } + return false; + } + /** * Returns true if it is possible to open an input stream at the given URL, * else false. The input stream is closed. @@ -76,15 +101,6 @@ 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 *