File tree Expand file tree Collapse file tree 2 files changed +17
-5
lines changed
Expand file tree Collapse file tree 2 files changed +17
-5
lines changed Original file line number Diff line number Diff line change @@ -97,7 +97,18 @@ void ConsoleFilter::LoadFilters()
9797 continue ;
9898 }
9999
100- this ->filter .insert (std::make_pair (key, it->value .GetString ()));
100+ try
101+ {
102+ std::regex tmp (it->value .GetString (), std::regex_constants::ECMAScript);
103+ }
104+ catch (const std::regex_error &err)
105+ {
106+ ConFilterError (string_format (" The regex for \" %s\" is not valid." , key.c_str ()));
107+ ConFilterError (string_format (" Error: %s" , err.what ()));
108+ continue ;
109+ }
110+
111+ this ->filter .insert ({key, std::regex (it->value .GetString (), std::regex_constants::ECMAScript)});
101112 this ->counter .insert (std::make_pair (key, 0 ));
102113 }
103114}
@@ -108,12 +119,12 @@ bool ConsoleFilter::NeedFiltering(std::string message)
108119 return false ;
109120
110121 PERF_RECORD (" Console Filter" , " core" )
111- for (std::map<std::string, std::string>::iterator it = this ->filter .begin (); it != this ->filter .end (); ++it)
122+ for (auto it = this ->filter .begin (); it != this ->filter .end (); ++it)
112123 {
113124 std::string key = it->first ;
114- std::string val = it->second ;
125+ std::regex val = it->second ;
115126
116- if (message. find (val) != std::string::npos )
127+ if (std::regex_search (message, val) )
117128 {
118129 if (this ->counter .find (key) != this ->counter .end ())
119130 this ->counter [key]++;
Original file line number Diff line number Diff line change 33
44#include < map>
55#include < string>
6+ #include < regex>
67#include " ../entrypoint.h"
78#include " ../common.h"
89
@@ -16,7 +17,7 @@ class ConsoleFilter
1617{
1718private:
1819 bool m_status = false ;
19- std::map<std::string, std::string > filter;
20+ std::map<std::string, std::regex > filter;
2021 std::map<std::string, uint64> counter;
2122
2223public:
You can’t perform that action at this time.
0 commit comments