diff options
-rw-r--r-- | html.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/html.c b/html.c index 77438a0..34ffb16 100644 --- a/html.c +++ b/html.c @@ -228,12 +228,12 @@ static void swap(char *a, char *b) { static int htmlMarkupURLs(FILE *file, char *buf) { static regex_t regex; - compile(®ex, "(^|[[:space:]<])(https?:[^[:space:]>]+)(.|$)"); + compile(®ex, "(^|[[:space:]<])(https?:[^[:space:]>]+)"); int error; char *ptr; - regmatch_t match[4]; - for (ptr = buf; !regexec(®ex, ptr, 4, match, 0); ptr += match[2].rm_eo) { + regmatch_t match[3]; + for (ptr = buf; !regexec(®ex, ptr, 3, match, 0); ptr += match[2].rm_eo) { char nul = '\0'; swap(&ptr[match[2].rm_so], &nul); @@ -242,14 +242,14 @@ static int htmlMarkupURLs(FILE *file, char *buf) { swap(&ptr[match[2].rm_so], &nul); const char *template = Q(<a href="[url]">[url]</a>); - swap(&ptr[match[3].rm_so], &nul); + swap(&ptr[match[2].rm_eo], &nul); struct Variable vars[] = { { "url", &ptr[match[2].rm_so] }, {0}, }; error = templateRender(file, template, vars, escapeXML); if (error) return error; - swap(&ptr[match[3].rm_so], &nul); + swap(&ptr[match[2].rm_eo], &nul); } return escapeXML(file, ptr); } |