From 0153761de003f1d33e20f6d0cd56ac3c98c91314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Rydg=C3=A5rd?= Date: Thu, 26 Mar 2026 13:04:02 -0600 Subject: [PATCH] IniFile: Disallow section headers from starting at other line offsets than 0. See #21479 --- Common/Data/Format/IniFile.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Common/Data/Format/IniFile.cpp b/Common/Data/Format/IniFile.cpp index 98a9af4216..3189645ddf 100644 --- a/Common/Data/Format/IniFile.cpp +++ b/Common/Data/Format/IniFile.cpp @@ -172,7 +172,10 @@ ParsedIniLine::ParsedIniLine(std::string_view line) { value.clear(); comment = line; } else { - ParseLine(line, &key, &value, &comment); + if (!ParseLine(line, &key, &value, &comment)) { + // Preserve bogus input but turn it into comments. + comment = "# " + std::string(line); + } } } @@ -473,7 +476,7 @@ bool IniFile::Load(std::istream &in) { std::string linebuf; while (std::getline(in, linebuf)) { - std::string_view line = StripSpaces(std::string_view(linebuf)); + std::string_view line = std::string_view(linebuf); // Remove UTF-8 byte order marks. if (line.substr(0, 3) == "\xEF\xBB\xBF") { line = line.substr(3);