aboutsummaryrefslogtreecommitdiff
path: root/primedev/mods
diff options
context:
space:
mode:
Diffstat (limited to 'primedev/mods')
-rw-r--r--primedev/mods/modsavefiles.cpp20
1 files changed, 20 insertions, 0 deletions
diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp
index 13239c99..d73b867c 100644
--- a/primedev/mods/modsavefiles.cpp
+++ b/primedev/mods/modsavefiles.cpp
@@ -74,6 +74,26 @@ 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("A mod failed to save a file via Safe I/O due to the following error:");
+ spdlog::error("No file extension specified");
+ return;
+ }
+
+ // If there's a file extension missing here that you need, feel free to make a PR adding it
+ static const 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("A mod failed to save a file via Safe I/O due to the following error:");
+ spdlog::error("Disallowed file extension: {}", extension);
+ return;
+ }
+
try
{
mutex.get().lock();