Skip to content

Commit d220103

Browse files
committed
fixes directory glob inside jarfile with + in filename
when you have embedded gems inside a jarfile and the filename was something like myjar-20150210+behappy.jar then the rubygems could not find those gems. Sponsored by Lookout Inc.
1 parent b6f907f commit d220103

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

core/src/main/java/org/jruby/util/JarResource.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@ public static JarResource create(String pathname) {
2222
try {
2323
// since pathname is actually an uri we need to decode any url decoded characters like %20
2424
// which happens when directory names contain spaces
25+
// but do not to decode '+' to allow '+' inside a filenames
26+
sanitized = sanitized.replace("+", "%2B");
2527
sanitized = URLDecoder.decode(sanitized, "UTF-8");
2628
} catch (IllegalArgumentException iae) {
2729
// something in the path did not decode, so it's probably not a URI

test/jar_with+.jar

431 Bytes
Binary file not shown.

test/test_load.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,13 @@ def test_loading_jar_with_leading_underscore
261261
}
262262
end
263263

264+
def test_jar_with_plus_in_name
265+
assert_in_sub_runtime %{
266+
require 'test/jar_with+.jar'
267+
Dir['test/jar_with+.jar!/*'].size == 2
268+
}
269+
end
270+
264271
# JRUBY-5045
265272
def test_cwd_plus_dotdot_jar_loading
266273
assert_equal "hi", run_in_sub_runtime(%{

0 commit comments

Comments
 (0)