fix: parser throws on non-string input, #726

This commit is contained in:
Yang Jun
2024-07-25 20:06:12 +08:00
parent fce2899e88
commit 21a822348f
2 changed files with 53 additions and 48 deletions
+1
View File
@@ -26,6 +26,7 @@ export class Parser {
this.parseLimit = new Limiter('parse length', liquid.options.parseLimit)
}
public parse (html: string, filepath?: string): Template[] {
html = String(html)
this.parseLimit.use(html.length)
const tokenizer = new Tokenizer(html, this.liquid.options.operators, filepath)
const tokens = tokenizer.readTopLevelTokens(this.liquid.options)