diff options
author | Andrew Azores <[email protected]> | 2013-09-26 10:25:33 -0400 |
---|---|---|
committer | Andrew Azores <[email protected]> | 2013-09-26 10:25:33 -0400 |
commit | c824b24b3c7656e6230b6c1d398a927b1225f0c2 (patch) | |
tree | dc6594b350e9583b1bda9d1be35259e03f9ce9fa /plugin/icedteanp | |
parent | 22c0eae35d290f25bfd69b937c09c10b6f961db7 (diff) |
Fix for PR1204, handling of query strings and absolute paths.
Absolute paths in resource URLs are correctly handled when appended to host
URLs and URL query strings are not removed.
* netx/net/sourceforge/jnlp/cache/ResourceUrlCreator.java:
(getVersionedUrlUsingQuery) renamed to getVersionedUrl, refactored
construction of URL
* plugin/icedteanp/java/sun/applet/PluginAppletViewer.java:
(requestPluginProxyInfo) extracted proxy URI logic.
(processProxyUri) new method for finding proxy URIs, handles absolute
resource paths correctly
* tests/netx/unit/net/sourceforge/jnlp/cache/ResourceUrlCreatorTest.java:
added tests for ResourceUrlCreator#getVersionedUrl
* tests/netx/unit/sun/applet/PluginAppletViewerTest.java: added tests for
PluginAppletViewer.processProxyUri
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/resources/AbsolutePathsAndQueryStrings.html:
new reproducer checks that absolute paths and query strings in resource
URLs are properly handled, and caching still works
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/resources/AbsolutePathsAndQueryStrings.jnlp:
same
* tests/reproducers/simple/AbsolutePathsAndQueryStrings/testcases/AbsolutePathsAndQueryStrings.java:
same
Diffstat (limited to 'plugin/icedteanp')
-rw-r--r-- | plugin/icedteanp/java/sun/applet/PluginAppletViewer.java | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java index f0c1cc5..bd4c0d5 100644 --- a/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java +++ b/plugin/icedteanp/java/sun/applet/PluginAppletViewer.java @@ -86,6 +86,7 @@ import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.SocketPermission; import java.net.URI; +import java.net.URISyntaxException; import java.net.URL; import java.net.URLConnection; import java.security.AccessController; @@ -1243,17 +1244,7 @@ public class PluginAppletViewer extends XEmbeddedFrame Long reference = getRequestIdentifier(); try { - - // there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for - // an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can - // use that, if we get back an http proxy, we fallback to DIRECT connect - - String scheme = uri.getScheme(); - String port = uri.getPort() != -1 ? ":" + uri.getPort() : ""; - if (!uri.getScheme().startsWith("http") && !uri.getScheme().equals("ftp")) - scheme = "http"; - - requestURI = UrlUtil.encode(scheme + "://" + uri.getHost() + port + "/" + uri.getPath(), "UTF-8"); + requestURI = convertUriSchemeForProxyQuery(uri); } catch (Exception e) { PluginDebug.debug("Cannot construct URL from ", uri.toString(), " ... falling back to DIRECT proxy"); OutputController.getLogger().log(OutputController.Level.ERROR_ALL,e); @@ -1283,6 +1274,21 @@ public class PluginAppletViewer extends XEmbeddedFrame return request.getObject(); } + public static String convertUriSchemeForProxyQuery(URI uri) throws URISyntaxException, UnsupportedEncodingException { + // there is no easy way to get SOCKS proxy info. So, we tell mozilla that we want proxy for + // an HTTP uri in case of non http/ftp protocols. If we get back a SOCKS proxy, we can + // use that, if we get back an http proxy, we fallback to DIRECT connect + + String scheme = uri.getScheme(); + if (!scheme.startsWith("http") && !scheme.equals("ftp")) { + scheme = "http"; + } + + URI result = new URI(scheme, uri.getUserInfo(), uri.getHost(), uri.getPort(), + uri.getPath(), uri.getQuery(), uri.getFragment()); + return UrlUtil.encode(result.toString(), "UTF-8"); + } + public static void JavaScriptFinalize(long internal) { Long reference = getRequestIdentifier(); |