Skip to content

Commit

Permalink
Fix settings.txt parsing in case of weird line endings
Browse files Browse the repository at this point in the history
  • Loading branch information
Leseratte10 committed Mar 14, 2020
1 parent 15acce8 commit 3487e50
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion Source/Core/Common/SettingsHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 3487e50

Please sign in to comment.