Fix basic format header checks

This commit is contained in:
TheAssassin
2018-11-15 13:14:31 +01:00
parent 21b12cc6b6
commit 9707b81931
2 changed files with 15 additions and 5 deletions

View File

@@ -95,8 +95,10 @@ namespace linuxdeploy {
throw ParseError("Empty keys are not allowed");
// keys may only contain A-Za-z- characters according to specification
for (const auto c : key) {
if (!(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c == '-'))
for (const char c : key) {
if (!(
(c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9') || (c == '-')
))
throw ParseError("Key contains invalid character " + std::string{c});
}

View File

@@ -50,7 +50,7 @@ TEST_F(DesktopFileConformanceTest, testBasicFormatValidKeyCharacters) {
ss << "[Desktop Entry]" << std::endl
<< "TestKey=foo" << std::endl;
EXPECT_THROW(DesktopFile file(ss), ParseError);
EXPECT_NO_THROW(DesktopFile file(ss));
}
{
@@ -58,7 +58,7 @@ TEST_F(DesktopFileConformanceTest, testBasicFormatValidKeyCharacters) {
ss << "[Desktop Entry]" << std::endl
<< "4242trolol0=foo" << std::endl;
EXPECT_THROW(DesktopFile file(ss), ParseError);
EXPECT_NO_THROW(DesktopFile file(ss));
}
{
@@ -66,6 +66,14 @@ TEST_F(DesktopFileConformanceTest, testBasicFormatValidKeyCharacters) {
ss << "[Desktop Entry]" << std::endl
<< "----=foo" << std::endl;
EXPECT_THROW(DesktopFile file(ss), ParseError);
EXPECT_NO_THROW(DesktopFile file(ss));
}
{
std::stringstream ss;
ss << "[Desktop Entry]" << std::endl
<< "allLowerCase=foo" << std::endl;
EXPECT_NO_THROW(DesktopFile file(ss));
}
}