diff options
| author | Florian Bach <leseratte10@vodafone.de> | 2020-03-14 22:27:26 +0100 |
|---|---|---|
| committer | Florian Bach <leseratte10@vodafone.de> | 2020-03-15 00:12:19 +0100 |
| commit | 3487e5037e2076754afc5796c8200e242c239256 (patch) | |
| tree | 50c1fd295bd0f26eb8dd7a34f06f12716399d6cf /Source/Core/Common/SettingsHandler.cpp | |
| parent | 15acce847d44564afcc5b49ef26171fe4c4e51d2 (diff) | |
Fix settings.txt parsing in case of weird line endings
Diffstat (limited to 'Source/Core/Common/SettingsHandler.cpp')
| -rw-r--r-- | Source/Core/Common/SettingsHandler.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/Source/Core/Common/SettingsHandler.cpp b/Source/Core/Common/SettingsHandler.cpp index 23c64f1e2a..cac968d502 100644 --- a/Source/Core/Common/SettingsHandler.cpp +++ b/Source/Core/Common/SettingsHandler.cpp @@ -41,7 +41,7 @@ void SettingsHandler::SetBytes(Buffer&& buffer) std::string SettingsHandler::GetValue(std::string_view key) const { - constexpr char delim[] = "\r\n"; + constexpr char delim[] = "\n"; std::string toFind = std::string(delim).append(key).append("="); size_t found = decoded.find(toFind); @@ -80,6 +80,14 @@ void SettingsHandler::Decrypt() str++; m_key = (m_key >> 31) | (m_key << 1); } + + // Decryption done. Now get rid of all CR in the output. + // The decoded file is supposed to contain Windows line endings + // (CR-LF), but sometimes also contains CR-LF-LF endings which + // confuse the parsing code, so let's just get rid of all CR + // line endings. + + decoded.erase(std::remove(decoded.begin(), decoded.end(), '\x0d'), decoded.end()); } void SettingsHandler::Reset() |
