Skip to content

Commit e7208f0

Browse files
committed
issue #287 -- relative path not allowed in Info.j2sPath
1 parent be50a4e commit e7208f0

File tree

5 files changed

+23
-6
lines changed

5 files changed

+23
-6
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250903235007
1+
20251014103610
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
20250903235007
1+
20251014103610
848 Bytes
Binary file not shown.

sources/net.sf.j2s.java.core/srcjs/js/j2sApplet.js

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
22

3+
// BH 2025.10.15 allowing ../../.... at the start of Info.j2sPath
34
// BH 2025.08.16 allow loading file:/// from current directory
45
// BH 2025.04.20 adds Info.coreAssets:"coreAssets.zip"
56
// BH 2025.04.18 enables Info.readyFunction for headless apps
@@ -2880,10 +2881,15 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
28802881
if (codePath.indexOf("://") < 0) {
28812882
var base = document.location.href.split("#")[0]
28822883
.split("?")[0].split("/");
2883-
if (codePath.indexOf("/") == 0)
2884+
if (codePath.indexOf("/") == 0) {
28842885
base = [ base[0], codePath.substring(1) ];
2885-
else
2886+
} else {
2887+
while (codePath.indexOf("../") == 0) {
2888+
base = base.slice(0, base.length - 1);
2889+
codePath = codePath.substring(3);
2890+
}
28862891
base[base.length - 1] = codePath;
2892+
}
28872893
codePath = base.join("/");
28882894
}
28892895
applet._j2sFullPath = codePath.substring(0, codePath.length - 1);

sources/net.sf.j2s.java.core/srcjs/swingjs2.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10686,6 +10686,7 @@ return jQuery;
1068610686
})(jQuery,document,"click mousemove mouseup touchmove touchend", "outjsmol");
1068710687
// j2sApplet.js BH = Bob Hanson hansonr@stolaf.edu
1068810688

10689+
// BH 2025.10.15 allowing ../../.... at the start of Info.j2sPath
1068910690
// BH 2025.08.16 allow loading file:/// from current directory
1069010691
// BH 2025.04.20 adds Info.coreAssets:"coreAssets.zip"
1069110692
// BH 2025.04.18 enables Info.readyFunction for headless apps
@@ -10876,6 +10877,7 @@ window.J2S = J2S = (function() {
1087610877
// null here means no conversion necessary
1087710878
"INTERNET.TEST" : "https://pubchem.ncbi.nlm.nih.gov",
1087810879
"chemapps.stolaf.edu" : null,
10880+
"zakodium.com":null,
1087910881
"cactus.nci.nih.gov" : null,
1088010882
".x3dna.org" : null,
1088110883
"rruff.geo.arizona.edu" : null,
@@ -11672,6 +11674,10 @@ if (database == "_" && J2S._serverUrl.indexOf("//your.server.here/") >= 0) {
1167211674
info.type = "POST";
1167311675
info.url = fileName.split("?POST?")[0]
1167411676
info.data = fileName.split("?POST?")[1]
11677+
if (info.data.startsWith('{"')) {
11678+
info.contentType = "application/json";
11679+
info.data = info.data.replaceAll("\n", "\\\\n");
11680+
}
1167511681
} else {
1167611682
!info.type && (info.type = "GET");
1167711683
info.url = fileName;
@@ -13561,10 +13567,15 @@ if (ev.keyCode == 9 && ev.target["data-focuscomponent"]) {
1356113567
if (codePath.indexOf("://") < 0) {
1356213568
var base = document.location.href.split("#")[0]
1356313569
.split("?")[0].split("/");
13564-
if (codePath.indexOf("/") == 0)
13570+
if (codePath.indexOf("/") == 0) {
1356513571
base = [ base[0], codePath.substring(1) ];
13566-
else
13572+
} else {
13573+
while (codePath.indexOf("../") == 0) {
13574+
base = base.slice(0, base.length - 1);
13575+
codePath = codePath.substring(3);
13576+
}
1356713577
base[base.length - 1] = codePath;
13578+
}
1356813579
codePath = base.join("/");
1356913580
}
1357013581
applet._j2sFullPath = codePath.substring(0, codePath.length - 1);

0 commit comments

Comments
 (0)