From: Matthew Fernandez Date: Mon, 4 Oct 2021 00:13:29 +0000 (-0700) Subject: replace 'gvputs(… xml_url_string(…))' with 'xml_escape(…)' X-Git-Tag: 2.49.2~19^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bb9e55e3a945bf09b851720d08043c01592ee671;p=graphviz replace 'gvputs(… xml_url_string(…))' with 'xml_escape(…)' Similar to previous `xml_string` and `xml_string0` related changes, this avoids dynamic allocations and makes the affected code thread safe. Related to #1868. --- diff --git a/plugin/core/gvrender_core_map.c b/plugin/core/gvrender_core_map.c index 836bab70c..e17a529b8 100644 --- a/plugin/core/gvrender_core_map.c +++ b/plugin/core/gvrender_core_map.c @@ -20,6 +20,12 @@ typedef enum { FORMAT_IMAP, FORMAT_ISMAP, FORMAT_CMAP, FORMAT_CMAPX, } format_type; +// wrapper around `xml_escape` to set flags for URL escaping +static void xml_url_puts(GVJ_t *job, const char *s) { + const xml_flags_t flags = {0}; + (void)xml_escape(s, flags, (int(*)(void*, const char*))gvputs, job); +} + static void map_output_shape (GVJ_t *job, map_shape_t map_shape, pointf * AF, int nump, char* url, char *tooltip, char *target, char *id) { @@ -89,12 +95,12 @@ static void map_output_shape (GVJ_t *job, map_shape_t map_shape, pointf * AF, in } if (id && id[0]) { gvputs(job, " id=\""); - gvputs(job, xml_url_string(id)); + xml_url_puts(job, id); gvputs(job, "\""); } if (url && url[0]) { gvputs(job, " href=\""); - gvputs(job, xml_url_string(url)); + xml_url_puts(job, url); gvputs(job, "\""); } if (target && target[0]) { diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 1e94dd303..24f3a3959 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -344,7 +344,8 @@ svg_begin_anchor(GVJ_t * job, char *href, char *tooltip, char *target, "