Skip to content

Commit 2d59cff

Browse files
committed
fix: memory limit issue for join filter, fix #737
1 parent 292a93b commit 2d59cff

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/filters/array.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type { Scope } from '../context'
66

77
export const join = argumentsToValue(function (this: FilterImpl, v: any[], arg: string) {
88
const array = toArray(v)
9-
const sep = arg === undefined ? ' ' : arg
9+
const sep = isNil(arg) ? ' ' : stringify(arg)
1010
const complexity = array.length * (1 + sep.length)
1111
this.context.memoryLimit.use(complexity)
1212
return array.join(sep)

test/e2e/issues.spec.ts

+6
Original file line numberDiff line numberDiff line change
@@ -495,4 +495,10 @@ describe('Issues', function () {
495495
const liquid = new Liquid()
496496
expect(() => liquid.parse({} as any)).not.toThrow()
497497
})
498+
it('Unexpected "RenderError: memory alloc limit exceeded" #737', () => {
499+
const liquid = new Liquid();
500+
const context = { x: ["a", "b"] };
501+
const template = "{{ x | join: 5 }}"
502+
expect(liquid.parseAndRender(template, context)).resolves.toEqual('a5b')
503+
})
498504
})

0 commit comments

Comments
 (0)