mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-18 05:50:43 -07:00
fix(security): allow partial recursion when renderLimit is finite
Only reject render/include cycles when renderLimit is unlimited (default Infinity). With a finite time budget, recursion is bounded by renderLimit checks in renderTemplates. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
+3
-1
@@ -181,7 +181,9 @@ export function * renderFilePath (file: ParsedFileName, ctx: Context, liquid: Li
|
||||
|
||||
export function pushPartialStack (ctx: Context, filepath: string, tag: 'render' | 'include') {
|
||||
const stack: string[] = ctx.getRegister('partialStack', [])
|
||||
if (stack.includes(filepath)) throw new Error(`${tag} tag cannot be nested`)
|
||||
if (ctx.renderLimit.isUnlimited() && stack.includes(filepath)) {
|
||||
throw new Error(`${tag} tag cannot be nested`)
|
||||
}
|
||||
stack.push(filepath)
|
||||
}
|
||||
|
||||
|
||||
@@ -19,4 +19,7 @@ export class Limiter {
|
||||
assert(+count <= this.limit, this.message)
|
||||
}
|
||||
}
|
||||
isUnlimited () {
|
||||
return !Number.isFinite(this.limit)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user