-
Notifications
You must be signed in to change notification settings - Fork 50
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
IO.relativize is broken when base contains ".." #182
Comments
eed3si9n
added a commit
to eed3si9n/io
that referenced
this issue
Sep 27, 2018
Fixes sbt#182 The inconsisnt behavior in JDK 11 reported in sbt#85 exposed that `IO.relativize` is currently incorrect. The IOSpec states ```scala IO.relativize(relativeRootDir, nestedFile).map(file) shouldBe Some(file("../../meh.file")) ``` however, given that the base directory is `/tmp/io-relativize/inside-dir/..` and that the target to be relativized is `/tmp/io-relativize/meh.file`, the correct answer should be `"meh.file"`, not `"../../meh.file"`. This fixes the problem by avoiding the call to `getCanonicalFile`, which has the side effect of resolving symbolic links.
Merged
eed3si9n
added a commit
to eed3si9n/io
that referenced
this issue
Sep 27, 2018
Fixes sbt#182 The inconsisnt behavior in JDK 11 reported in sbt#85 exposed that `IO.relativize` is currently incorrect. The IOSpec states ```scala IO.relativize(relativeRootDir, nestedFile).map(file) shouldBe Some(file("../../meh.file")) ``` however, given that the base directory is `/tmp/io-relativize/inside-dir/..` and that the target to be relativized is `/tmp/io-relativize/meh.file`, the correct answer should be `"meh.file"`, not `"../../meh.file"`. This fixes the problem by avoiding the call to `getCanonicalFile`, which has the side effect of resolving symbolic links.
eed3si9n
added a commit
to eed3si9n/io
that referenced
this issue
Sep 28, 2018
Fixes sbt#182 The inconsisnt behavior in JDK 11 reported in sbt#85 exposed that `IO.relativize` is currently incorrect. The IOSpec states ```scala IO.relativize(relativeRootDir, nestedFile).map(file) shouldBe Some(file("../../meh.file")) ``` however, given that the base directory is `/tmp/io-relativize/inside-dir/..` and that the target to be relativized is `/tmp/io-relativize/meh.file`, the correct answer should be `"meh.file"`, not `"../../meh.file"`. This fixes the problem by avoiding the call to `getCanonicalFile`, which has the side effect of resolving symbolic links.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The inconsisnt behavior in JDK 11 reported in #85 exposed that
IO.relativize
is currently incorrect.steps
Given that the base directory is
/tmp/io-relativize/inside-dir/..
and that the target to be relativized is/tmp/io-relativize/meh.file
, IOSpec statesproblem
Some(file("../../meh.file"))
is incorrect.expectation
Some("meh.file")
notes
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#isAbsolute:
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/io/File.html#getCanonicalPath():
https://docs.oracle.com/en/java/javase/11/docs/api/java.base/java/nio/file/Path.html#normalize()
See also #175
The text was updated successfully, but these errors were encountered: