Skip to content


fixes directory glob inside jarfile with + in filename
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mkristian committed Feb 10, 2015
1 parent b6f907f commit d220103
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions core/src/main/java/org/jruby/util/
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ public static JarResource create(String pathname) {
try {
// since pathname is actually an uri we need to decode any url decoded characters like %20
// which happens when directory names contain spaces
// but do not to decode '+' to allow '+' inside a filenames
sanitized = sanitized.replace("+", "%2B");

This comment has been minimized.

Copy link

mkristian Feb 10, 2015

Author Member

@ratnikov do you have a better idea on how to decode in same cases and not to decode in other cases ?

This comment has been minimized.

Copy link

ratnikov Feb 10, 2015


Perhaps move the URI-fication logic to the createJarResource and try both with the value 'as' is and with a decoded value?

sanitized = URLDecoder.decode(sanitized, "UTF-8");
} catch (IllegalArgumentException iae) {
// something in the path did not decode, so it's probably not a URI
Expand Down
Binary file added test/jar_with+.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions test/test_load.rb
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ def test_loading_jar_with_leading_underscore

def test_jar_with_plus_in_name
assert_in_sub_runtime %{
require 'test/jar_with+.jar'
Dir['test/jar_with+.jar!/*'].size == 2

# JRUBY-5045
def test_cwd_plus_dotdot_jar_loading
assert_equal "hi", run_in_sub_runtime(%{
Expand Down

0 comments on commit d220103

Please sign in to comment.