-
Notifications
You must be signed in to change notification settings - Fork 55
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
Flag use of Unicode less-than and greater-than characters in FilePath to be a Windows-only change #215
Flag use of Unicode less-than and greater-than characters in FilePath to be a Windows-only change #215
Conversation
sjsonnet/src/sjsonnet/Util.scala
Outdated
@@ -33,4 +33,20 @@ object Util{ | |||
new String(range.dropWhile(_ < 0).takeWhile(_ < s.length).map(s).toArray) | |||
} | |||
} | |||
|
|||
val isWindows: Boolean = System.getProperty("os.name").toLowerCase.startsWith("windows") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This matches
public static boolean isWindows = System.getProperty("os.name").toLowerCase().startsWith("windows"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Come to think of it, though, I'm wondering whether this should be lifted to Platform
to ensure it won't blow up on Scala JS.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, we need to wrap in options to avoid an NPE under ScalaJS: d745f75
See https://scastie.scala-lang.org/VuigbI2gS5G1WOnTYCdTdg for seeing some default properties in ScalaJS (look at Javascript console output after running).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for fixing this bug!
This PR fixes a regression introduced by #208
That PR aimed to fix #200, an issue where
std.extVar
failed on Windows because it tried to resolve mock paths which contained<
and>
characters which are forbidden in Windows filenames.That PR's solution was to use Unicode less-than and greater-than characters in place of ASCII
<
and>
, but that broke things for Unix/Linux platforms with a non-UTF8LANG
(see #208 (review)).In this PR, I aim to fix this by flagging the other PR's change to only occur for Windows, while continuing to use ASCII
<
and>
as before on other platforms.I also added a regression test by pinning
LANG=C
in our GitHub Actions test setup. This successfully reproduced the bug fixed in this PR, and also uncovered a minor test-only issue related to the use of default character encodings (which I've fixed by pinning the test code to UTF-8).Note that these file paths aren't actually materialized onto disk: rather, these are "placeholder / mock" paths used to indicate when jsonnet is reading from synthetic paths. In theory, we might be able to avoid the need to ever perform resolution in the first place by changing uses of these paths to be an
Either
of either an actualos.Path
or a placeholder, but that's a much larger and more invasive change than I want to make right now. Here, I've chosen to pursue a narrowly-targeted tactical fix-forward.