Skip to content

Commit

Permalink
do not crash on invalid regex
Browse files Browse the repository at this point in the history
  • Loading branch information
aloneguid committed Dec 8, 2023
1 parent e3a343a commit 534e719
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 5 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: 'Build'

env:
VERSION: 3.6.2
VERSION: 3.7.0
BUILD_TYPE: Release
ARCH: x64
VCPKG_CONFIG: Release
VCPKG_HASH: e8c2a04eb7ca058b6e2f0e6e33c67fdbffeee846
VCPKG_HASH: 8ee46dc72f75fc3d8d8dc90386bf7e84f2eb7450
DOC_ARTIFACT: webHelpBT2-all.zip

on: [push, workflow_dispatch]
Expand Down
9 changes: 7 additions & 2 deletions bt/app/match_rule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,13 @@ namespace bt {

bool match_rule::contains(const string& input, const string& value) const {
if(is_regex) {
regex r{value, regex_constants::icase};
return regex_match(input, r);
try {
regex r{value, regex_constants::icase};
return regex_match(input, r);
} catch(const std::regex_error& e) {
// most probably invalid regex pattern
return false;
}
} else {
return str::contains_ic(input, value);
}
Expand Down
10 changes: 10 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 3.7.0

## Improvements

- ?

### Bugs fixed

- BT crashed with unhandled exception when regular expression rule was executing a regex with invalid syntax (#59).

## 3.6.2

🐞Fixed: BT hangs waiting for browser proxy process to terminate. Thanks to @cjs1976 and @fixator10 in #51.
Expand Down
2 changes: 1 addition & 1 deletion grey
Submodule grey updated 3 files
+6 −2 backend.cpp
+61 −26 components.cpp
+14 −6 components.h

0 comments on commit 534e719

Please sign in to comment.