Mercurial > hg > release > icedtea-web-1.3
changeset 519:ff0d07a33ad2
Ensure document-base is properly encoded.
author | Adam Domurad <adomurad@redhat.com> |
---|---|
date | Thu, 02 May 2013 13:55:23 -0400 |
parents | ded8ed9a9427 |
children | 3c5e0952d876 |
files | ChangeLog netx/net/sourceforge/jnlp/cache/ResourceTracker.java netx/net/sourceforge/jnlp/util/UrlUtils.java plugin/icedteanp/java/sun/applet/PluginAppletViewer.java |
diffstat | 4 files changed, 31 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/ChangeLog Wed Apr 17 10:15:16 2013 +0200 +++ b/ChangeLog Thu May 02 13:55:23 2013 -0400 @@ -1,3 +1,13 @@ +2013-05-02 Adam Domurad <adomurad@redhat.com> + + Ensure document-base is properly encoded. + * netx/net/sourceforge/jnlp/cache/ResourceTracker.java + (getCacheFile): Use decodeUrlAsFile instead of toURI().getPath(). + * netx/net/sourceforge/jnlp/util/UrlUtils.java + (decodeUrlAsFile): New, tolerates ill-formed URLs. + * plugin/icedteanp/java/sun/applet/PluginAppletViewer.java + (handleMessage): Don't decode documentBase + 2013-04-11 Jiri Vanek <jvanek@redhat.com> Added various self-describing tests for codebase
--- a/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Wed Apr 17 10:15:16 2013 +0200 +++ b/netx/net/sourceforge/jnlp/cache/ResourceTracker.java Thu May 02 13:55:23 2013 -0400 @@ -46,6 +46,7 @@ import net.sourceforge.jnlp.event.DownloadEvent; import net.sourceforge.jnlp.event.DownloadListener; import net.sourceforge.jnlp.runtime.JNLPRuntime; +import net.sourceforge.jnlp.util.UrlUtils; import net.sourceforge.jnlp.util.WeakList; /** @@ -394,7 +395,7 @@ return resource.localFile; if (location.getProtocol().equalsIgnoreCase("file")) { - File file = new File(location.getFile()); + File file = UrlUtils.decodeUrlAsFile(location); if (file.exists()) return file; }
--- a/netx/net/sourceforge/jnlp/util/UrlUtils.java Wed Apr 17 10:15:16 2013 +0200 +++ b/netx/net/sourceforge/jnlp/util/UrlUtils.java Thu May 02 13:55:23 2013 -0400 @@ -37,10 +37,28 @@ package net.sourceforge.jnlp.util; +import java.io.File; +import java.io.IOException; import java.net.URL; +import java.net.URLDecoder; public class UrlUtils { + /* Decode a percent-encoded URL. Catch checked exceptions and log. */ + public static URL decodeUrlQuietly(URL url) { + try { + return new URL(URLDecoder.decode(url.toString(), "utf-8")); + } catch (IOException e) { + e.printStackTrace(); + return url; + } + } + + /* Decode a URL as a file, being tolerant of URLs with mixed encoded & decoded portions. */ + public static File decodeUrlAsFile(URL url) { + return new File(decodeUrlQuietly(url).getFile()); + } + public static boolean isLocalFile(URL url) { if (url.getProtocol().equals("file") &&
--- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Wed Apr 17 10:15:16 2013 +0200 +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java Thu May 02 13:55:23 2013 -0400 @@ -478,8 +478,7 @@ String height = msgParts[2]; int spaceLocation = message.indexOf(' ', "tag".length() + 1); - String documentBase = - UrlUtil.decode(message.substring("tag".length() + 1, spaceLocation)); + String documentBase = message.substring("tag".length() + 1, spaceLocation); String tag = message.substring(spaceLocation + 1); PluginDebug.debug("Handle = ", handle, "\n",