From d59ef03d8f5d975a3c31ce9f1a27b8caaa51550d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 19 Mar 2023 19:23:38 +0100 Subject: [PATCH] Check for illegal keywords in the header of Speck files to detect invalid files (closes #2549) --- modules/space/speckloader.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/modules/space/speckloader.cpp b/modules/space/speckloader.cpp index 210322f8dc..9a8282865c 100644 --- a/modules/space/speckloader.cpp +++ b/modules/space/speckloader.cpp @@ -263,6 +263,21 @@ Dataset loadFile(std::filesystem::path path, SkipAllZeroLines skipAllZeroLines) res.textures.push_back(texture); continue; } + + if (startsWith(line, "maxcomment")) { + // ignoring this comment as we don't need it + continue; + } + + // If we get this far, we had an illegal header as it wasn't an empty line and + // didn't start with either '#' denoting a comment line, and didn't start with + // either the 'datavar', 'texturevar', 'polyorivar', or 'texture' keywords + throw ghoul::RuntimeError(fmt::format( + "Error in line {} while reading the header information of file {}. Line is " + "neither a comment line, nor starts with one of the supported keywords for " + "SPECK files", + currentLineNumber, path + )); } std::sort(