mirror of
https://github.com/askama-rs/askama.git
synced 2025-09-28 05:21:14 +00:00
parser: add missing level guard in if let
Resolves <https://issues.oss-fuzz.com/issues/393401467>
This commit is contained in:
parent
9b0ed3c952
commit
e1d61276e9
@ -3,9 +3,10 @@ group_imports = "StdExternalCrate"
|
||||
imports_granularity = "Module"
|
||||
newline_style = "Unix"
|
||||
normalize_comments = true
|
||||
overflow_delimited_expr = true
|
||||
style_edition = "2024"
|
||||
unstable_features = true
|
||||
use_field_init_shorthand = true
|
||||
style_edition = "2024"
|
||||
|
||||
ignore = [
|
||||
"testing/tests/hello.rs",
|
||||
|
1
rinja/.rustfmt.toml
Symbolic link
1
rinja/.rustfmt.toml
Symbolic link
@ -0,0 +1 @@
|
||||
../.rustfmt.toml
|
@ -426,6 +426,7 @@ impl<'a> CondTest<'a> {
|
||||
let mut expr = Expr::parse(i, s.level, false)?;
|
||||
if let Expr::BinOp(_, _, ref mut right) = expr.inner {
|
||||
if matches!(right.inner, Expr::Var("set" | "let")) {
|
||||
let _level_guard = s.level.nest(i)?;
|
||||
*i = right.span.as_suffix_of(start).unwrap();
|
||||
let start_span = Span::from(*i);
|
||||
let new_right = Self::parse_cond(i, s)?;
|
||||
|
@ -1288,3 +1288,14 @@ fn test_generics_parsing() {
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fuzzed_deeply_tested_if_let() {
|
||||
let src = include_str!("../tests/fuzzed-deeply-tested-if-let.txt");
|
||||
let syntax = Syntax::default();
|
||||
let err = Ast::from_str(src, None, &syntax).unwrap_err();
|
||||
assert_eq!(
|
||||
err.to_string().lines().next(),
|
||||
Some("your template code is too deeply nested, or the last expression is too complex"),
|
||||
);
|
||||
}
|
||||
|
9731
rinja_parser/tests/fuzzed-deeply-tested-if-let.txt
Normal file
9731
rinja_parser/tests/fuzzed-deeply-tested-if-let.txt
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user