Disallow more unsafe string->path conversions allowed by path append operators
Add more fs::path operator/ and operator+ overloads to prevent unsafe string->path conversions on Windows that would cause strings to be decoded according to the current Windows locale & code page instead of the correct string encoding. Update application code to deal with loss of implicit string->path conversions by calling fs::u8path or fs::PathFromString explicitly, or by just changing variable types from std::string to fs::path to avoid conversions altoghther, or make them happen earlier. In all cases, there's no change in behavior either (1) because strings only contained ASCII characters and would be decoded the same regardless of what encoding was used, or (2) because of the 1:1 mapping between paths and strings using the PathToString and PathFromString functions. Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com>
This commit is contained in:
1 parent
7a4ac713aa
commit
f64aa9c411
18 files changed
+83
-59
No files matched your search
+2
-2
@@ -508,7 +508,7 @@ fs::path static StartupShortcutPath()
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin.lnk";
|
||||
if (chain == CBaseChainParams::TESTNET) // Remove this special case when CBaseChainParams::TESTNET = "testnet4"
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / "Bitcoin (testnet).lnk";
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / strprintf("Bitcoin (%s).lnk", chain);
|
||||
return GetSpecialFolderPath(CSIDL_STARTUP) / fs::u8path(strprintf("Bitcoin (%s).lnk", chain));
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
@@ -589,7 +589,7 @@ fs::path static GetAutostartFilePath()
|
||||
std::string chain = gArgs.GetChainName();
|
||||
if (chain == CBaseChainParams::MAIN)
|
||||
return GetAutostartDir() / "bitcoin.desktop";
|
||||
return GetAutostartDir() / strprintf("bitcoin-%s.desktop", chain);
|
||||
return GetAutostartDir() / fs::u8path(strprintf("bitcoin-%s.desktop", chain));
|
||||
}
|
||||
|
||||
bool GetStartOnSystemStartup()
|
||||
|
||||
Reference in new issue
Block a user