Merge pull request #8670 from Leseratte10/master

Fix settings.txt parsing in case of weird line endings
This commit is contained in:
Léo Lam 2020-03-15 14:28:26 +01:00 committed by GitHub
commit 33492e4df0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 1 deletions

View File

@ -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()