3
0
mirror of https://github.com/larvit/adf-codec.git synced 2026-11-21 23:46:21 +01:00

Refuse markdown past V8's longest string on every engine, before building it

This commit is contained in:
2026-10-11 23:26:20 +02:00
committed by Lillem4n
parent 7a27f6b81c
commit e3aa790ec8
19 changed files with 203 additions and 90 deletions
@@ -70,11 +70,10 @@ test('refuses what the document guard refuses, and nothing else', () => {
assert.match(portableDocument(document(paragraph(deepInline))), /^unsupported-nesting-depth at /)
})
// The merge throws at its concatenation, before any text is scanned, so no engine holds more than the one string.
test('refuses a paragraph whose merged text passes the engine\'s longest string', () => {
test('refuses a paragraph whose text would pass V8\'s longest string, joining none of it', () => {
const long = 'a'.repeat(2 ** 28)
const merged = paragraph(...Array.from({ length: 9 }, () => text(long)))
assert.equal(portableDocument(document(merged)), 'unsupported-node-shape at /')
assert.equal(portableDocument(document(merged)), 'unsupported-node-shape at /content/0')
})
test('refuses nesting past 500 levels wherever the reduction walks', () => {