aboutsummaryrefslogtreecommitdiffstats
path: root/netx/net/sourceforge/jnlp/util/UrlUtils.java
diff options
context:
space:
mode:
authorAdam Domurad <[email protected]>2013-06-05 15:12:01 -0400
committerAdam Domurad <[email protected]>2013-06-05 15:12:01 -0400
commit6b9db3b5496e986d9cbe16f94d65c6bb49aa6df7 (patch)
tree560fe41682dc8ea36843759d3de3402532131170 /netx/net/sourceforge/jnlp/util/UrlUtils.java
parentd529b383c65853c4c02276bd3eab2988b5a5370b (diff)
Fix PR1465 - java.io.FileNotFoundException while trying to download a JAR file
Diffstat (limited to 'netx/net/sourceforge/jnlp/util/UrlUtils.java')
-rw-r--r--netx/net/sourceforge/jnlp/util/UrlUtils.java15
1 files changed, 14 insertions, 1 deletions
diff --git a/netx/net/sourceforge/jnlp/util/UrlUtils.java b/netx/net/sourceforge/jnlp/util/UrlUtils.java
index af36a9c..73d896a 100644
--- a/netx/net/sourceforge/jnlp/util/UrlUtils.java
+++ b/netx/net/sourceforge/jnlp/util/UrlUtils.java
@@ -86,16 +86,29 @@ public class UrlUtils {
}
}
+ /* Use the URI syntax check of 'toURI' to see if it matches RFC2396.
+ * See http://www.ietf.org/rfc/rfc2396.txt */
+ public static boolean isValidRFC2396Url(URL url) {
+ try {
+ url.toURI();
+ return true;
+ } catch (URISyntaxException e) {
+ return false;
+ }
+ }
+
/* Ensure a URL is properly percent-encoded.
* Certain usages require local-file URLs to be encoded, eg for code-base & document-base. */
public static URL normalizeUrl(URL url, boolean encodeFileUrls) throws MalformedURLException, UnsupportedEncodingException, URISyntaxException {
if (url == null) {
return null;
}
+
String protocol = url.getProtocol();
boolean shouldEncode = (encodeFileUrls || !"file".equals(protocol));
- if (protocol == null || !shouldEncode || url.getPath() == null) {
+ // PR1465: We should not call 'URLDecoder.decode' on RFC2396-compliant URLs
+ if (protocol == null || !shouldEncode || url.getPath() == null || isValidRFC2396Url(url)) {
return url;
}