ext/rinku/rinku.c in rinku-1.3.1 vs ext/rinku/rinku.c in rinku-1.4.0

- old
+ new

@@ -24,11 +24,10 @@ #define rb_enc_copy(dst, src) #endif #include "autolink.h" #include "buffer.h" -#include "houdini.h" #include <string.h> #include <stdlib.h> #include <stdio.h> #include <ctype.h> @@ -71,13 +70,13 @@ "<a href=\"mailto:", "<a href=\"", }; static void -autolink__html_escape(struct buf *ob, const struct buf *link, void *payload) +autolink__print(struct buf *ob, const struct buf *link, void *payload) { - houdini_escape_html0(ob, link->data, link->size, 0); + bufput(ob, link->data, link->size); } /* From sundown/html/html.c */ static int html_is_tag(const uint8_t *tag_data, size_t tag_size, const char *tagname) @@ -185,11 +184,11 @@ active_chars['W'] = AUTOLINK_ACTION_WWW; active_chars[':'] = AUTOLINK_ACTION_URL; } if (link_text_cb == NULL) - link_text_cb = &autolink__html_escape; + link_text_cb = &autolink__print; if (link_attr != NULL) { while (isspace(*link_attr)) link_attr++; } @@ -226,11 +225,11 @@ /* print the link */ if (link_end > 0) { bufput(ob, text + i, end - i - rewind); bufputs(ob, g_hrefs[(int)action]); - houdini_escape_href(ob, link->data, link->size); + bufput(ob, link->data, link->size); if (link_attr) { BUFPUTSL(ob, "\" "); bufputs(ob, link_attr); bufputc(ob, '>'); @@ -274,9 +273,16 @@ * auto_link(text, mode=:all, link_attr=nil, skip_tags=nil) * auto_link(text, mode=:all, link_attr=nil, skip_tags=nil) { |link_text| ... } * * Parses a block of text looking for "safe" urls or email addresses, * and turns them into HTML links with the given attributes. + * + * NOTE: The block of text may or may not be HTML; if the text is HTML, + * Rinku will skip the relevant tags to prevent double-linking and linking + * inside `pre` blocks by default. + * + * NOTE: If the input text is HTML, it's expected to be already escaped. + * Rinku will perform no escaping. * * NOTE: Currently the follow protocols are considered safe and are the * only ones that will be autolinked. * * http:// https:// ftp:// mailto://