Skip to content

Commit

Permalink
fix: remove expression trim
Browse files Browse the repository at this point in the history
The unnecessary trim_spaces(expression) was removed from Handlebars.cpp as it's not required in the current context and could potentially remove intentional characters from literal string.
  • Loading branch information
alandefreitas committed Oct 16, 2023
1 parent 0683dde commit bf64028
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1785,7 +1785,6 @@ evalExpr(
bool evalLiterals) const
{
using Res = Handlebars::evalExprResult;
expression = trim_spaces(expression);
if (evalLiterals)
{
// ==============================================================
Expand Down
4 changes: 4 additions & 0 deletions src/test/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,10 @@ basic_context()
BOOST_TEST(hbs.render("Goodbye {{\"foo[bar\"}} world!", ctx) == "Goodbye beautiful world!");
BOOST_TEST(hbs.render("Goodbye {{\"foo'bar\"}} world!", ctx) == "Goodbye beautiful world!");
BOOST_TEST(hbs.render("Goodbye {{'foo\"bar'}} world!", ctx) == "Goodbye beautiful world!");

// literal references only convert to strings as helper parameters
// literal references as main helper names will decay to context keys
BOOST_TEST(hbs.render("{{\"\\n\"}}") == "");
}

// that current context path ({{.}}) doesn't hit helpers
Expand Down

0 comments on commit bf64028

Please sign in to comment.