You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.
Currently, os.pwd / "foo/bar/baz" fails. We do this to guard against people accidentally doing os.pwd / myStringValue and accidentally getting path traversal problems and such, and for people to explicitly say os.pwd / os.SubPath(myStringValue) or os.pwd / os.RelPath(myStringValue).
But if the RHS of the / is a literal string, there is no risk, and we should allow people to say os.pwd / "foo/bar/baz" instead of the more verbose os.pwd / "foo" / "bar" / "baz". This can be done by making the implicit conversion from String to SubPath/RelPath a macro that checks whether the RHS is a literal, and if so goes through a different code path that allows it to contain multiple segments automatically
The text was updated successfully, but these errors were encountered:
lihaoyi
changed the title
Allow implicit conversions from String => os.*Path to allow multiple segments if the string is a literal
Allow implicit conversions from String => os.*Path to allow multiple segments if the string is a literal (500USD Bounty)
Sep 3, 2024
@pawelsadlo I'd be ok with non-macro implementations. The main requirement is that it only work for literal strings and that it give some kind of useful error message when used on non-literal strings
From the maintainer Li Haoyi: I'm putting a 500USD bounty on this issue, payable by bank transfer on a merged PR implementing this.
Currently,
os.pwd / "foo/bar/baz"
fails. We do this to guard against people accidentally doingos.pwd / myStringValue
and accidentally getting path traversal problems and such, and for people to explicitly sayos.pwd / os.SubPath(myStringValue)
oros.pwd / os.RelPath(myStringValue)
.But if the RHS of the
/
is a literal string, there is no risk, and we should allow people to sayos.pwd / "foo/bar/baz"
instead of the more verboseos.pwd / "foo" / "bar" / "baz"
. This can be done by making the implicit conversion fromString
toSubPath
/RelPath
a macro that checks whether the RHS is a literal, and if so goes through a different code path that allows it to contain multiple segments automaticallyThe text was updated successfully, but these errors were encountered: