X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fjalview%2Futil%2FHttpUtils.java;fp=getdown%2Fsrc%2Fgetdown%2Fcore%2Fsrc%2Fmain%2Fjava%2Fjalview%2Futil%2FHttpUtils.java;h=44880a0e4c01f6ecb849c20cb3d41ecb2e87d866;hb=fe88522a1771e72d1e21f81764b823a1f708cc1f;hp=c607840ba5d3eed29ada95d72c64e89db4af09b3;hpb=7bb6882463062279027fa73984328edc864fd047;p=jalview.git 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 *