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

Regex DOS can occur with HTML

Open clgeoio opened this issue 3 years ago • 1 comments

Whilst the name does imply converting markdown to JSX, the readme does say

Arbitrary HTML is supported and parsed into the appropriate JSX representation without dangerouslySetInnerHTML

When the following HTML is passed to markdown-to-jsx , the browser/node server will lock up and use 100% CPU due to a suspected infinite regex parsing issue.

<span><span><span><span>Text</span></span></span></span>Text<br /><br /><strong>Text</strong><br /><strong><br /></strong>Text<a href="https://www.google.com/" rel="noopener noreferrer" target="_blank">Link</a>  <a href="https://www.google.com/" rel="noopener noreferrer" target="_blank">Link</a>.Text<br /><br /><strong>Bold</strong><br /><strong><br /></strong>More text text text<br /><br /><strong>Bold</strong><br /><strong><br /></strong>

This above snippet is the output from a popular WYSIWYG editor, Froala. If copied and pasted into https://probablyup.com/markdown-to-jsx/, it will lock up your browser.

I am using markdown-to-jsx 7.1.1.

clgeoio avatar Feb 26 '21 03:02 clgeoio

Interestingly. When I paste the snippet in the example link, and the current contents is empty, it freezes as said. But when there is something already present there is no issue.

Prabhakar-Poudel avatar May 11 '21 21:05 Prabhakar-Poudel