aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorRyan Liptak <squeek502@hotmail.com>2022-01-20 01:43:00 -0800
committerRyan Liptak <squeek502@hotmail.com>2022-02-19 15:46:23 -0800
commit83a486a064fdb7a533d2bdac6f8b4b0e42e46546 (patch)
tree8754d5db73ff186d3bc1004e6effa94c0fcf5c78 /lib/std
parentc87f79c957a74fae16931a71d4c6414f9d58acf6 (diff)
downloadzig-83a486a064fdb7a533d2bdac6f8b4b0e42e46546.tar.gz
zig-83a486a064fdb7a533d2bdac6f8b4b0e42e46546.zip
os.getenvW: Fix handling of special `=`-prefixed env vars
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/os.zig6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/std/os.zig b/lib/std/os.zig
index ade20cc671..d04a938d5c 100644
--- a/lib/std/os.zig
+++ b/lib/std/os.zig
@@ -1726,6 +1726,12 @@ pub fn getenvW(key: [*:0]const u16) ?[:0]const u16 {
while (ptr[i] != 0) {
const key_start = i;
+ // There are some special environment variables that start with =,
+ // so we need a special case to not treat = as a key/value separator
+ // if it's the first character.
+ // https://devblogs.microsoft.com/oldnewthing/20100506-00/?p=14133
+ if (ptr[key_start] == '=') i += 1;
+
while (ptr[i] != 0 and ptr[i] != '=') : (i += 1) {}
const this_key = ptr[key_start..i];