handlebars-lang / handlebars-lang/handlebars.js

Template containing NULL character fails to evaluate

Open
#2,059 2 comments 0 reactions 0 assignees View on GitHub
bug
Dominant language
JavaScript
Stars
18.7k
Forks
2.1k
PR merge metrics
No merged PRs in 30d

Description

Templates with NULL Unicode character(s) fail to evaluate

Example code:

```typescript
import Handlebars from "https://esm.sh/handlebars";

const handlebars = Handlebars.create();
const template = handlebars.compile('Hello \x00 {{name}}')
try {
const test = template({name: "foo"})
console.log(test)
} catch (e) {
console.log(e.message)
}
```

Fails with:

```
"Lexical error on line 1. Unrecognized text.
Hello {{name}}
------^"
```

Codepen: https://codepen.io/Milan-Konir/pen/KwPXgbo?editors=1111

Contributor guide

Open the contributing guide

Research direction

Start by running the Handlebars.create() and handlebars.compile() reproduction with the embedded NULL character. Trace the compile path from handlebars.compile into the template evaluation and identify where the NULL is rejected; done means the example evaluates without the lexical error.

Written by the indexing model from the issue text.

Assessment

Tech stack
handlebars, javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.