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

Spell a line in memory linear in its length, so a paragraph up to V8's longest string converts within Node's default heap

This commit is contained in:
2026-10-13 11:48:18 +02:00
committed by Lillem4n
parent 7bc69355c3
commit 03b4ab2e44
5 changed files with 97 additions and 55 deletions
@@ -70,6 +70,12 @@ test('refuses text past V8\'s longest string', () => {
assert.equal(markdown(result), tooLong)
})
// One escape past the most entries V8's Set holds.
test('escapes more characters in a line than a Set holds', () => {
const stars = '*'.repeat(2 ** 24 + 1)
assert.equal(markdown(adfToLosslessMarkdown(document(paragraph({ text: stars, type: 'text' })))), `${'\\*'.repeat(2 ** 24 + 1)}\n`)
})
test('refuses a document version the markdown cannot carry', () => {
assert.equal(code(adfToLosslessMarkdown({ type: 'doc', version: 2 })), 'unsupported-document-version')
})