Skip to content

ProcessInfo.processInfo.environment returns magic shell environment vars which aren't valid #847

Closed
@jakepetroules

Description

@jakepetroules

Here's an excerpt of what ProcessInfo.processInfo.environment returns for me:

=C:=C:\Users\jakepetroules
=E:=E:\test2
=ExitCode=00000001
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\jakepetroules\AppData\Roaming

This is (apparently) because the GetEnvironmentStringsW API can return magic environment variables set by the cmd shell which aren't in fact valid environment variables.

They won't be shown by set, and the documentation doesn't say anything about these magic variables, but does say The name of an environment variable cannot include an equal sign (=).

I believe we should consider dropping any environment variable strings returned by GetEnvironmentStringsW which start with the = character, to avoid surprising behavior.

This is what Qt did back in 2013: qt/qtbase@e7a242b, maybe we should check also what some other languages/environments are doing as well, like .NET or Python.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions