mdiep / MMMarkdown

An Objective-C framework for converting Markdown to HTML.
MIT License
1.25k stars 168 forks source link

Missing link text causes runtime exception #35

Closed ianalbertruelala closed 10 years ago

ianalbertruelala commented 10 years ago

The following markdown causes an assertion failure "Invalid parameter not satisfying: theLineRanges.count > 0" on line 86 in MMScanner initWithString:lineRanges:

[](http://www.google.com/)

Obviously it's not a meaningful link since there's nothing to click, but we've found WYSIWYG editors may leave this artifact behind as content is edited. It's fine if the link doesn't wind up being displayed, but the parser should ideally not crash.

ianalbertruelala commented 10 years ago

Commenting out the if (textRange.length > 0) tests in MMSpanParser.m _parseLinkTextBodyWithScanner: lines 623 and 651 seem to fix the problem, but I don't know if that fix has any side effects.

ianalbertruelala commented 10 years ago

Sorry, to clarify, this was against 0.3, the last release. I see the issue does not reproduce on master. For now we'll upgrade from the current master branch until another release is made.

mdiep commented 10 years ago

Aha! Thanks for looking into it.