Allow resources with spaces in the path.
This is in order to include a file output by unity that we have no control over.
This commit is contained in:
@@ -18,6 +18,7 @@ import java.io.InputStream;
|
|||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.PrintStream;
|
import java.io.PrintStream;
|
||||||
import java.io.RandomAccessFile;
|
import java.io.RandomAccessFile;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
@@ -57,7 +58,6 @@ import com.samskivert.util.ArrayUtil;
|
|||||||
import com.samskivert.util.RandomUtil;
|
import com.samskivert.util.RandomUtil;
|
||||||
import com.samskivert.util.RunAnywhere;
|
import com.samskivert.util.RunAnywhere;
|
||||||
import com.samskivert.util.StringUtil;
|
import com.samskivert.util.StringUtil;
|
||||||
|
|
||||||
import com.threerings.getdown.launcher.RotatingBackgrounds;
|
import com.threerings.getdown.launcher.RotatingBackgrounds;
|
||||||
import com.threerings.getdown.util.ConfigUtil;
|
import com.threerings.getdown.util.ConfigUtil;
|
||||||
import com.threerings.getdown.util.ConnectionUtil;
|
import com.threerings.getdown.util.ConnectionUtil;
|
||||||
@@ -376,7 +376,7 @@ public class Application
|
|||||||
String infix = (auxgroup == null) ? "" : ("-" + auxgroup);
|
String infix = (auxgroup == null) ? "" : ("-" + auxgroup);
|
||||||
String pfile = "patch" + infix + _version + ".dat";
|
String pfile = "patch" + infix + _version + ".dat";
|
||||||
try {
|
try {
|
||||||
URL remote = new URL(createVAppBase(_targetVersion), pfile);
|
URL remote = new URL(createVAppBase(_targetVersion), encodePath(pfile));
|
||||||
return new Resource(pfile, remote, getLocalPath(pfile), false);
|
return new Resource(pfile, remote, getLocalPath(pfile), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Failed to create patch resource path",
|
log.warning("Failed to create patch resource path",
|
||||||
@@ -398,7 +398,7 @@ public class Application
|
|||||||
|
|
||||||
String vmfile = LaunchUtil.LOCAL_JAVA_DIR + ".jar";
|
String vmfile = LaunchUtil.LOCAL_JAVA_DIR + ".jar";
|
||||||
try {
|
try {
|
||||||
URL remote = new URL(createVAppBase(_targetVersion), _javaLocation);
|
URL remote = new URL(createVAppBase(_targetVersion), encodePath(_javaLocation));
|
||||||
return new Resource(vmfile, remote, getLocalPath(vmfile), true);
|
return new Resource(vmfile, remote, getLocalPath(vmfile), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Failed to create VM resource", "vmfile", vmfile, "appbase", _appbase,
|
log.warning("Failed to create VM resource", "vmfile", vmfile, "appbase", _appbase,
|
||||||
@@ -415,7 +415,7 @@ public class Application
|
|||||||
{
|
{
|
||||||
String file = "full";
|
String file = "full";
|
||||||
try {
|
try {
|
||||||
URL remote = new URL(createVAppBase(_targetVersion), file);
|
URL remote = new URL(createVAppBase(_targetVersion), encodePath(file));
|
||||||
return new Resource(file, remote, getLocalPath(file), false);
|
return new Resource(file, remote, getLocalPath(file), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
log.warning("Failed to create full resource path",
|
log.warning("Failed to create full resource path",
|
||||||
@@ -435,7 +435,7 @@ public class Application
|
|||||||
try {
|
try {
|
||||||
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
|
String suffix = _trackingURLSuffix == null ? "" : _trackingURLSuffix;
|
||||||
String ga = getGATrackingCode();
|
String ga = getGATrackingCode();
|
||||||
return _trackingURL == null ? null : new URL(_trackingURL + event + suffix + ga);
|
return _trackingURL == null ? null : new URL(encodePath(_trackingURL + event + suffix + ga));
|
||||||
} catch (MalformedURLException mue) {
|
} catch (MalformedURLException mue) {
|
||||||
log.warning("Invalid tracking URL", "path", _trackingURL, "event", event, "error", mue);
|
log.warning("Invalid tracking URL", "path", _trackingURL, "event", event, "error", mue);
|
||||||
return null;
|
return null;
|
||||||
@@ -763,7 +763,7 @@ public class Application
|
|||||||
public URL getRemoteURL (String path)
|
public URL getRemoteURL (String path)
|
||||||
throws MalformedURLException
|
throws MalformedURLException
|
||||||
{
|
{
|
||||||
return new URL(_vappbase, path);
|
return new URL(_vappbase, encodePath(path));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -1681,6 +1681,15 @@ public class Application
|
|||||||
return appbase;
|
return appbase;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Encodes a path for use in a URL.
|
||||||
|
*/
|
||||||
|
protected static String encodePath (String path)
|
||||||
|
{
|
||||||
|
// URLEncoder is too fancy for paths, we want to keep /
|
||||||
|
return path.replace(" ", "%20");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses and returns a long. {@code value} must be non-null.
|
* Parses and returns a long. {@code value} must be non-null.
|
||||||
* @throws IOException on malformed value.
|
* @throws IOException on malformed value.
|
||||||
|
|||||||
Reference in New Issue
Block a user