Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save marktriggs/7608007 to your computer and use it in GitHub Desktop.
Save marktriggs/7608007 to your computer and use it in GitHub Desktop.
From 12b3f8764cddf147ed774078add9dd544832e685 Mon Sep 17 00:00:00 2001
From: Mark Triggs <mark@dishevelled.net>
Date: Sat, 23 Nov 2013 09:27:48 +1100
Subject: [PATCH] Modify LoadService.splitJarUrl to unescape URLs
Resolves the issue with loading 'yaml' described in #1248
---
.../main/java/org/jruby/runtime/load/LoadService.java | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/core/src/main/java/org/jruby/runtime/load/LoadService.java b/core/src/main/java/org/jruby/runtime/load/LoadService.java
index a3c02f2..4235b59 100644
--- a/core/src/main/java/org/jruby/runtime/load/LoadService.java
+++ b/core/src/main/java/org/jruby/runtime/load/LoadService.java
@@ -1392,13 +1392,21 @@ public class LoadService {
}
private String[] splitJarUrl(String loadPathEntry) {
- int idx = loadPathEntry.indexOf("!");
+ String unescaped = loadPathEntry;
+
+ try {
+ unescaped = new URI(loadPathEntry).getSchemeSpecificPart();
+ } catch (URISyntaxException e) {
+ // Fall back to using the original string
+ }
+
+ int idx = unescaped.indexOf("!");
if (idx == -1) {
- return new String[]{loadPathEntry, ""};
+ return new String[]{unescaped, ""};
}
- String filename = loadPathEntry.substring(0, idx);
- String entry = idx + 2 < loadPathEntry.length() ? loadPathEntry.substring(idx + 2) : "";
+ String filename = unescaped.substring(0, idx);
+ String entry = idx + 2 < unescaped.length() ? unescaped.substring(idx + 2) : "";
if(filename.startsWith("jar:")) {
filename = filename.substring(4);
--
1.7.10.4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment