fix: revert ownPropertyOnly iteration hardening

Iteration is documented as an ownPropertyOnly exception; restore
isIterable/toEnumerable and document inherited Symbol.iterator behavior.

Co-authored-by: Cursor <[email protected]>
This commit is contained in:
Yang Jun
2026-07-19 14:00:05 +08:00
co-authored by Cursor
parent 072f63c2c0
commit 04354ce36f
7 changed files with 12 additions and 21 deletions
@@ -88,14 +88,14 @@ describe('scope security', function () {
expect((Object.prototype as any).polluted).toBeUndefined()
})
it('should not iterate plain objects via inherited Symbol.iterator', async function () {
it('should iterate plain objects via inherited Symbol.iterator (ownPropertyOnly exception)', async function () {
// eslint-disable-next-line no-extend-native
(Object.prototype as any)[Symbol.iterator] = function * () { yield 'inherited' }
try {
await expect(liquid.parseAndRender(
'{% for x in obj %}{{ x }}{% endfor %}',
{ obj: {} }
)).resolves.toBe('')
)).resolves.toBe('inherited')
} finally {
delete (Object.prototype as any)[Symbol.iterator]
}