diff --git a/premake5.lua b/premake5.lua index c00d8bc3..35554fdf 100644 --- a/premake5.lua +++ b/premake5.lua @@ -206,7 +206,7 @@ workspace "iw4x" configurations {"Debug", "Release"} language "C++" - cppdialect "C++23" + cppdialect "C++20" architecture "x86" platforms "Win32" diff --git a/src/Components/Modules/Download.cpp b/src/Components/Modules/Download.cpp index 51de1891..e32e161a 100644 --- a/src/Components/Modules/Download.cpp +++ b/src/Components/Modules/Download.cpp @@ -890,12 +890,12 @@ namespace Components bool Download::ClientDownload::File::allowed() const { - if (name.contains("..") || name.contains(":")) + if (Utils::String::Contains(name, "..") || Utils::String::Contains(name, ":")) { return false; } - if (name.contains("\\") || name.contains("/")) + if (Utils::String::Contains(name, "\\") || Utils::String::Contains(name, "/")) { return false; } diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index a0fed218..fa192164 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -114,6 +114,16 @@ namespace Utils::String return std::equal(needle.rbegin(), needle.rend(), haystack.rbegin()); } + bool Contains(const std::string& haystack, const std::string& needle) + { + if (haystack.find(needle) != std::string::npos) + { + return true; + } + + return false; + } + bool IsNumber(const std::string& str) { return !str.empty() && std::find_if(str.begin(), str.end(), [](unsigned char input) diff --git a/src/Utils/String.hpp b/src/Utils/String.hpp index 0c90d90b..53675484 100644 --- a/src/Utils/String.hpp +++ b/src/Utils/String.hpp @@ -129,6 +129,7 @@ namespace Utils::String [[nodiscard]] bool StartsWith(const std::string& haystack, const std::string& needle); [[nodiscard]] bool EndsWith(const std::string& haystack, const std::string& needle); + [[nodiscard]] bool Contains(const std::string& haystack, const std::string& needle); [[nodiscard]] bool IsNumber(const std::string& str);