From 46e9ed6e0c118dc6b6a4a4833d6c960701849fdb Mon Sep 17 00:00:00 2001 From: John MacFarlane Date: Sun, 5 Jul 2015 12:46:37 -0700 Subject: commonmark writer: correctly handle email autolinks. --- src/commonmark.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/commonmark.c b/src/commonmark.c index 4594748..07377a0 100644 --- a/src/commonmark.c +++ b/src/commonmark.c @@ -240,6 +240,8 @@ is_autolink(cmark_node *node) cmark_chunk *title; cmark_chunk *url; cmark_node *link_text; + char *realurl; + int realurllen; if (node->type != CMARK_NODE_LINK) { return false; @@ -258,8 +260,14 @@ is_autolink(cmark_node *node) link_text = node->first_child; cmark_consolidate_text_nodes(link_text); - return (url->len == link_text->as.literal.len && - strncmp((char*)url->data, + realurl = (char*)url->data; + realurllen = url->len; + if (strncmp(realurl, "mailto:", 7) == 0) { + realurl += 7; + realurllen -= 7; + } + return (realurllen == link_text->as.literal.len && + strncmp(realurl, (char*)link_text->as.literal.data, link_text->as.literal.len) == 0); } -- cgit v1.2.3