Skip to content

Commit

Permalink
Showing 2 changed files with 17 additions and 0 deletions.
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/util/JarResource.java
Original file line number Diff line number Diff line change
@@ -25,6 +25,12 @@ public static JarResource create(String pathname) {
// normalize path -- issue #2017
if (entryPath.startsWith("//")) entryPath = entryPath.substring(1);

// Resources will not find paths which end with "/" as a valid directory entry. We sanitize here before
// we create the resources since jar resources cache and we are normalizing the path.
if (entryPath.length() > 1 && entryPath.endsWith("/")) {
entryPath = entryPath.substring(0, entryPath.length() - 1);
}

// TODO: Do we really need to support both test.jar!foo/bar.rb and test.jar!/foo/bar.rb cases?
JarResource resource = createJarResource(jarPath, entryPath, false);

11 changes: 11 additions & 0 deletions test/jruby/test_dir.rb
Original file line number Diff line number Diff line change
@@ -243,6 +243,17 @@ def test_mkdir_within_classloader
end
end

def test_stat_trailing_slash_via_uri_classloader
jar_file = File.expand_path('../jar_with_relative_require1.jar', __FILE__)
$CLASSPATH << jar_file
source_file = "jar:file:#{jar_file}!/test/require_relative1.rb"
assert File.exist?(source_file), "test is wrong, #{source_file} doesn't even exist"
source_dir = File.dirname(source_file)
assert File.directory?(source_dir), "#{source_dir} not found"
source_dir += "/"
assert File.directory?(source_dir), "#{source_dir} claims to not be a directory"
end

# JRUBY-4983
def test_entries_unicode
utf8_dir = "testDir_1/glk\u00a9"

0 comments on commit 057fd3f

Please sign in to comment.