From 4a3fa85ee7ad7428349421b2bace9b9a2aa7928d Mon Sep 17 00:00:00 2001 From: Witold Filipczyk Date: Sun, 23 Apr 2023 15:00:05 +0200 Subject: [PATCH] [link] Convert href for anchor to terminal codepage, usually utf-8. Refs #221 --- src/document/html/parser/link.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/document/html/parser/link.c b/src/document/html/parser/link.c index 6e0051ce..fbce1578 100644 --- a/src/document/html/parser/link.c +++ b/src/document/html/parser/link.c @@ -54,13 +54,17 @@ html_a(struct html_context *html_context, char *a, char *href; href = get_url_val(a, "href", html_context->doc_cp); + if (href) { char *target; + char *href_converted = convert_string(renderer_context.convert_table, href, strlen(href), + html_context->options->cp, CSM_NONE, NULL, NULL, NULL); - mem_free_set(&elformat.link, - join_urls(html_context->base_href, - trim_chars(href, ' ', 0))); - + if (href_converted) { + mem_free_set(&elformat.link, + join_urls(html_context->base_href, trim_chars(href_converted, ' ', 0))); + mem_free(href_converted); + } mem_free(href); target = get_target(html_context->options, a);