diff options
author | GeckoEidechse <gecko.eidechse+git@pm.me> | 2024-03-22 14:40:37 +0100 |
---|---|---|
committer | GeckoEidechse <gecko.eidechse+git@pm.me> | 2024-03-22 14:40:37 +0100 |
commit | 7a5253b10dba95e99a465f5a8a6c3ea5c77e6526 (patch) | |
tree | 7505a75a741a4d2493473d311516c412df54378c | |
parent | d3ee91c1f5cf7eeacbb091c28e248bc3b88d5a6e (diff) | |
download | NorthstarLauncher-7a5253b10dba95e99a465f5a8a6c3ea5c77e6526.tar.gz NorthstarLauncher-7a5253b10dba95e99a465f5a8a6c3ea5c77e6526.zip |
feat: Initial check for whitelisted filetypes
-rw-r--r-- | primedev/mods/modsavefiles.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/primedev/mods/modsavefiles.cpp b/primedev/mods/modsavefiles.cpp index 68e33864..2ed0b0d3 100644 --- a/primedev/mods/modsavefiles.cpp +++ b/primedev/mods/modsavefiles.cpp @@ -74,6 +74,22 @@ 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(); |