aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--primedev/mods/modsavefiles.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp
index 68e33864..5f1317b9 100644
--- a/primedev/mods/modsavefiles.cpp
+++ b/primedev/mods/modsavefiles.cpp
@@ -74,6 +74,24 @@ template <ScriptContext context> void SaveFileManager::SaveFileAsync(fs::path fi
std::thread writeThread(
[mutex, file, contents]()
{
+ // Check if has extension and return early if not
+ if (!file.has_extension())
+ {
+ spdlog::error("SAVE FAILED!");
+ spdlog::error("No file extension specified");
+ }
+
+ // TODO: move into list of global consts?
+ std::set<std::string> whitelist = {".txt", ".json"};
+
+ // Check if file extension is whitelisted
+ std::string extension = file.extension().string();
+ if (whitelist.find(extension) == whitelist.end())
+ {
+ spdlog::error("SAVE FAILED!");
+ spdlog::error("Disallowed file extension: {}", extension);
+ }
+
try
{
mutex.get().lock();