Skip to content

Commit

Permalink
Merge pull request #38 from Tom94/regex
Browse files Browse the repository at this point in the history
Prevent hard-crash when invalid regex syntax is used
  • Loading branch information
Tom94 authored Mar 13, 2018
2 parents b128755 + fc33932 commit 859a81e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/Common.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,12 @@ bool matches(string text, string filter, bool isRegex) {
return true;
}

regex searchRegex{filter, std::regex_constants::ECMAScript | std::regex_constants::icase};
return regex_search(text, searchRegex);
try {
regex searchRegex{filter, std::regex_constants::ECMAScript | std::regex_constants::icase};
return regex_search(text, searchRegex);
} catch (const regex_error&) {
return false;
}
};

return isRegex ? matchesRegex(text, filter) : matchesFuzzy(text, filter);
Expand Down

0 comments on commit 859a81e

Please sign in to comment.