Skip to content

Commit

Permalink
handle possible panic case when building the regex
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhseh committed Sep 15, 2023
1 parent 0833968 commit 2576866
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
3 changes: 3 additions & 0 deletions e2e_test/batch/basic/func.slt.part
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,9 @@ select regexp_replace('foobarXaz', '(?<!X)a', 'X');
----
foobXrXaz

query error Parsing error at position 2: Unknown group flag: (?1
select regexp_replace('foobarXaz', '(?1:123)', 'X');

query T
select regexp_count('ABCABCAXYaxy', 'A.');
----
Expand Down
4 changes: 3 additions & 1 deletion src/expr/src/vector_op/regexp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ impl RegexpContext {
};

Ok(Self {
regex: RegexBuilder::new(&origin).build().unwrap(),
regex: RegexBuilder::new(&origin)
.build()
.map_err(|e| ExprError::Parse(e.to_string().into()))?,
global: options.global,
replacement: make_replacement(replacement),
})
Expand Down

0 comments on commit 2576866

Please sign in to comment.