dreamwieber / AttributedMarkdown

Native Markdown Parsing to NSAttributedString on iOS
Other
412 stars 71 forks source link

Crashes when Emails included in markdown #24

Open joelfischerr opened 10 years ago

joelfischerr commented 10 years ago

When there are email adresses included in the document, markdown_output.m crashes.

case LINK:;
        NSURL *url = [NSURL URLWithString:elt->contents.link->url];
        if (url) {
            NSDictionary *linkAttibutes = @{@"attributedMarkdownURL": url};
            print_attr_element_list(out, elt->contents.link->label, attributes, merge(current, merge(attributes[elt->key], linkAttibutes)));
        } else {
            NSDictionary *attributesBroken = @{NSForegroundColorAttributeName: [TARGET_PLATFORM_COLOR redColor]}; // Make this attributes[BROKEN]
            print_attr_element_list(out, elt->contents.link->label, attributes, merge(current, attributesBroken));
            print_attr_string(out, [NSString stringWithFormat: @" (%@)", elt->contents.link->url], current);
        }
        break;
dreamwieber commented 10 years ago

Hmm, my guess is that elt->contents.link->url is null here. Confirm?

joelfischerr commented 10 years ago

Yes

dreamwieber commented 10 years ago

You could probably get around the crash for now by inserting an empty string rather than a nil one for now.

Sent from my iPhone

On May 4, 2014, at 6:06 AM, joelfischerr notifications@github.com wrote:

Yes

— Reply to this email directly or view it on GitHub.