< prev index next >

src/java.base/share/classes/sun/net/www/protocol/file/FileURLConnection.java

Print this page
rev 15504 : 8164705: Remove pathname canonicalization from FilePermission

@@ -39,14 +39,10 @@
 import sun.net.*;
 import sun.net.www.*;
 import java.util.*;
 import java.text.SimpleDateFormat;
 
-import sun.security.action.GetPropertyAction;
-import sun.security.action.GetIntegerAction;
-import sun.security.action.GetBooleanAction;
-
 public class FileURLConnection extends URLConnection {
 
     static String CONTENT_LENGTH = "content-length";
     static String CONTENT_TYPE = "content-type";
     static String TEXT_PLAIN = "text/plain";

@@ -222,12 +218,17 @@
         if (permission == null) {
             String decodedPath = ParseUtil.decode(url.getPath());
             if (File.separatorChar == '/') {
                 permission = new FilePermission(decodedPath, "read");
             } else {
+                // decode could return /c:/x/y/z.
+                if (decodedPath.length() > 2 && decodedPath.charAt(0) == '/'
+                        && decodedPath.charAt(2) == ':') {
+                    decodedPath = decodedPath.substring(1);
+                }
                 permission = new FilePermission(
-                        decodedPath.replace('/',File.separatorChar), "read");
+                        decodedPath.replace('/', File.separatorChar), "read");
             }
         }
         return permission;
     }
 }
< prev index next >