fix utils::string::replaceIP hanging if filter is empty

This commit is contained in:
dankmeme01 2024-11-17 18:13:04 +01:00
parent 6e11d0a6b0
commit 4d5e465ade

View file

@ -59,6 +59,8 @@ std::string utils::string::toUpper(std::string const& str) {
} }
std::string& utils::string::replaceIP(std::string& str, std::string const& orig, std::string const& repl) { std::string& utils::string::replaceIP(std::string& str, std::string const& orig, std::string const& repl) {
if (orig.empty()) return str;
std::string::size_type n = 0; std::string::size_type n = 0;
while ((n = str.find(orig, n)) != std::string::npos) { while ((n = str.find(orig, n)) != std::string::npos) {
str.replace(n, orig.size(), repl); str.replace(n, orig.size(), repl);