diff options
| author | David Lönnhager <david.l@mullvad.net> | 2019-11-04 13:32:59 +0100 |
|---|---|---|
| committer | David Lönnhager <david.l@mullvad.net> | 2019-11-04 14:39:54 +0100 |
| commit | a520a2875fbd6d28d022c12c15a4656f914bcda2 (patch) | |
| tree | 0bc0ec3c7f7ff130905e5d2749d2897860b4a738 | |
| parent | d3466776256d37c46de3ed4457b165f3dbcb9783 (diff) | |
| download | mullvadvpn-a520a2875fbd6d28d022c12c15a4656f914bcda2.tar.xz mullvadvpn-a520a2875fbd6d28d022c12c15a4656f914bcda2.zip | |
Add workaround for PATH values with incorrect type (regular instead of expandable string)
| -rw-r--r-- | windows/nsis-plugins/src/pathedit/pathedit.cpp | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/windows/nsis-plugins/src/pathedit/pathedit.cpp b/windows/nsis-plugins/src/pathedit/pathedit.cpp index fda83d779e..09f0ddbfec 100644 --- a/windows/nsis-plugins/src/pathedit/pathedit.cpp +++ b/windows/nsis-plugins/src/pathedit/pathedit.cpp @@ -68,6 +68,21 @@ bool SysPathExists(const std::wstring &allPaths, const std::wstring &pathToFind) auto pathTokens = common::string::Tokenize(allPaths, L";"); return FindSysPath(pathTokens, pathToFind) != pathTokens.end(); } + +std::wstring ReadPathValue(const RegistryKey &pathKey) +{ + // Some applications will replace the PATH value with a regular string; + // use this type as a fallback. + try + { + return pathKey.readString(pathValName, ValueStringType::ExpandableString); + } + catch (const std::exception &) + { + return pathKey.readString(pathValName, ValueStringType::RegularString); + } +} + } // anonymous namespace // @@ -109,7 +124,7 @@ void __declspec(dllexport) NSISCALL AddSysEnvPath true, RegistryView::Force64 ); - auto path = pathRegKey->readString(pathValName, ValueStringType::ExpandableString); + std::wstring path = ReadPathValue(*pathRegKey); if (SysPathExists(path, pathToAppend)) { @@ -180,7 +195,7 @@ void __declspec(dllexport) NSISCALL RemoveSysEnvPath true, RegistryView::Force64 ); - auto path = pathRegKey->readString(pathValName, ValueStringType::ExpandableString); + std::wstring path = ReadPathValue(*pathRegKey); // remove value if it exists in PATH auto pathTokens = common::string::Tokenize(path, L";"); |
