Skip to content
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

Fix regression on windows: Env var names are case insensitive #1501

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions src/vcpkg/base/system.process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ namespace vcpkg
system32_env,
"\\WindowsPowerShell\\v1.0\\");

std::unordered_set<std::string> env_strings = {
std::vector<std::string> env_strings = {
"ALLUSERSPROFILE",
"APPDATA",
"CommonProgramFiles",
Expand Down Expand Up @@ -650,19 +650,25 @@ namespace vcpkg
}
else
{
env_strings.emplace(std::move(var));
env_strings.emplace_back(std::move(var));
}
}
}

Environment env;
std::unordered_set<std::string> env_strings_uppercase;
for (auto&& env_var : env_strings)
{
env_strings_uppercase.emplace(Strings::ascii_to_uppercase(env_var));
}

for (auto&& env_var : get_environment_variables())
{
auto pos = env_var.find('=');
auto key = env_var.substr(0, pos);
if (Util::Sets::contains(env_strings, key) ||
Util::any_of(env_prefix_string, [&](auto&& group) { return Strings::starts_with(key, group); }))
if (Util::Sets::contains(env_strings_uppercase, Strings::ascii_to_uppercase(key)) ||
Util::any_of(env_prefix_string,
[&](auto&& group) { return Strings::case_insensitive_ascii_starts_with(key, group); }))
{
auto value = pos == std::string::npos ? "" : env_var.substr(pos + 1);
env.add_entry(key, value);
Expand Down
Loading