fix: enforce root containment for renderFile/parseFile lookups (#870)

Made-with: Cursor
This commit is contained in:
Yang Jun
2026-04-07 23:18:53 +08:00
committed by GitHub
parent db4348507e
commit f41c1fc02f
5 changed files with 31 additions and 10 deletions
+1
View File
@@ -38,6 +38,7 @@ describe('#renderFile()', function () {
return expect(html).toContain('"name": "liquidjs"')
})
it('should render file with context', async function () {
engine = new Liquid({ root: views, extname: '.html' })
const html = await engine.renderFile(resolve(views, 'name.html'), { name: 'harttle' })
return expect(html).toBe('My name is harttle.')
})
+2 -2
View File
@@ -4,8 +4,8 @@ import { drainStream } from '../stub/stream'
describe('.renderToNodeStream()', function () {
it('should render to stream in Node.js', done => {
const cjs = require('../../dist/liquid.node')
const engine = new cjs.Liquid()
const tpl = engine.parseFileSync(resolve(__dirname, '../stub/root/foo.html'))
const engine = new cjs.Liquid({ root: resolve(__dirname, '../stub/root/') })
const tpl = engine.parseFileSync('foo.html')
const stream = engine.renderToNodeStream(tpl)
let html = ''
stream.on('data', (data: string) => { html += data })