Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Protect against quadratic generated table size explosion
This commit adds a limit to the number of auto-completed cells around 200,000. The result is, in these original samples: python -c 'N=100; print("x|" * N + "\n" + "-|" * N + "\n" + "x|\n" * N)' | commonmark --extension=pipe_tables | wc -c 102362 This is unchanged. $ python -c 'N=1000; print("x|" * N + "\n" + "-|" * N + "\n" + "x|\n" * N)' | commonmark --extension=pipe_tables | wc -c 2025878 This, however, is much lower. The parser is refusing to parse the row where the limit is hit, and switches to parsing it as text instead. $ python -c 'N=10000; print("x|" * N + "\n" + "-|" * N + "\n" + "x|\n" * N)' | commonmark --extension=pipe_tables | wc -c 2240258 It's not quadratic any more (without this commit, it was 1000230062). At the limit, 200,000 autocompleted rows is approximately "</td><td>".len * 200,000 generated data, or 1.8Mbyte of data. The above examples show about 2Mbytes, thanks to the row tags and text overhead, and when the parser breaks out of the table it's still including the remaining "rows" as text.
- Loading branch information