diff options
-rw-r--r-- | ChangeLog | 11 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/Parser.java | 21 | ||||
-rw-r--r-- | netx/net/sourceforge/jnlp/ResourcesDesc.java | 13 | ||||
-rw-r--r-- | tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java | 19 |
4 files changed, 44 insertions, 20 deletions
@@ -1,5 +1,16 @@ 2013-11-26 Jiri Vanek <[email protected]> + Reverted "fix to ManifestedJar1Test cases", better manifestedjar tests, + added srtict test + * netx/net/sourceforge/jnlp/Parser.java: added indentation, fixes + condition in strict base check + * netx/net/sourceforge/jnlp/ResourcesDesc.java: revertedt recently added throw + * tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java: + (manifestedJar1main2mainNoAppDesc) adapted and + (manifestedJar1main2mainNoAppDescStrict) added + +2013-11-26 Jiri Vanek <[email protected]> + * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: (getManifestAttribute) added check for null manifest to prevent npe. * tests/netx/unit/net/sourceforge/jnlp/runtime/JNLPClassLoaderTest.java: diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java index 310b306..4043fa6 100644 --- a/netx/net/sourceforge/jnlp/Parser.java +++ b/netx/net/sourceforge/jnlp/Parser.java @@ -250,13 +250,13 @@ class Parser { Node resources[] = getChildNodes(parent, "resources"); // ensure that there are at least one information section present - if (resources.length == 0 && !j2se) + if (resources.length == 0 && !j2se) { throw new ParseException(R("PNoResources")); - + } // create objects from the resources sections - for (int i = 0; i < resources.length; i++) + for (int i = 0; i < resources.length; i++) { result.add(getResourcesDesc(resources[i], j2se)); - + } return result; } @@ -302,9 +302,11 @@ class Parser { // check for duplicate main entries if (jar.isMain()) { - if (mainFlag == true) - if (strict) + if (mainFlag == true) { + if (strict) { throw new ParseException(R("PTwoMains")); + } + } mainFlag = true; } @@ -1073,10 +1075,11 @@ class Parser { URL result = new URL(base, href); // check for going above the codebase - if (!result.toString().startsWith(base.toString())) - if (strict) + if (!result.toString().startsWith(base.toString()) && !base.toString().startsWith(result.toString())){ + if (strict) { throw new ParseException(R("PUrlNotInCodebase", node.getNodeName(), href, base)); - + } + } return result; } diff --git a/netx/net/sourceforge/jnlp/ResourcesDesc.java b/netx/net/sourceforge/jnlp/ResourcesDesc.java index a63c3b0..0726851 100644 --- a/netx/net/sourceforge/jnlp/ResourcesDesc.java +++ b/netx/net/sourceforge/jnlp/ResourcesDesc.java @@ -72,19 +72,10 @@ public class ResourcesDesc { } public static JARDesc getMainJAR(List<JARDesc> jars) { - JARDesc markedMain = null; for (JARDesc jar : jars) { if (jar.isMain()) { - if (markedMain == null){ - markedMain = jar; - } else { - //more then one main jar specified. It stinks. Return null to die later null; - throw new RuntimeException("Multiple main JARs specified, refusing to continue."); - } - } - } - if (markedMain!=null){ - return markedMain; + return jar; + } } if (jars.size() > 0) { diff --git a/tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java b/tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java index 8b36dd9..7558585 100644 --- a/tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java +++ b/tests/reproducers/simple/ManifestedJar1/testcases/ManifestedJar1Test.java @@ -35,9 +35,11 @@ obligated to do so. If you do not wish to do so, delete this exception statement from your version. */ +import java.util.Arrays; import net.sourceforge.jnlp.ProcessResult; import net.sourceforge.jnlp.ServerAccess; import net.sourceforge.jnlp.annotations.Bug; +import net.sourceforge.jnlp.runtime.Translator; import org.junit.Assert; import org.junit.Test; @@ -154,15 +156,32 @@ public class ManifestedJar1Test { /** * * Two jars, both with manifest, sboth with main tag, no app desc + * first jar is taken * */ @Test public void manifestedJar1main2mainNoAppDesc() throws Exception { String id = "ManifestedJar-1main2mainNoAppDesc"; ProcessResult pr = server.executeJavawsHeadless(null, "/" + id + ".jnlp"); + assertManifestedJar1(id, pr); + assertNotManifestedJar2(id, pr); + assertNotDead(id, pr); + } + + /** + * + * Two jars, both with manifest, sboth with main tag, no app desc + * two main jars reported + * + */ + @Test + public void manifestedJar1main2mainNoAppDescStrict() throws Exception { + String id = "ManifestedJar-1main2mainNoAppDesc"; + ProcessResult pr = server.executeJavawsHeadless(Arrays.asList(new String[]{"-strict"}), "/" + id + ".jnlp"); assertNotManifestedJar1(id, pr); assertNotManifestedJar2(id, pr); assertNotDead(id, pr); + Assert.assertTrue(pr.stderr.contains(Translator.R("PTwoMains")) || pr.stdout.contains(Translator.R("PTwoMains"))); } /** |