Skip to content

Commit

Permalink
[Misc]: bumping up francy-regex to 0.13.0, reverting changes in previ…
Browse files Browse the repository at this point in the history
…ous commit since they now handle the previously failing case (#442)
  • Loading branch information
joshfried-aws authored Jan 5, 2024
1 parent 1fc8760 commit 593c5e8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 39 deletions.
7 changes: 4 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion guard/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ grep-matcher = "0.1.5"
grep-regex = "0.1.9"
unsafe-libyaml = "0.2.10"
rstest = "0.15.0"
fancy-regex = "0.12.0"
fancy-regex = "0.13.0"
indoc = "1.0.8"
thiserror = "1.0.38"

Expand Down
35 changes: 0 additions & 35 deletions guard/src/rules/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,41 +257,6 @@ fn parse_regex_inner(input: Span) -> IResult<Span, Value> {

regex.push_str(fragment);

let mut stack = vec![];
let chars = regex.chars().collect::<Vec<_>>();

for (i, c) in chars.iter().enumerate() {
if c.is_control() {
return Err(nom::Err::Error(ParserError {
context: "Could not parse regular expression".to_string(),
kind: ErrorKind::RegexpMatch,
span: input,
}));
}
if *c == '(' {
if i == 0 || *chars.get(i - 1).unwrap() != '\\' {
stack.push(c);
}
} else if *c == ')'
&& (i == 0 || *chars.get(i - 1).unwrap() != '\\')
&& stack.pop().is_none()
{
return Err(nom::Err::Error(ParserError {
context: "Could not parse regular expression".to_string(),
kind: ErrorKind::RegexpMatch,
span: input,
}));
}
}

if !stack.is_empty() {
return Err(nom::Err::Error(ParserError {
context: "Could not parse regular expression".to_string(),
kind: ErrorKind::RegexpMatch,
span: input,
}));
}

return match Regex::try_from(regex.as_str()) {
Ok(_) => Ok((remainder, Value::Regex(regex))),
Err(e) => Err(nom::Err::Error(ParserError {
Expand Down

0 comments on commit 593c5e8

Please sign in to comment.