OpenJDK / jdk-updates / jdk11u
changeset 52219:ba8c53bd0099
8213429: Windows file handling redux
Reviewed-by: alanb, dfuchs, weijun, bpb, rhalade, ahgross
author | aefimov |
---|---|
date | Mon, 20 May 2019 15:57:16 +0100 |
parents | c5091c754c12 |
children | c7602effc480 |
files | src/java.base/share/classes/java/io/FilePermission.java |
diffstat | 1 files changed, 26 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/src/java.base/share/classes/java/io/FilePermission.java Wed Sep 25 07:52:58 2019 +0200 +++ b/src/java.base/share/classes/java/io/FilePermission.java Mon May 20 15:57:16 2019 +0100 @@ -366,12 +366,22 @@ this.mask = mask; if (cpath.equals("<<ALL FILES>>")) { + allFiles = true; directory = true; recursive = true; cpath = ""; return; } + // Validate path by platform's default file system + try { + String name = cpath.endsWith("*") ? cpath.substring(0, cpath.length() - 1) + "-" : cpath; + builtInFS.getPath(new File(name).getPath()); + } catch (InvalidPathException ipe) { + invalid = true; + return; + } + // store only the canonical cpath if possible cpath = AccessController.doPrivileged(new PrivilegedAction<>() { public String run() { @@ -572,19 +582,19 @@ * @return the effective mask */ boolean impliesIgnoreMask(FilePermission that) { + if (this == that) { + return true; + } + if (allFiles) { + return true; + } + if (this.invalid || that.invalid) { + return false; + } + if (that.allFiles) { + return false; + } if (FilePermCompat.nb) { - if (this == that) { - return true; - } - if (allFiles) { - return true; - } - if (this.invalid || that.invalid) { - return false; - } - if (that.allFiles) { - return false; - } // Left at least same level of wildness as right if ((this.recursive && that.recursive) != that.recursive || (this.directory && that.directory) != that.directory) { @@ -782,10 +792,10 @@ FilePermission that = (FilePermission) obj; + if (this.invalid || that.invalid) { + return false; + } if (FilePermCompat.nb) { - if (this.invalid || that.invalid) { - return false; - } return (this.mask == that.mask) && (this.allFiles == that.allFiles) && this.npath.equals(that.npath) && @@ -794,6 +804,7 @@ (this.recursive == that.recursive); } else { return (this.mask == that.mask) && + (this.allFiles == that.allFiles) && this.cpath.equals(that.cpath) && (this.directory == that.directory) && (this.recursive == that.recursive);