regex filter: fix assertion fail if regex wasn't properly compiled
This commit is contained in:
@@ -35,7 +35,7 @@ template <typename T> struct RegexFilter
|
||||
bool operator()(const Item &item) {
|
||||
if (m_rx.regex().empty())
|
||||
return true;
|
||||
if (!m_rx.error().empty())
|
||||
if (!m_rx.compiled() || !m_rx.error().empty())
|
||||
return false;
|
||||
return m_filter(m_rx, item.value());
|
||||
}
|
||||
|
||||
@@ -52,6 +52,11 @@ const std::string &Regex::error() const
|
||||
return m_error;
|
||||
}
|
||||
|
||||
bool Regex::compiled() const
|
||||
{
|
||||
return m_compiled;
|
||||
}
|
||||
|
||||
bool Regex::compile()
|
||||
{
|
||||
if (m_compiled)
|
||||
|
||||
@@ -37,6 +37,9 @@ struct Regex
|
||||
/// @return compilation error (if there was any)
|
||||
const std::string &error() const;
|
||||
|
||||
/// @return true if regular expression is compiled, false otherwise
|
||||
bool compiled() const;
|
||||
|
||||
/// compiles regular expression
|
||||
/// @result true if compilation was successful, false otherwise
|
||||
bool compile();
|
||||
|
||||
Reference in New Issue
Block a user