mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-16 04:40:39 -07:00
fix: memoryLimit doesn't work in for tag, #776
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"version": "0.0.0",
|
"version": "0.0.0",
|
||||||
"private": true,
|
"private": true,
|
||||||
"hexo": {
|
"hexo": {
|
||||||
"version": "5.4.0"
|
"version": "7.3.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "hexo generate",
|
"build": "hexo generate",
|
||||||
|
|||||||
Vendored
+4
-1
@@ -60,7 +60,10 @@
|
|||||||
/* global liquidjs, ace */
|
/* global liquidjs, ace */
|
||||||
if (!location.pathname.match(/playground.html$/)) return;
|
if (!location.pathname.match(/playground.html$/)) return;
|
||||||
updateVersion(liquidjs.version);
|
updateVersion(liquidjs.version);
|
||||||
const engine = new liquidjs.Liquid();
|
const engine = new liquidjs.Liquid({
|
||||||
|
memoryLimit: 1e5,
|
||||||
|
renderLimit: 1e5
|
||||||
|
});
|
||||||
const editor = createEditor('editorEl', 'liquid');
|
const editor = createEditor('editorEl', 'liquid');
|
||||||
const dataEditor = createEditor('dataEl', 'json');
|
const dataEditor = createEditor('dataEl', 'json');
|
||||||
const preview = createEditor('previewEl', 'html');
|
const preview = createEditor('previewEl', 'html');
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ export function evalQuotedToken (token: QuotedToken) {
|
|||||||
function * evalRangeToken (token: RangeToken, ctx: Context) {
|
function * evalRangeToken (token: RangeToken, ctx: Context) {
|
||||||
const low: number = yield evalToken(token.lhs, ctx)
|
const low: number = yield evalToken(token.lhs, ctx)
|
||||||
const high: number = yield evalToken(token.rhs, ctx)
|
const high: number = yield evalToken(token.rhs, ctx)
|
||||||
|
ctx.memoryLimit.use(high - low + 1)
|
||||||
return range(+low, +high + 1)
|
return range(+low, +high + 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -524,4 +524,9 @@ describe('Issues', function () {
|
|||||||
const result = engine.parseAndRenderSync(`\n{{ "foo" | pos }}`)
|
const result = engine.parseAndRenderSync(`\n{{ "foo" | pos }}`)
|
||||||
expect(result).toEqual('\n[2,12] foo')
|
expect(result).toEqual('\n[2,12] foo')
|
||||||
})
|
})
|
||||||
|
it("memoryLimit doesn't work in for tag #776", () => {
|
||||||
|
const engine = new Liquid()
|
||||||
|
const tpl = `{% for i in (1..1000000000) %} {{'a'}} {% endfor %}`
|
||||||
|
expect(() => engine.parseAndRenderSync(tpl)).toThrow(/memory out/)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user