diff options
author | Nick Wellnhofer <wellnhofer@aevum.de> | 2020-01-18 23:12:37 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2020-01-23 08:25:54 -0800 |
commit | b237924585e61532ada774bf9e70eadff00666dc (patch) | |
tree | 4355e86e19736d1eeffd905cdbc2d2b6ea7a6430 /src/html.c | |
parent | 3acbdf0965859c55fa36c65a4c0e17e92012687c (diff) |
Use C string instead of chunk for link URL and title
Use zero-terminated C strings instead of cmark_chunks without storing
the length. This introduces a few additional strlen computations,
but overhead should be low.
Allows to reduce size of struct cmark_node later.
Diffstat (limited to 'src/html.c')
-rw-r--r-- | src/html.c | 22 |
1 files changed, 12 insertions, 10 deletions
@@ -280,13 +280,14 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, if (entering) { cmark_strbuf_puts(html, "<a href=\""); if ((options & CMARK_OPT_UNSAFE) || - !(scan_dangerous_url(&node->as.link.url, 0))) { - houdini_escape_href(html, node->as.link.url.data, - node->as.link.url.len); + !(_scan_dangerous_url(node->as.link.url))) { + houdini_escape_href(html, node->as.link.url, + strlen((char *)node->as.link.url)); } - if (node->as.link.title.len) { + if (node->as.link.title) { cmark_strbuf_puts(html, "\" title=\""); - escape_html(html, node->as.link.title.data, node->as.link.title.len); + escape_html(html, node->as.link.title, + strlen((char *)node->as.link.title)); } cmark_strbuf_puts(html, "\">"); } else { @@ -298,16 +299,17 @@ static int S_render_node(cmark_node *node, cmark_event_type ev_type, if (entering) { cmark_strbuf_puts(html, "<img src=\""); if ((options & CMARK_OPT_UNSAFE) || - !(scan_dangerous_url(&node->as.link.url, 0))) { - houdini_escape_href(html, node->as.link.url.data, - node->as.link.url.len); + !(_scan_dangerous_url(node->as.link.url))) { + houdini_escape_href(html, node->as.link.url, + strlen((char *)node->as.link.url)); } cmark_strbuf_puts(html, "\" alt=\""); state->plain = node; } else { - if (node->as.link.title.len) { + if (node->as.link.title) { cmark_strbuf_puts(html, "\" title=\""); - escape_html(html, node->as.link.title.data, node->as.link.title.len); + escape_html(html, node->as.link.title, + strlen((char *)node->as.link.title)); } cmark_strbuf_puts(html, "\" />"); |