Skip to content

Commit

Permalink
commonmark writer: correctly handle email autolinks.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgm committed Jul 5, 2015
1 parent 6199918 commit 46e9ed6
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/commonmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
}
Expand Down

0 comments on commit 46e9ed6

Please sign in to comment.