8224908: Revert: 8216553: JrtFileSystemProvider getPath(URI) omits /modules element from file path

Reviewed-by: darcy, kbarrett
This commit is contained in:
Jim Laskey 2019-05-28 16:51:28 -03:00
parent b71c30f1b8
commit 4e83c1c4dc
4 changed files with 7 additions and 61 deletions

View file

@ -190,10 +190,10 @@ public final class JrtFileSystemProvider extends FileSystemProvider {
throw new IllegalArgumentException("Fragment component present");
}
String path = uri.getPath();
if (path == null || path.charAt(0) != '/' || path.contains("..")) {
if (path == null || path.charAt(0) != '/') {
throw new IllegalArgumentException("Invalid path component");
}
return getTheFileSystem().getPath("/modules" + path);
return getTheFileSystem().getPath(path);
}
private FileSystem getTheFileSystem() {

View file

@ -25,7 +25,6 @@
package jdk.internal.jrtfs;
import java.io.File;
import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
@ -171,16 +170,7 @@ final class JrtPath implements Path {
@Override
public final URI toUri() {
try {
String p = toAbsolutePath().path;
if (!p.startsWith("/modules") || p.contains("..")) {
throw new IOError(new RuntimeException(p + " cannot be represented as URI"));
}
p = p.substring("/modules".length());
if (p.isEmpty()) {
p = "/";
}
return new URI("jrt", p, null);
return new URI("jrt", toAbsolutePath().path, null);
} catch (URISyntaxException ex) {
throw new AssertionError(ex);
}