mirror of
https://github.com/pantor/inja.git
synced 2026-10-05 12:00:36 +00:00
Throw instead of crashing on a pipe with no preceding expression (#351)
{{ | upper }} makes Parser::parse_expression call arguments.back() on an empty vector, which is undefined behavior and aborts under hardened standard libraries. Throw 'too few arguments' (matching add_operator) when there is no expression before the '|'.
This commit is contained in:
@@ -159,6 +159,9 @@ Yeah!
|
||||
CHECK(env.render("{{ brother.name | upper }}", data) == "CHRIS");
|
||||
CHECK(env.render("{{ brother.name | upper | lower }}", data) == "chris");
|
||||
CHECK(env.render("{{ [\"C\", \"A\", \"B\"] | sort | join(\",\") }}", data) == "A,B,C");
|
||||
|
||||
CHECK_THROWS_WITH(env.render("{{ | upper }}", data), "[inja.exception.parser_error] (at 1:6) too few arguments");
|
||||
CHECK_THROWS_WITH(env.render("{{ upper(| lower) }}", data), "[inja.exception.parser_error] (at 1:12) too few arguments");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user