From: erg Date: Tue, 27 Nov 2007 20:02:32 +0000 (+0000) Subject: Fix bug 1239 - output user name only if all ascii X-Git-Tag: LAST_LIBGRAPH~32^2~4996 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=d2904e58e80d443fa88b4889b0c4259c61434db7;p=graphviz Fix bug 1239 - output user name only if all ascii --- diff --git a/plugin/core/gvrender_core_svg.c b/plugin/core/gvrender_core_svg.c index 9000911be..d62d63591 100644 --- a/plugin/core/gvrender_core_svg.c +++ b/plugin/core/gvrender_core_svg.c @@ -31,6 +31,7 @@ #include #include #include +#include #include "macros.h" #include "const.h" @@ -110,6 +111,18 @@ static void svg_comment(GVJ_t * job, char *str) gvdevice_fputs(job, " -->\n"); } +/* isAscii: + * Return true if all characters in the string are ascii. + */ +static int isAscii (char* s) +{ + int c; + while ((c = *s++) != '\0') { + if (!isascii (c)) return 0; + } + return 1; +} + static void svg_begin_job(GVJ_t * job) { char *s; @@ -131,8 +144,17 @@ static void svg_begin_job(GVJ_t * job) gvdevice_fputs(job, xml_string(job->common->info[1])); gvdevice_fputs(job, " ("); gvdevice_fputs(job, xml_string(job->common->info[2])); - gvdevice_fputs(job, ")\n For user: "); - gvdevice_fputs(job, xml_string(job->common->user)); + /* We have absolutely no idea what character set the username + * may be in. To be conservative, we only output the username + * if it is all ascii. Since SVG output is UTF-8, we could check + * if the string appears to be in this format and allow it. + */ + if (isAscii (job->common->user)) { + gvdevice_fputs(job, ")\n For user: "); + gvdevice_fputs(job, xml_string(job->common->user)); + } + else + gvdevice_fputs(job, ")\n"); gvdevice_fputs(job, " -->\n"); }