aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaad Mohammad <[email protected]>2012-11-13 11:04:38 -0500
committerSaad Mohammad <[email protected]>2012-11-13 11:04:38 -0500
commit05dce02a240c914e9dba64cc0625a5e308cb16a0 (patch)
treebf432cf01b1e52381e07b5818a2d33c84a9d2708
parent07debbc4fcc25b31d0231230ff2093926580129e (diff)
Fix PR1166: Embedded JNLP File is not supported in applet tag
-rw-r--r--ChangeLog15
-rw-r--r--NEWS1
-rw-r--r--configure.ac1
-rw-r--r--netx/net/sourceforge/jnlp/JNLPFile.java15
-rw-r--r--netx/net/sourceforge/jnlp/Parser.java11
-rw-r--r--netx/net/sourceforge/jnlp/PluginBridge.java26
6 files changed, 65 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index 056087e..c5f7b0e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,20 @@
2012-11-13 Saad Mohammad <[email protected]>
+ Fix PR1166: Embedded JNLP File is not supported in applet tag.
+ * configure.ac: Checks for sun.misc.BASE64Decoder.
+ * NEWS: Added entry for PR1166.
+ * netx/net/sourceforge/jnlp/JNLPFile.java (JNLPFile):
+ New constructor which accepts inputstream of jnlp file and a
+ specified codebase.
+ * netx/net/sourceforge/jnlp/Parser.java (Parser): If parsing of
+ codebase fails, it will overwrite the codebase with the one passed
+ in through parameters.
+ * netx/net/sourceforge/jnlp/PluginBridge.java:
+ (PluginBridge) Supports embedded jnlp file.
+ (decodeBase64String) Decodes Base64 strings to byte array.
+
+2012-11-13 Saad Mohammad <[email protected]>
+
Added unit tests for PR1166.
* tests/netx/unit/net/sourceforge/jnlp/JNLPFileTest.java:
Tests the JNLPFile constructor that accepts an InputStream and an alternative codebase.
diff --git a/NEWS b/NEWS
index 6a5c05b..2a3d7e4 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ New in release 1.4 (2012-XX-XX):
- PR1027: DownloadService is not supported by IcedTea-Web
* Plugin
- PR1106: Buffer overflow in plugin table-
+ - PR1166: Embedded JNLP File is not supported in applet tag
* Common
- PR1049: Extension jnlp's signed jar with the content of only META-INF/* is considered
- PR955: regression: SweetHome3D fails to run
diff --git a/configure.ac b/configure.ac
index 8517687..b1da7bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -77,6 +77,7 @@ IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_JAR_URLJARFILE, [sun.net.www.protocol.ja
IT_CHECK_FOR_CLASS(SUN_NET_WWW_PROTOCOL_JAR_URLJARFILECALLBACK, [sun.net.www.protocol.jar.URLJarFileCallBack])
IT_CHECK_FOR_CLASS(SUN_AWT_X11_XEMBEDDEDFRAME, [sun.awt.X11.XEmbeddedFrame])
IT_CHECK_FOR_CLASS(SUN_MISC_REF, [sun.misc.Ref])
+IT_CHECK_FOR_CLASS(SUN_MISC_BASE64DECODER, [sun.misc.BASE64Decoder])
IT_CHECK_FOR_CLASS(COM_SUN_JNDI_TOOLKIT_URL_URLUTIL, [com.sun.jndi.toolkit.url.UrlUtil])
IT_CHECK_FOR_CLASS(SUN_APPLET_APPLETIMAGEREF, [sun.applet.AppletImageRef])
IT_CHECK_FOR_APPLETVIEWERPANEL_HOLE
diff --git a/netx/net/sourceforge/jnlp/JNLPFile.java b/netx/net/sourceforge/jnlp/JNLPFile.java
index 137bfff..26bc806 100644
--- a/netx/net/sourceforge/jnlp/JNLPFile.java
+++ b/netx/net/sourceforge/jnlp/JNLPFile.java
@@ -251,7 +251,20 @@ public class JNLPFile {
* @throws ParseException if the JNLP file was invalid
*/
public JNLPFile(InputStream input, boolean strict) throws ParseException {
- parse(Parser.getRootNode(input), strict, null, null);
+ this(input, null, strict);
+ }
+
+ /**
+ * Create a JNLPFile from an input stream.
+ *
+ * @param input input stream of JNLP file.
+ * @param codebase codebase to use if not specified in JNLP file..
+ * @param strict whether to enforce the spec rules
+ * @throws IOException if an IO exception occurred
+ * @throws ParseException if the JNLP file was invalid
+ */
+ public JNLPFile(InputStream input, URL codebase, boolean strict) throws ParseException {
+ parse(Parser.getRootNode(input), strict, null, codebase);
}
/**
diff --git a/netx/net/sourceforge/jnlp/Parser.java b/netx/net/sourceforge/jnlp/Parser.java
index d24c0fd..a825a5b 100644
--- a/netx/net/sourceforge/jnlp/Parser.java
+++ b/netx/net/sourceforge/jnlp/Parser.java
@@ -143,9 +143,16 @@ class Parser {
// JNLP tag information
this.spec = getVersion(root, "spec", "1.0+");
- this.codebase = addSlash(getURL(root, "codebase", base));
- if (this.codebase == null) // We only override it if it is not specified.
+
+ try {
+ this.codebase = addSlash(getURL(root, "codebase", base));
+ } catch (ParseException e) {
+ //If parsing fails, continue by overriding the codebase with the one passed in
+ }
+
+ if (this.codebase == null) // Codebase is overwritten if codebase was not specified in file or if parsing of it failed
this.codebase = codebase;
+
this.base = (this.codebase != null) ? this.codebase : base; // if codebase not specified use default codebase
fileLocation = getURL(root, "href", this.base);
diff --git a/netx/net/sourceforge/jnlp/PluginBridge.java b/netx/net/sourceforge/jnlp/PluginBridge.java
index c7b8f28..37b72e6 100644
--- a/netx/net/sourceforge/jnlp/PluginBridge.java
+++ b/netx/net/sourceforge/jnlp/PluginBridge.java
@@ -22,7 +22,10 @@
package net.sourceforge.jnlp;
+import java.io.ByteArrayInputStream;
import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
import java.net.URL;
import java.net.MalformedURLException;
import java.util.HashSet;
@@ -32,6 +35,8 @@ import java.util.ArrayList;
import java.util.Map;
import java.util.Set;
+import sun.misc.BASE64Decoder;
+
import net.sourceforge.jnlp.runtime.JNLPRuntime;
/**
@@ -96,7 +101,18 @@ public class PluginBridge extends JNLPFile {
// Use codeBase as the context for the URL. If jnlp_href's
// value is a complete URL, it will replace codeBase's context.
URL jnlp = new URL(codeBase, atts.get("jnlp_href"));
- JNLPFile jnlpFile = jnlpCreator.create(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), codeBase);
+ JNLPFile jnlpFile = null;
+
+ if (atts.containsKey("jnlp_embedded")) {
+ InputStream jnlpInputStream = new ByteArrayInputStream(decodeBase64String(atts.get("jnlp_embedded")));
+ jnlpFile = new JNLPFile(jnlpInputStream, codeBase, false);
+ } else {
+ jnlpFile = jnlpCreator.create(jnlp, null, false, JNLPRuntime.getDefaultUpdatePolicy(), codeBase);
+ }
+
+ if (jnlpFile.isApplet())
+ main = jnlpFile.getApplet().getMainClass();
+
Map<String, String> jnlpParams = jnlpFile.getApplet().getParameters();
info = jnlpFile.info;
@@ -349,4 +365,12 @@ public class PluginBridge extends JNLPFile {
public boolean isInstaller() {
return false;
}
+
+ /**
+ * Returns the decoded BASE64 string
+ */
+ static byte[] decodeBase64String(String encodedString) throws IOException {
+ BASE64Decoder base64 = new BASE64Decoder();
+ return base64.decodeBuffer(encodedString);
+ }
}