Very long string crash nodejs
Author: jlguardiCreated Jun 15, 2020Updated Oct 13, 2024
I've experienced some issues with long strings:
- Very slow parsing on long strings (1MB)
- Crash with very long strings: Due to recursive calls and string concatenation, the current implementation crashes with 100MB strings.
I've included 2 test cases to validate this behaviour:
t.equal(
JSON5.parse("'" + 'a'.repeat(1000 * 1000) + "'"),
'a'.repeat(1000 * 1000),
'parse long json string (1MB)'
)
t.equal(
JSON5.parse("'" + 'a'.repeat(100 * 1000 * 1000) + "'"),
'a'.repeat(100 * 1000 * 1000),
'parse very long json string (100MB)'
)Related with #85 and #164
Source: json5/json5