markdown-to-jsx icon indicating copy to clipboard operation
markdown-to-jsx copied to clipboard

InternalError: too much recursion

Open dimensi opened this issue 4 years ago • 3 comments

Hi, I wrote a table for the documentation of a component in storybook that uses an html list inside. And my chrome started to hang and firefox started to crash with the error that recursion is too deep. After an hour of debugging I realized that the problem is in your library. Made a sandbox with a minimal example. https://codesandbox.io/s/5yusm?file=/src/App.tsx In chrome it is very slow to work, in firefox it crashes with an error, so I suggest looking at the sandbox through firefox. Your library is cool, but it seems the algorithm is too slow when dealing with tables and content inside a table. Unfortunately I don't know how to do it better :(

JS shows the error in this place: https://github.com/probablyup/markdown-to-jsx/blob/main/index.tsx#L716 https://github.com/probablyup/markdown-to-jsx/blob/main/index.tsx#L655

Below is a video of how the browser reacts by removing a few extra spaces.

https://user-images.githubusercontent.com/11390039/123175287-371aa300-d48a-11eb-81de-3102051cfaa7.mov

dimensi avatar Jun 23 '21 22:06 dimensi

I'm hitting this too, I'm pretty sure it's effectively an evil regexp causing a DoS https://owasp.org/www-community/attacks/Regular_expression_Denial_of_Service_-_ReDoS

but those regexps are beyond my expertise to debug:

https://github.com/probablyup/markdown-to-jsx/blob/ebd044aa1257751c2dec3f28d09ec8c54dff8c39/index.tsx#L298-L311

xdumaine avatar Feb 01 '23 16:02 xdumaine

Is there a fix for this too much recursion error?

magimenon avatar Apr 22 '24 16:04 magimenon