/hg/release/icedtea-web-1.2: 2 new changesets
jvanek at icedtea.classpath.org
jvanek at icedtea.classpath.org
Tue Jul 3 04:52:30 PDT 2012
changeset 01ed07070c3c in /hg/release/icedtea-web-1.2
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.2?cmd=changeset;node=01ed07070c3c
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Jul 03 13:38:23 2012 +0200
Fixed behavior when encoded/characters needed encoding included in url (PR811)
changeset d5cec52b3c5b in /hg/release/icedtea-web-1.2
details: http://icedtea.classpath.org/hg/release/icedtea-web-1.2?cmd=changeset;node=d5cec52b3c5b
author: Jiri Vanek <jvanek at redhat.com>
date: Tue Jul 03 13:51:29 2012 +0200
Last hope for not downloaded resources to be verified
diffstat:
ChangeLog | 25 +++
NEWS | 2 +
netx/net/sourceforge/jnlp/cache/CacheUtil.java | 38 +++-
netx/net/sourceforge/jnlp/cache/ResourceTracker.java | 130 +++++++++++++++-
netx/net/sourceforge/jnlp/resources/Messages.properties | 4 +-
netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java | 26 +++-
6 files changed, 212 insertions(+), 13 deletions(-)
diffs (318 lines):
diff -r a49edd57b1b3 -r d5cec52b3c5b ChangeLog
--- a/ChangeLog Thu Jun 28 12:00:07 2012 -0400
+++ b/ChangeLog Tue Jul 03 13:51:29 2012 +0200
@@ -1,3 +1,28 @@
+2012-07-23 Jiri Vanek <jvanek at redhat.com>
+
+ Last hope for not downloaded resources to be verified
+ * netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java:
+ (getCodeSourceSecurity): will now try to download and verify resource
+ which was downloaded outside of netx.
+ (alreadyTried) set for memory of once tried resources to not try again
+ * NEWS: mentioned RH816592
+ * netx/net/sourceforge/jnlp/resources/Messages.properties: backported
+ necessary resources (LNoSecInstance) and (LCertFoundIn)
+
+2012-07-09 Jiri Vanek <jvanek at redhat.com>
+
+ Fixed behavior when encoded/characters needed encoding included in url
+ * NEWS: mentioned PR811
+ * netx/net/sourceforge/jnlp/cache/CacheUtil.java: (urlEquals) Enhanced
+ to be able compare encoded/decoded urls correctly.
+ (notNullUrlEquals) new method to separate comparing of individual parts of
+ url from null checks
+ * netx/net/sourceforge/jnlp/cache/ResourceTracker.java: (addResource)
+ is now encoding url if needed. (normalizeUrl) new method to encode path in
+ url of all except file protocol. (normalizeChunk) New method for encoding
+ of atomic piece.
+
+
2012-06-28 Adam Domurad <adomurad at redhat.com>
Allow passing of plugin tables and browser tables in NP_Initialize that
diff -r a49edd57b1b3 -r d5cec52b3c5b NEWS
--- a/NEWS Thu Jun 28 12:00:07 2012 -0400
+++ b/NEWS Tue Jul 03 13:51:29 2012 +0200
@@ -11,6 +11,8 @@
New in release 1.2.1 (2012-XX-XX):
* NetX
- PR898: signed applications with big jnlp-file doesn't start (webstart affect like "frozen")
+ - PR811: javaws is not handling urls with spaces (and other characters needing encoding) correctly
+ - 816592: icedtea-web not loading GeoGebra java applets in Firefox or Chrome
* Plugin
- PR863: Error passing strings to applet methods in Chromium
- PR895: IcedTea-Web searches for missing classes on each loadClass or findClass
diff -r a49edd57b1b3 -r d5cec52b3c5b netx/net/sourceforge/jnlp/cache/CacheUtil.java
--- a/netx/net/sourceforge/jnlp/cache/CacheUtil.java Thu Jun 28 12:00:07 2012 -0400
+++ b/netx/net/sourceforge/jnlp/cache/CacheUtil.java Tue Jul 03 13:51:29 2012 +0200
@@ -61,22 +61,40 @@
* ie sourceforge.net and www.sourceforge.net).
*/
public static boolean urlEquals(URL u1, URL u2) {
- if (u1 == u2)
+ if (u1 == u2) {
return true;
- if (u1 == null || u2 == null)
+ }
+ if (u1 == null || u2 == null) {
return false;
+ }
- if (!compare(u1.getProtocol(), u2.getProtocol(), true) ||
- !compare(u1.getHost(), u2.getHost(), true) ||
- //u1.getDefaultPort() != u2.getDefaultPort() || // only in 1.4
- !compare(u1.getPath(), u2.getPath(), false) ||
- !compare(u1.getQuery(), u2.getQuery(), false) ||
- !compare(u1.getRef(), u2.getRef(), false))
- return false;
- else
+ if (notNullUrlEquals(u1, u2)) {
return true;
+ }
+ try {
+ URL nu1 = ResourceTracker.normalizeUrl(u1, false);
+ URL nu2 = ResourceTracker.normalizeUrl(u2, false);
+ if (notNullUrlEquals(nu1, nu2)) {
+ return true;
+ }
+ } catch (Exception ex) {
+ //keep silent here and return false
+ }
+ return false;
}
+ private static boolean notNullUrlEquals(URL u1, URL u2) {
+ if (!compare(u1.getProtocol(), u2.getProtocol(), true)
+ || !compare(u1.getHost(), u2.getHost(), true)
+ || //u1.getDefaultPort() != u2.getDefaultPort() || // only in 1.4
+ !compare(u1.getPath(), u2.getPath(), false)
+ || !compare(u1.getQuery(), u2.getQuery(), false)
+ || !compare(u1.getRef(), u2.getRef(), false)) {
+ return false;
+ } else {
+ return true;
+ }
+ }
/**
* Caches a resource and returns a URL for it in the cache;
* blocks until resource is cached. If the resource location is
diff -r a49edd57b1b3 -r d5cec52b3c5b netx/net/sourceforge/jnlp/cache/ResourceTracker.java
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Thu Jun 28 12:00:07 2012 -0400
+++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Tue Jul 03 13:51:29 2012 +0200
@@ -24,10 +24,13 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
+import java.net.URLDecoder;
+import java.net.URLEncoder;
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ArrayList;
@@ -108,6 +111,15 @@
private static final int ERROR = Resource.ERROR;
private static final int STARTED = Resource.STARTED;
+ // normalization of url
+ private static final char PATH_DELIMITER_MARK = '/';
+ private static final String PATH_DELIMITER = "" + PATH_DELIMITER_MARK;
+ private static final char QUERY_DELIMITER_MARK = '&';
+ private static final String QUERY_DELIMITER = "" + QUERY_DELIMITER_MARK;
+ private static final char QUERY_MARK = '?';
+ private static final char HREF_MARK = '#';
+ private static final String UTF8 = "utf-8";
+
/** max threads */
private static final int maxThreads = 5;
@@ -173,7 +185,12 @@
public void addResource(URL location, Version version, DownloadOptions options, UpdatePolicy updatePolicy) {
if (location == null)
throw new IllegalArgumentException("location==null");
-
+ try {
+ location = normalizeUrl(location, JNLPRuntime.isDebug());
+ } catch (Exception ex) {
+ System.err.println("Normalization of " + location.toString() + " have failed");
+ ex.printStackTrace();
+ }
Resource resource = Resource.getResource(location, version, updatePolicy);
boolean downloaded = false;
@@ -1127,4 +1144,115 @@
}
};
+ private static String normalizeChunk(String base, boolean debug) throws UnsupportedEncodingException {
+ if (base == null) {
+ return base;
+ }
+ if ("".equals(base)) {
+ return base;
+ }
+ String result = base;
+ String ssE = URLDecoder.decode(base, UTF8);
+ // System.out.println("*" + base + "*");
+ // System.out.println("-" + ssE + "-");
+ if (base.equals(ssE)) {
+ result = URLEncoder.encode(base, UTF8);
+ if (debug) {
+ System.out.println(base + " chunk needs to be encoded => " + result);
+ }
+ } else {
+ if (debug) {
+ System.out.println(base + " chunk already encoded");
+ }
+ }
+ return result;
+ }
+
+ public static URL normalizeUrl(URL u, boolean debug) throws MalformedURLException, UnsupportedEncodingException {
+ if (u == null) {
+ return null;
+ }
+ String protocol = u.getProtocol();
+ if (protocol == null || "file".equals(protocol)) {
+ return u;
+ }
+ String file = u.getPath();
+ if (file == null) {
+ return u;
+ }
+ String host = u.getHost();
+ String ref = u.getRef();
+ int port = u.getPort();
+ String query = u.getQuery();
+ String[] qq = {};
+ if (query != null) {
+ qq = query.split(QUERY_DELIMITER);
+ }
+ String[] ss = file.split(PATH_DELIMITER);
+ int normalized = 0;
+ if (debug) {
+ System.out.println("normalizing path " + file + " in " + u.toString());
+ }
+ for (int i = 0; i < ss.length; i++) {
+ String base = ss[i];
+ String r = normalizeChunk(base, debug);
+ if (!r.equals(ss[i])) {
+ normalized++;
+ }
+ ss[i] = r;
+ }
+ if (debug) {
+ System.out.println("normalizing query " + query + " in " + u.toString());
+ }
+ for (int i = 0; i < qq.length; i++) {
+ String base = qq[i];
+ String r = normalizeChunk(base, debug);
+ if (!r.equals(qq[i])) {
+ normalized++;
+ }
+ qq[i] = r;
+ }
+ if (normalized == 0) {
+ if (debug) {
+ System.out.println("Nothing was normalized in this url");
+ }
+ return u;
+ } else {
+ if (debug) {
+ System.out.println(normalized + " chunks normalized, rejoining url");
+ }
+ }
+ StringBuilder composed = new StringBuilder("");
+ for (int i = 0; i < ss.length; i++) {
+ String string = ss[i];
+ if (ss.length <= 1 || (string != null && !"".equals(string))) {
+ composed.append(PATH_DELIMITER_MARK).append(string);
+ }
+ }
+ String composed1 = composed.toString();
+ if (query != null && !query.trim().equals("")) {
+ composed.append(QUERY_MARK);
+ for (int i = 0; i < qq.length; i++) {
+ String string = qq[i];
+ if ((string != null && !"".equals(string))) {
+ composed.append(string);
+ if (i != qq.length - 1) {
+ composed.append(QUERY_DELIMITER_MARK);
+ }
+ }
+ }
+ }
+ String composed2 = composed.substring(composed1.length() - 1);
+ if (ref != null && !ref.trim().equals("")) {
+ composed.append(HREF_MARK).append(ref);
+ }
+
+ URL result = new URL(protocol, host, port, composed.toString());
+
+ if (debug) {
+ System.out.println("normalized `" + composed1 + "` and `" + composed2 + "` in " + result.toString());
+ }
+ return result;
+
+ }
}
diff -r a49edd57b1b3 -r d5cec52b3c5b netx/net/sourceforge/jnlp/resources/Messages.properties
--- a/netx/net/sourceforge/jnlp/resources/Messages.properties Thu Jun 28 12:00:07 2012 -0400
+++ b/netx/net/sourceforge/jnlp/resources/Messages.properties Tue Jul 03 13:51:29 2012 +0200
@@ -81,7 +81,9 @@
LSignedAppJarUsingUnsignedJar=Signed application using unsigned jars.
LSignedAppJarUsingUnsignedJarInfo=The main application jar is signed, but some of the jars it is using aren't.
LSignedJNLPFileDidNotMatch=The signed JNLP file did not match the launching JNLP file.
-
+LNoSecInstance=Error: No security instance for {0}. The application may have trouble continuing
+LCertFoundIn={0} found in cacerts ({1})
+
JNotApplet=File is not an applet.
JNotApplication=File is not an application.
JNotComponent=File is not a component.
diff -r a49edd57b1b3 -r d5cec52b3c5b netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java
--- a/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Thu Jun 28 12:00:07 2012 -0400
+++ b/netx/net/sourceforge/jnlp/runtime/JNLPClassLoader.java Tue Jul 03 13:51:29 2012 +0200
@@ -167,6 +167,9 @@
/** Map of specific original (remote) CodeSource Urls to securitydesc */
private HashMap<URL, SecurityDesc> jarLocationSecurityMap =
new HashMap<URL, SecurityDesc>();
+
+ /*Set to prevent once tried-to-get resources to be tried again*/
+ private Set<URL> alreadyTried = Collections.synchronizedSet(new HashSet<URL>());
/** Loader for codebase (which is a path, rather than a file) */
private CodeBaseClassLoader codeBaseLoader;
@@ -1732,7 +1735,28 @@
*/
protected SecurityDesc getCodeSourceSecurity(URL source) {
- return jarLocationSecurityMap.get(source);
+ SecurityDesc sec=jarLocationSecurityMap.get(source);
+ if (sec == null && !alreadyTried.contains(source)) {
+ alreadyTried.add(source);
+ //try to load the jar which is requesting the permissions, but was NOT downloaded by standard way
+ if (JNLPRuntime.isDebug()) {
+ System.out.println("Application is trying to get permissions for " + source.toString() + ", which was not added by standard way. Trying to download and verify!");
+ }
+ try {
+ JARDesc des = new JARDesc(source, null, null, false, false, false, false);
+ addNewJar(des);
+ sec = jarLocationSecurityMap.get(source);
+ } catch (Throwable t) {
+ if (JNLPRuntime.isDebug()) {
+ t.printStackTrace();
+ }
+ sec = null;
+ }
+ }
+ if (sec == null){
+ System.out.println(Translator.R("LNoSecInstance",source.toString()));
+ }
+ return sec;
}
/**
More information about the distro-pkg-dev
mailing list