From edff4b537c4afd3bf0cc894039420a25a3fe0e78 Mon Sep 17 00:00:00 2001 From: Malin Ejdbo Date: Mon, 15 Feb 2021 14:30:25 +0100 Subject: [PATCH] Add warning if regex contains two or more wildcards * Find that replaces std::regex currently does not support two or more wildcards in an expression --- src/scene/scene_lua.inl | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/scene/scene_lua.inl b/src/scene/scene_lua.inl index c00971da07..a12b55b4ac 100644 --- a/src/scene/scene_lua.inl +++ b/src/scene/scene_lua.inl @@ -89,6 +89,17 @@ void applyRegularExpression(lua_State* L, const std::string& regex, ); return; } + + if (regex.find_first_of("*", wildPos + 1) != std::string::npos) { + LERRORC( + "applyRegularExpression", + fmt::format( + "Malformed regular expression: '{}': " + "Currently only one '*' is supported", regex + ) + ); + return; + } } // Else search for the literal string without regex else { @@ -468,6 +479,17 @@ int property_getProperty(lua_State* L) { ); return 0; } + + if (regex.find_first_of("*", wildPos + 1) != std::string::npos) { + LERRORC( + "property_getProperty", + fmt::format( + "Malformed regular expression: '{}': " + "Currently only one '*' is supported", regex + ) + ); + return 0; + } } // Else search for the literal string without regex else { @@ -643,6 +665,17 @@ int removeSceneGraphNodesFromRegex(lua_State* L) { ); return 0; } + + if (name.find_first_of("*", wildPos + 1) != std::string::npos) { + LERRORC( + "removeSceneGraphNodesFromRegex", + fmt::format( + "Malformed regular expression: '{}': " + "Currently only one '*' is supported", name + ) + ); + return 0; + } } // Else search for the literal string without regex else {