Recognize broken section headings, mk. 3

This commit is contained in:
TheAssassin
2018-11-14 10:59:17 +01:00
parent bf152a509b
commit ded20c162d
2 changed files with 11 additions and 0 deletions

View File

@@ -55,6 +55,9 @@ namespace linuxdeploy {
if (len > 0 &&
!((len >= 2 && (line[0] == '/' && line[1] == '/')) || (len >= 1 && line[0] == '#'))) {
if (line[0] == '[') {
if (line.find_last_of('[') != 0)
throw ParseError("Multiple opening [ brackets");
// this line apparently introduces a new section
auto closingBracketPos = line.find(']');
auto lastClosingBracketPos = line.find_last_of(']');

View File

@@ -217,3 +217,11 @@ TEST_F(DesktopFileReaderFixture, testReadBrokenSectionHeaderTooManyClosingBracke
ASSERT_THROW(DesktopFileReader reader(ins), ParseError);
}
TEST_F(DesktopFileReaderFixture, testReadBrokenSectionHeaderTooManyOpeningBrackets) {
std::stringstream ins;
ins << "[[Desktop Entry]" << std::endl
<< "test=test" << std::endl;
ASSERT_THROW(DesktopFileReader reader(ins), ParseError);
}