Skip to content

Commit 535df5e

Browse files
Merge pull request #332 from Kijewski/pr-393401467
parser: add missing level guard in `if let`
2 parents 9b0ed3c + e1d6127 commit 535df5e

File tree

5 files changed

+9746
-1
lines changed

5 files changed

+9746
-1
lines changed

.rustfmt.toml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ group_imports = "StdExternalCrate"
33
imports_granularity = "Module"
44
newline_style = "Unix"
55
normalize_comments = true
6+
overflow_delimited_expr = true
7+
style_edition = "2024"
68
unstable_features = true
79
use_field_init_shorthand = true
8-
style_edition = "2024"
910

1011
ignore = [
1112
"testing/tests/hello.rs",

rinja/.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../.rustfmt.toml

rinja_parser/src/node.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,7 @@ impl<'a> CondTest<'a> {
426426
let mut expr = Expr::parse(i, s.level, false)?;
427427
if let Expr::BinOp(_, _, ref mut right) = expr.inner {
428428
if matches!(right.inner, Expr::Var("set" | "let")) {
429+
let _level_guard = s.level.nest(i)?;
429430
*i = right.span.as_suffix_of(start).unwrap();
430431
let start_span = Span::from(*i);
431432
let new_right = Self::parse_cond(i, s)?;

rinja_parser/src/tests.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1288,3 +1288,14 @@ fn test_generics_parsing() {
12881288
)
12891289
.unwrap();
12901290
}
1291+
1292+
#[test]
1293+
fn fuzzed_deeply_tested_if_let() {
1294+
let src = include_str!("../tests/fuzzed-deeply-tested-if-let.txt");
1295+
let syntax = Syntax::default();
1296+
let err = Ast::from_str(src, None, &syntax).unwrap_err();
1297+
assert_eq!(
1298+
err.to_string().lines().next(),
1299+
Some("your template code is too deeply nested, or the last expression is too complex"),
1300+
);
1301+
}

0 commit comments

Comments
 (0)