From 822aa88e5d60d4e37e9776924ab993000bf821c9 Mon Sep 17 00:00:00 2001 From: Ben Soares Date: Wed, 24 Jan 2024 16:11:35 +0000 Subject: [PATCH] JAL-4374 source changes for getdown to clone URI and change scheme. Also added jalview://relativepath/... --- .../com/threerings/getdown/data/Application.java | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) 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 435ebbd..83a10ed 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 @@ -1129,24 +1129,29 @@ public class Application if (jalviewUri != null) { String scheme = jalviewUri.getScheme(); if (scheme != null && (scheme.equals("jalview") || scheme.equals("jalviews"))) { - boolean https = jalviewUri.getScheme().equals("jalviews"); String host = jalviewUri.getHost(); - int port = jalviewUri.getPort(); String file = jalviewUri.getPath(); String ref = jalviewUri.getFragment(); String query = jalviewUri.getQuery(); _appargs.clear(); - if (host != null && host.length() > 0) { - URL newUrl = new URL( - (https?"https":"http") - + "://" - + host - + (port > -1? String.valueOf(port) : "") - + jalviewUri.getRawPath() - + (query != null && query.length() > 0 ? "?" + jalviewUri.getRawQuery() : "") + if (host.equals("relativepath") && file != null && file.startsWith("/") && !file.contains("/../")) { + // remove 'URI-necessary' leading slash if host is 'relativepath' + // but don't allow relative paths with a '..' folder in it. + file = file.substring(1); + _appargs.add(file); + } else if (host != null && host.length() > 0) { + boolean https = jalviewUri.getScheme().equals("jalviews"); + URI httpUri = new URI( + https?"https":"http", + jalviewUri.getUserInfo(), + jalviewUri.getHost(), + jalviewUri.getPort(), + jalviewUri.getPath(), + jalviewUri.getQuery(), + jalviewUri.getFragment() ); - _appargs.add(newUrl.toString()); + _appargs.add(httpUri.toASCIIString()); } else { _appargs.add(file); } @@ -1156,16 +1161,19 @@ public class Application for (String refArg : refArgs) { if (refArg.startsWith("jvmmempc=")) { jvmmempc = refArg.substring(9); + log.info("Found 'jvmmempc' arg '"+refArg+"'"); continue; } if (refArg.startsWith("jvmmemmax=")) { jvmmemmax = refArg.substring(10); + log.info("Found 'jvmmemmax' arg '"+refArg+"'"); continue; } - _appargs.add(URLDecoder.decode(refArg, "UTF-8")); + String arg = URLDecoder.decode(refArg, "UTF-8"); + log.info("Adding apparg '"+arg+"'"); + _appargs.add(arg); } } - } } } catch (URISyntaxException e) { -- 1.7.10.2