From 6e8af35dd5906a768e173c2af667daedd2d94593 Mon Sep 17 00:00:00 2001 From: Yang Jun Date: Tue, 21 Jul 2026 21:30:19 +0800 Subject: [PATCH] refactor: simplify scope-security MR Drop null-prototype passthrough in push(), inline blocked-key checks, remove redundant createScope at include tag, trim verbose docs, and drop implementation-detail unit tests. Co-authored-by: Cursor --- src/context/context.ts | 6 +----- src/tags/include.ts | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/context/context.ts b/src/context/context.ts index a7caf8e56..87db76d97 100644 --- a/src/context/context.ts +++ b/src/context/context.ts @@ -95,11 +95,7 @@ export class Context { return scope } public push (ctx: Scope): Scope { - const scope = ctx instanceof Drop - ? ctx - : Object.getPrototypeOf(ctx) === null - ? ctx - : createScope(ctx) + const scope = ctx instanceof Drop ? ctx : createScope(ctx) this.scopes.push(scope) return scope } diff --git a/src/tags/include.ts b/src/tags/include.ts index 8c7e9d228..a0965a617 100644 --- a/src/tags/include.ts +++ b/src/tags/include.ts @@ -1,5 +1,5 @@ import { Template, ValueToken, TopLevelToken, Liquid, Tag, assert, evalToken, Hash, Emitter, TagToken, Context } from '..' -import { BlockMode, Scope, createScope } from '../context' +import { BlockMode, Scope } from '../context' import { Parser } from '../parser' import { Argument, Arguments, PartialScope } from '../template' import { isString, isValueToken } from '../util' @@ -40,7 +40,7 @@ export default class extends Tag { const scope = (yield hash.render(ctx)) as Scope if (withVar) scope[filepath] = yield evalToken(withVar, ctx) const templates = (yield liquid._parsePartialFile(filepath, ctx.sync, this.currentFile)) as Template[] - ctx.push(ctx.opts.jekyllInclude ? { include: createScope(scope) } : scope) + ctx.push(ctx.opts.jekyllInclude ? { include: scope } : scope) yield renderer.renderTemplates(templates, ctx, emitter) ctx.pop() ctx.restoreRegister(saved)