Skip to content

Commit 4824978

Browse files
hansonrhansonr
authored andcommitted
fix for applications accessing file "./"
1 parent 3e004f5 commit 4824978

File tree

1 file changed

+11
-16
lines changed

1 file changed

+11
-16
lines changed

sources/net.sf.j2s.java.core/src/swingjs/JSUtil.java

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ private static Object getCachedFileData(String path) {
6868

6969
/**
7070
* This could be a simple String, a javajs.util.SB, or unsigned or signed bytes
71-
* depending upon the browser and the file type.
71+
* depending upon the browser and the file type.
7272
*
7373
* It will not be cached, but it might come from a cache;
7474
*
@@ -78,24 +78,19 @@ private static Object getCachedFileData(String path) {
7878
@SuppressWarnings("unused")
7979
private static Object getFileContents(Object uriOrJSFile) {
8080
if (uriOrJSFile instanceof File) {
81-
byte[] bytes = /** @j2sNative uriOrJSFile.bytes ||*/ null;
82-
if (bytes != null)
83-
return bytes;
81+
byte[] bytes = /** @j2sNative uriOrJSFile.bytes || */
82+
null;
83+
if (bytes != null)
84+
return bytes;
8485
}
8586
String uri = uriOrJSFile.toString();
8687
Object data = getCachedFileData(uri);
87-
if (data == null) {
88-
89-
// for reference -- not used in JavaScript
90-
91-
/**
92-
* @j2sNative
93-
*
94-
*/
95-
try {
96-
data = Rdr.streamToUTF8String((BufferedInputStream) new URL(uri).getContent());
97-
} catch (Exception e) {
98-
}
88+
if (data == null && !uri.startsWith("./")) {
89+
// Java applications may use "./" here
90+
try {
91+
data = Rdr.streamToUTF8String((BufferedInputStream) new URL(uri).getContent());
92+
} catch (Exception e) {
93+
}
9994
// bypasses AjaxURLConnection
10095
data = JSUtil.J2S.getFileData(uri, null, false, false);
10196
}

0 commit comments

Comments
 (0)