You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@geronimo.apache.org by GitBox <gi...@apache.org> on 2022/12/11 17:10:56 UTC

[GitHub] [geronimo-xbean] powerbroker commented on a diff in pull request #34: XBEAN-337 jar path with exclamation signs(!) should be resolved correctly

powerbroker commented on code in PR #34:
URL: https://github.com/apache/geronimo-xbean/pull/34#discussion_r1045267258


##########
xbean-finder/src/main/java/org/apache/xbean/finder/archive/JarArchive.java:
##########
@@ -41,22 +43,52 @@ public class JarArchive implements Archive {
     private final JarFile jar;
     private final MJarSupport mjar = new MJarSupport();
 
-    public JarArchive(ClassLoader loader, URL url) {
+    public JarArchive(ClassLoader loader, URL url){
 //        if (!"jar".equals(url.getProtocol())) throw new IllegalArgumentException("not a jar url: " + url);
 
+        this.loader = loader;
+        this.url = url;
+        File jf;
+        int idx;
+
+        /*
+         * True URL.getPath(...) wiping out protocol prefixes:
+         *
+         *  1. 'jar:file:/c:/temp/...' -> 'jar' + 'file:/c:/temp/...'
+         *  2. 'file:/c:/temp/...' -> 'file' + '/c:/temp/...'
+         *
+         *  assuming we accept 'file:/...${xxx.jar}!/' URLs
+         *      AND 'zip:file:/...!/' would be cool too, if
+         *      allowed by new URL(...)
+         */
         try {
-            this.loader = loader;
-            this.url = url;
-            URL u = url;
-
-            String jarPath = url.getFile();
-            if (jarPath.contains("!")) {
-                jarPath = jarPath.substring(0, jarPath.lastIndexOf("!"));
-                u = new URL(jarPath);
+            // Underlying JarFile(...) requires RandomAccessFile,
+            //  so only local file URLs here...
+            while(!"file".equalsIgnoreCase(url.getProtocol())) {

Review Comment:
   jar:foo:file is actually prohibited by new URL(), why not allow this impossible scenario?
   from other side, if they let e.g. tar:gz:file, this will work here and, if fail - deeper, where e.g. 'tar' format should be supported. 
   
   in general, AFAIK we are interested here in url, pointing to (available, because of possible '!'s in path) local zip file: '...file:/.../some.jar....'. i think:
   1. a File parameter, instead of URL would be appropriate
   2. extra prefixes and suffixes may cause warning, but shouldn't ruin jar access.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@geronimo.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org