diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp index 13239c99f..d73b867cd 100644 --- a/primedev/mods/modsavefiles.cpp +++ b/primedev/mods/modsavefiles.cpp @@ -74,6 +74,26 @@ template 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 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();