mity / md4c

C Markdown parser. Fast. SAX-like interface. Compliant to CommonMark specification.
MIT License
755 stars 138 forks source link

pathologic input: O(n^2) with link ref. defs #238

Closed mity closed 4 months ago

mity commented 4 months ago

Input generated with this leads to O(n^2) in time and space (output size):

$ python -c 'N=1000; print("[x]: " + "x" * N + "\n[x]" * N)'
mity commented 4 months ago

Seems cmark stops generating the links after reaching some threshold, pulldown-cmark is vulnerable too.