Skip to content

Commit

Permalink
Increased the resilience of constructing jar file paths - should now …
Browse files Browse the repository at this point in the history
…tolerate whitespaces in paths etc.
  • Loading branch information
huntc committed Jun 16, 2013
1 parent c2dd16e commit 05e8b4c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/main/java/org/webjars/WebJarAssetLocator.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import java.io.File;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collection;
Expand Down Expand Up @@ -101,13 +102,15 @@ private static Set<String> getAssetPaths(final Pattern filterExpr,
final Set<String> paths = listFiles(file, filterExpr);
assetPaths.addAll(paths);
} else if ("jar".equals(url.getProtocol())) {
final JarFile file;
final JarFile jarFile;
try {
file = new JarFile(url.getPath().substring(5, url.getPath().indexOf("!")));
final String path = url.getPath();
final File file = new File(URI.create(path.substring(0, path.indexOf("!"))));
jarFile = new JarFile(file);
} catch (IOException e) {
throw new RuntimeException(e);
}
final Enumeration<JarEntry> entries = file.entries();
final Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) {
final JarEntry entry = entries.nextElement();
final String assetPathCandidate = entry.getName();
Expand Down

0 comments on commit 05e8b4c

Please sign in to comment.