diff options
| -rw-r--r-- | CHANGELOG.md | 3 | ||||
| -rw-r--r-- | windows/nsis-plugins/src/pathedit/pathedit.cpp | 19 |
2 files changed, 20 insertions, 2 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index 6ab87cd50d..760e303df3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -42,6 +42,9 @@ Line wrap the file at 100 chars. Th ### Fixed #### Windows - Detect removal of the OpenVPN TAP adapter on reconnection attempts. +- Improve robustness in path environment variable logic in Windows installer. Handle the case + where the registry value type is incorrectly set to be a regular string rather than an expandable + string. ## [2019.9] - 2019-10-11 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";"); |
