Commit 8dc5d7a
committed
fix: Append to preexisting
The value of an environment variable as obtained by the facilities
in `std::env` is not always well-formed Unicode. Specifically, on
Windows the values of environment variables, like paths, are
natively UTF-16LE strings except that unpaired surrogate code
points can also occur. An `&OsStr` on Windows may accordingly not
quite be UTF-8.
When the `MSYS` variable is absent, we treat this the same as when
it is present but empty. However, as described in #1574, an `MSYS`
variable that is present but whose value contains an unpaired
surrogate would also be replaced entirely, rather than appending to
its old value.
This changes that, to instead append, retaining whatever was there
even if it was ill-formed Unicode.
An alternative change could be to panic when the old value is
ill-formed Unicode. This commit allows and appends to the old
value, rather than panicking or keeping and documenting the
previous behavior of discarding the old value, because the appended
sequence ` winsymlinks:nativestrict` is effective at causing
fixture scripts to attempt to create actual symlinks even if
the preceding code point is an unpaired Unicode high surrogate.MSYS env var even if ill-formed1 parent fbd4908 commit 8dc5d7a
1 file changed
+2
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
593 | 593 | | |
594 | 594 | | |
595 | 595 | | |
596 | | - | |
597 | | - | |
| 596 | + | |
| 597 | + | |
598 | 598 | | |
599 | 599 | | |
600 | 600 | | |
| |||
0 commit comments