Skip to content

Commit 9291e60

Browse files
Brian Burkhalterslowhog
authored andcommitted
8242680: Improved URI Support
Reviewed-by: alanb, rhalade
1 parent ff3e558 commit 9291e60

2 files changed

Lines changed: 9 additions & 5 deletions

File tree

src/java.base/unix/classes/sun/nio/fs/UnixUriUtils.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,12 @@ static URI toUri(UnixPath up) {
115115

116116
// trailing slash if directory
117117
if (sb.charAt(sb.length()-1) != '/') {
118-
int mode = UnixNativeDispatcher.stat(up);
119-
if ((mode & UnixConstants.S_IFMT) == UnixConstants.S_IFDIR)
120-
sb.append('/');
118+
try {
119+
up.checkRead();
120+
int mode = UnixNativeDispatcher.stat(up);
121+
if ((mode & UnixConstants.S_IFMT) == UnixConstants.S_IFDIR)
122+
sb.append('/');
123+
} catch (SecurityException ignore) { }
121124
}
122125

123126
try {

src/java.base/windows/classes/sun/nio/fs/WindowsUriSupport.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2008, 2009, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2008, 2020, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -104,8 +104,9 @@ static URI toUri(WindowsPath path) {
104104
boolean addSlash = false;
105105
if (!s.endsWith("\\")) {
106106
try {
107+
path.checkRead();
107108
addSlash = WindowsFileAttributes.get(path, true).isDirectory();
108-
} catch (WindowsException x) {
109+
} catch (SecurityException | WindowsException x) {
109110
}
110111
}
111112

0 commit comments

Comments
 (0)