From: Kyle Fuller Date: Wed, 14 Oct 2015 15:30:12 +0000 (-0700) Subject: Catch regex errors #31 X-Git-Tag: 1.1.0~13 X-Git-Url: http://git.99rst.org/?a=commitdiff_plain;h=1735071f3d6b2ae905caf7842df777a36096851c;p=znc-palaver.git Catch regex errors #31 --- diff --git a/palaver.cpp b/palaver.cpp index a578472..c1adb66 100644 --- a/palaver.cpp +++ b/palaver.cpp @@ -485,10 +485,15 @@ public: #ifdef HAS_REGEX std::smatch match; - std::regex expression = std::regex("\\b" + re_escape(sKeyword) + "\\b", - std::regex_constants::ECMAScript | std::regex_constants::icase); + CString sExpression = "\\b" + re_escape(sKeyword) + "\\b"; - std::regex_search(sMessage, match, expression); + try { + std::regex expression = std::regex(sExpression, + std::regex_constants::ECMAScript | std::regex_constants::icase); + std::regex_search(sMessage, match, expression); + } catch (std::regex_error& error) { + DEBUG("Caught regex error '" << error.code() << "' from '" << sExpression << "'."); + } if (!match.empty()) { bResult = true;