Commit 7e7733d4 authored by Phillip Webb's avatar Phillip Webb

Deal with spaces in file references

Fixes gh-1169
parent 7654259f
...@@ -25,6 +25,7 @@ import java.net.URISyntaxException; ...@@ -25,6 +25,7 @@ import java.net.URISyntaxException;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLDecoder;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
...@@ -518,7 +519,8 @@ public class PropertiesLauncher extends Launcher { ...@@ -518,7 +519,8 @@ public class PropertiesLauncher extends Launcher {
} }
} }
else { else {
lib.add(0, new ExplodedArchive(new File(url.getFile()))); String filename = URLDecoder.decode(url.getFile(), "UTF-8");
lib.add(0, new ExplodedArchive(new File(filename)));
} }
} }
} }
......
...@@ -23,6 +23,7 @@ import java.lang.reflect.Method; ...@@ -23,6 +23,7 @@ import java.lang.reflect.Method;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection; import java.net.URLConnection;
import java.net.URLDecoder;
import java.net.URLStreamHandler; import java.net.URLStreamHandler;
import java.util.Map; import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
...@@ -151,7 +152,7 @@ public class Handler extends URLStreamHandler { ...@@ -151,7 +152,7 @@ public class Handler extends URLStreamHandler {
throw new IllegalStateException("Not a file URL"); throw new IllegalStateException("Not a file URL");
} }
String path = name.substring(FILE_PROTOCOL.length()); String path = name.substring(FILE_PROTOCOL.length());
File file = new File(path); File file = new File(URLDecoder.decode(path, "UTF-8"));
Map<File, JarFile> cache = rootFileCache.get(); Map<File, JarFile> cache = rootFileCache.get();
JarFile jarFile = (cache == null ? null : cache.get(file)); JarFile jarFile = (cache == null ? null : cache.get(file));
if (jarFile == null) { if (jarFile == null) {
......
...@@ -23,6 +23,7 @@ import java.io.InputStream; ...@@ -23,6 +23,7 @@ import java.io.InputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.net.URL; import java.net.URL;
import java.net.URLClassLoader; import java.net.URLClassLoader;
import java.net.URLDecoder;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
...@@ -106,7 +107,8 @@ public class ExplodedArchiveTests { ...@@ -106,7 +107,8 @@ public class ExplodedArchiveTests {
@Test @Test
public void getUrl() throws Exception { public void getUrl() throws Exception {
URL url = this.archive.getUrl(); URL url = this.archive.getUrl();
assertThat(new File(url.toURI()), equalTo(new File(this.rootFolder.toURI()))); assertThat(new File(URLDecoder.decode(url.getFile(), "UTF-8")),
equalTo(this.rootFolder));
} }
@Test @Test
......
...@@ -97,7 +97,6 @@ public class JarFileTests { ...@@ -97,7 +97,6 @@ public class JarFileTests {
assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue()); assertThat(urlClassLoader.getResource("special/\u00EB.dat"), notNullValue());
assertThat(urlClassLoader.getResource("d/9.dat"), notNullValue()); assertThat(urlClassLoader.getResource("d/9.dat"), notNullValue());
jarFile.close(); jarFile.close();
} }
@Test @Test
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment