SimonFairbairn / SwiftyMarkdown

Converts Markdown files and strings into NSAttributedStrings with lots of customisation options.
MIT License
1.64k stars 275 forks source link

Fix complex pattern hanging forever #139

Open polqf opened 1 year ago

polqf commented 1 year ago

This PR fixes an issue where a complex pattern would hang forever, and never return, leaving an app in a complete freeze. The string is **~*~~~*~*~**~*~* h e a r d ***~*~*~**~*~~~*

The library would detect the initial ~~~ pattern as the start of a tag, and the one at the end as the end of it. But the closeTag method would never return as remainingTags would never reach 0.