Skip to content

Commit

Permalink
Fixes #1653. '/' works as a valid path but children don't (under wind…
Browse files Browse the repository at this point in the history
…ows).

This is actually about how java.io.File and related classes will not see
/Foo or \Foo as an absolute path.  I strategically added explicit logic
for this in our resource creation logic.  Ultimately, within the same
general vicinity we should figure out what the Windows System drive letter
is and prepend that.
enebo committed Feb 24, 2017
1 parent 32926ac commit e31f567
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/util/JRubyFile.java
Original file line number Diff line number Diff line change
@@ -129,7 +129,8 @@ private static JRubyFile createNoUnicodeConversion(String cwd, String pathname)
pathname = pathname.substring(5);
}
File internal = new JavaSecuredFile(pathname);
if (internal.isAbsolute()) {
// File and company do not seem to recognize bare \ and / on Windows as absolute. Cheat!
if (internal.isAbsolute() || Platform.IS_WINDOWS && (pathname.startsWith("/") || pathname.startsWith("\\"))) {
return new JRubyFile(internal);
}
if(cwd != null && cwd.startsWith("uri:") && !pathname.startsWith("uri:") && !pathname.contains("!/")) {

0 comments on commit e31f567

Please sign in to comment.