bmoliveira / MarkdownKit

A simple and customizable Markdown Parser for Swift
MIT License
783 stars 136 forks source link

Fix a crash when parsing lists with lots of spaces after the indicator character #94

Closed guillaumealgis closed 3 years ago

guillaumealgis commented 3 years ago

The range used in .addAttributes() is wrong, because we're replacing characters of the same range with the indicator variable right before, and the indicator can be shorter than the original range.length.

If the original range was sufficiently long for its length to be greater than the string's length after the indicator replacement, .addAttributes will crash.

Attached is a proposed fix and two simple tests, one passing and one failing before fix, both passing after.