Skip to content

Commit

Permalink
return None if regex compilation fails
Browse files Browse the repository at this point in the history
  • Loading branch information
xzhseh committed Feb 20, 2024
1 parent c94e0e5 commit e9e94b4
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/frontend/src/handler/create_sql_function.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,9 @@ fn find_target(input: &str, target: &str) -> Option<usize> {
// The pattern uses negative lookbehind (?<!...) and lookahead (?!...) to ensure
// the target is not surrounded by ASCII alphabetic characters
let pattern = format!(r"(?<![A-Za-z]){0}(?![A-Za-z])", fancy_regex::escape(target));
let re = Regex::new(&pattern).unwrap();
let Ok(re) = Regex::new(&pattern) else {
return None;
};

let Ok(Some(ma)) = re.find(input) else {
return None;
Expand Down

0 comments on commit e9e94b4

Please sign in to comment.