< prev index next >
src/java.base/share/classes/jdk/internal/jrtfs/JrtPath.java
Print this page
@@ -23,10 +23,11 @@
* questions.
*/
package jdk.internal.jrtfs;
import java.io.File;
+import java.io.IOError;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URI;
import java.net.URISyntaxException;
@@ -168,11 +169,20 @@
}
@Override
public final URI toUri() {
try {
- return new URI("jrt", toAbsolutePath().path, null);
+ 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);
} catch (URISyntaxException ex) {
throw new AssertionError(ex);
}
}
< prev index next >