mirror of
https://github.com/harttle/liquidjs.git
synced 2026-09-15 20:30:39 -07:00
Restore null-prototype hardening for Jekyll include bindings, colocate blocked-key checks with readJSProperty, align ownPropertyOnly JSDoc with security docs, and drop integration tests duplicated in context.spec. Co-authored-by: Cursor <[email protected]>
43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { Liquid } from '../../../src/liquid'
|
|
import { Drop } from '../../../src/drop/drop'
|
|
|
|
describe('scope security', function () {
|
|
let liquid: Liquid
|
|
|
|
beforeEach(function () {
|
|
liquid = new Liquid()
|
|
})
|
|
|
|
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('inherited')
|
|
} finally {
|
|
delete (Object.prototype as any)[Symbol.iterator]
|
|
}
|
|
})
|
|
|
|
it('should not read inherited size on plain objects', async function () {
|
|
const obj = Object.create({ size: 99 })
|
|
obj.own = 'yes'
|
|
await expect(liquid.parseAndRender('{{ obj.size }}', { obj })).resolves.toBe('1')
|
|
})
|
|
|
|
it('should still iterate Drop with Symbol.iterator', async function () {
|
|
class IterableDrop extends Drop {
|
|
* [Symbol.iterator] () {
|
|
yield 'a'
|
|
yield 'b'
|
|
}
|
|
}
|
|
await expect(liquid.parseAndRender(
|
|
'{% for x in drop %}{{ x }}{% endfor %}',
|
|
{ drop: new IterableDrop() }
|
|
)).resolves.toBe('ab')
|
|
})
|
|
})
|