Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: c7bad2a1e69f
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 949da5180f6d
Choose a head ref
  • 2 commits
  • 1 file changed
  • 1 contributor

Commits on Mar 23, 2017

  1. When canonicalizing classpath URIs, use a bogus root path.

    This prevents in-classloader paths from expanding using real
    filesystem paths that may resolve symlinks.
    
    Fixes #4145.
    headius committed Mar 23, 2017
    Copy the full SHA
    cbf9a7d View commit details

Commits on Mar 24, 2017

  1. Merge pull request #4543 from headius/fix-4145

    When canonicalizing classpath URIs, use a bogus root path.
    headius authored Mar 24, 2017
    Copy the full SHA
    949da51 View commit details
Showing with 19 additions and 9 deletions.
  1. +19 −9 core/src/main/java/org/jruby/RubyFile.java
28 changes: 19 additions & 9 deletions core/src/main/java/org/jruby/RubyFile.java
Original file line number Diff line number Diff line change
@@ -1638,32 +1638,42 @@ private static IRubyObject expandPathInternal(ThreadContext context, IRubyObject
int index = relativePath.indexOf("!/");
postFix = relativePath.substring(index);
relativePath = relativePath.substring(0, index);
}
else if (protocol.find()) {
} else if (protocol.find()) {
preFix = protocol.group();
int offset = protocol.end();
String extra = "";
int index = relativePath.indexOf("file://");
boolean classloaderURI = preFix.equals("uri:classloader:") || preFix.equals("classpath:");

if (index >= 0) {
index += 7; // "file://".length == 7
// chck if its "file:///"
if (relativePath.length() > index && relativePath.charAt(index) == '/') {
offset += 2; extra = "//";
}
else {
} else {
offset += 1; extra = "/";
}
} else {
if (classloaderURI && relativePath.startsWith("//", offset)) {
// on Windows "uri:classloader://home" ends up as "//home" - trying a network drive!
offset += 1; // skip one '/'
}
}
else if ( ( preFix.equals("uri:classloader:") || preFix.equals("classpath:") )
&& relativePath.startsWith("//", offset) ) {
// on Windows "uri:classloader://home" ends up as "//home" - trying a network drive!
offset += 1; // skip one '/'

relativePath = relativePath.substring(offset);

if (classloaderURI) {
String fakePrefix = "/THIS_IS_A_FAKE_PATH_FOR_JRUBY";
relativePath = canonicalizePath(fakePrefix + "/" + relativePath).substring(fakePrefix.length());
} else {
relativePath = canonicalizePath(relativePath);
}
relativePath = canonicalizePath(relativePath.substring(offset));

if (Platform.IS_WINDOWS && !preFix.contains("file:") && startsWithDriveLetterOnWindows(relativePath)) {
// this is basically for classpath:/ and uri:classloader:/
relativePath = relativePath.substring(2).replace('\\', '/');
}

return concatStrings(runtime, preFix, extra, relativePath, enc);
}