Skip to content

Commit 3e8e24d

Browse files
authored
Merge pull request #389 from lherschi/windows_tests_fail_since_Cve181Cve182Cve185_fixes
Fix for the following failed test on Windows
2 parents de7d672 + a1447ec commit 3e8e24d

File tree

3 files changed

+11
-10
lines changed

3 files changed

+11
-10
lines changed

core/src/main/java/net/sourceforge/jnlp/JNLPFile.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,10 @@ public JNLPFile(final URL location, final VersionString version, final ParserSet
282282
* @throws ParseException if the JNLP file was invalid
283283
*/
284284
protected JNLPFile(final URL location, final VersionString version, final ParserSettings settings, final UpdatePolicy policy, final URL forceCodebase) throws IOException, ParseException {
285-
InputStream input = openURL(location, version, policy);
286285
this.parserSettings = settings;
287-
parse(input, location, forceCodebase);
286+
try (InputStream input = openURL(location, version, policy)) {
287+
parse(input, location, forceCodebase);
288+
}
288289

289290
//Downloads the original jnlp file into the cache if possible
290291
//(i.e. If the jnlp file being launched exist locally, but it

core/src/main/java/net/sourceforge/jnlp/cache/CacheUtil.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ public static File urlToPath(URL location, String subdir) {
703703
path.append(location.getPort());
704704
path.append(File.separatorChar);
705705
}
706-
String locationPath = location.getPath().replace('/', File.separatorChar);
706+
String locationPath = location.getPath();
707707
String query = "";
708708
if (location.getQuery() != null) {
709709
query = location.getQuery();
@@ -723,7 +723,7 @@ public static File urlToPath(URL location, String subdir) {
723723
throw new RuntimeException(ex);
724724
}
725725
} else {
726-
path.append(locationPath);
726+
path.append(locationPath.replace('/', File.separatorChar));
727727
if (location.getQuery() != null && !location.getQuery().trim().isEmpty()) {
728728
path.append(".").append(location.getQuery());
729729
}

core/src/test/java/net/sourceforge/jnlp/cache/CacheUtilTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,46 +90,46 @@ public void testUrlToPathLonger256NoSuffix() throws Exception {
9090
}
9191

9292
@Test
93-
public void tesPathUpNoGoBasic() throws Exception {
93+
public void testPathUpNoGoBasic() throws Exception {
9494
final URL u = new URL("https://example.com/applet/../my.jar");
9595
final File expected = new File("/tmp/https/example.com/abca4723622ed60db3dea12cbe2402622a74f7a49b73e23b55988e4eee5ded.jar");
9696
File r = CacheUtil.urlToPath(u, "/tmp/");
9797
Assert.assertEquals(expected, r);
9898
}
9999

100100
@Test
101-
public void tesPathUpNoGoBasicLong() throws Exception {
101+
public void testPathUpNoGoBasicLong() throws Exception {
102102
final URL u = new URL("https://example.com/applet/../my.jar.q_SlNFU1NJT05JRD02OUY1ODVCNkJBOTM1NThCQjdBMTA5RkQyNDZEQjEwRi5wcm9kX3RwdG9tY2F0MjE1X2p2bTsgRW50cnVzdFRydWVQYXNzUmVkaXJlY3RVcmw9Imh0dHBzOi8vZWZzLnVzcHRvLmdvdi9FRlNXZWJVSVJlZ2lzdGVyZWQvRUZTV2ViUmVnaXN0ZXJlZCI7IFRDUFJPRFBQQUlSc2Vzc2lvbj02MjIxMjk0MTguMjA0ODAuMDAwMA\"");
103103
final File expected = new File("/tmp/https/example.com/ec97413e3f6eee8215ecc8375478cc1ae5f44f18241b9375361d5dfcd7b0ec");
104104
File r = CacheUtil.urlToPath(u, "/tmp/");
105105
Assert.assertEquals(expected, r);
106106
}
107107

108108
@Test
109-
public void tesPathUpNoGoBasic2() throws Exception {
109+
public void testPathUpNoGoBasic2() throws Exception {
110110
final URL u = new URL("https://example.com/../my.jar");
111111
final File expected = new File("/tmp/https/example.com/eb1a56bed34523dbe7ad84d893ebc31a8bbbba9ce3f370e42741b6a5f067c140.jar");
112112
File r = CacheUtil.urlToPath(u, "/tmp/");
113113
Assert.assertEquals(expected, r);
114114
}
115115

116116
@Test
117-
public void tesPathUpNoGoBasicEvil() throws Exception {
117+
public void testPathUpNoGoBasicEvil() throws Exception {
118118
final URL u = new URL("https://example.com/../../my.jar");
119119
final File expected = new File("/tmp/https/example.com/db464f11d68af73e37eefaef674517b6be23f0e4a5738aaee774ecf5b58f1bfc.jar");
120120
File r = CacheUtil.urlToPath(u, "/tmp/");
121121
Assert.assertEquals(expected, r);
122122
}
123123

124124
@Test
125-
public void tesPathUpNoGoBasicEvil2() throws Exception {
125+
public void testPathUpNoGoBasicEvil2() throws Exception {
126126
final URL u = new URL("https://example.com:99/../../../my.jar");
127127
final File expected = new File("/tmp/https/example.com/99/95401524c345e0d554d4d77330e86c98a77b9bb58a0f93094204df446b356.jar");
128128
File r = CacheUtil.urlToPath(u, "/tmp/");
129129
Assert.assertEquals(expected, r);
130130
}
131131
@Test
132-
public void tesPathUpNoGoBasicEvilest() throws Exception {
132+
public void testPathUpNoGoBasicEvilest() throws Exception {
133133
final URL u = new URL("https://example2.com/something/../../../../../../../../../../../my.jar");
134134
final File expected = new File("/tmp/https/example2.com/a8df64388f5b84d5f635e4d6dea5f4d2f692ae5381f8ec6736825ff8d6ff2c0.jar");
135135
File r = CacheUtil.urlToPath(u, "/tmp/");

0 commit comments

Comments
 (0)