Skip to content

Commit

Permalink
regex: log an error if regex parsing fails
Browse files Browse the repository at this point in the history
  • Loading branch information
vaxerski committed Jan 17, 2025
1 parent b7a3c45 commit 76a8996
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/desktop/Rule.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
#include "Rule.hpp"
#include <re2/re2.h>
#include "../debug/Log.hpp"

CRuleRegexContainer::CRuleRegexContainer(const std::string& regex_) {
const bool NEGATIVE = regex_.starts_with("negative:");

negative = NEGATIVE;
regex = std::make_unique<RE2>(NEGATIVE ? regex_.substr(9) : regex_);

// TODO: maybe pop an error?
if (!regex->ok())
Debug::log(ERR, "RuleRegexContainer: regex {} failed to parse!", regex_);
}

bool CRuleRegexContainer::passes(const std::string& str) const {
Expand Down

0 comments on commit 76a8996

Please sign in to comment.