diff options
author | John MacFarlane <jgm@berkeley.edu> | 2015-07-05 12:46:37 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2015-07-05 12:46:37 -0700 |
commit | 46e9ed6e0c118dc6b6a4a4833d6c960701849fdb (patch) | |
tree | 2ac7516dd5c6efecbcd0279ea03660389e3623b6 /src | |
parent | 61999187556690dbb837f4049d14d51760978a97 (diff) |
commonmark writer: correctly handle email autolinks.
Diffstat (limited to 'src')
-rw-r--r-- | src/commonmark.c | 12 |
1 files 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); } |