Bug#493553: rrdtool: broken with non-UTF8 locales: Invalid UTF-8 string passed to pango_layout_set_text()
tags 493553 + patch pending thanks Hi, On Sun, Aug 03, 2008 at 09:29:10AM +0300, Meelis Roos wrote: When invoking rrdtool graph in an environment with non-UTF8 locale (like my et_EE.ISO-8859-15) it still assumes the input is UTF-8. This results in messages like (process:8043): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text() and broken diacritics in graph output. Might also be a problem with pango but it seems more likely that rrdtool is wrong here. Well, imho, this is caused by some strange behavior of libpango. Anyway, that behavior seems to be intended, so this is a bug in rrdtool. The problem is, that pango_layout_set_text() and pango_layout_set_markup() expect strings which are UTF-8 encoded (instead of using the encoding as specified by the locale settings), so rrdtool has to make sure that this is true. The attached patch converts the given string to UTF-8 using glib's g_locale_to_utf8() function. This function expects the string to be encoded as specified by the locale settings, so this will fail if e.g. you're using some script which is encoded in some way incompatible to the locale settings. In this case, the patch falls back to use the original string as provided by the user as there is no way to tell how to interpret that string. So, in this case, you will still get the old behavior (that pango warning and messed up strings in the graph). However, imho this is perfectly fine since it should be up to the user to take care of a sane environment. I've just done some basic tests of that patch, so some more feedback would be appreciated. Tobi, besides that, the patch should be fine for inclusion in the next release of rrdtool. Cheers, Sebastian -- Sebastian tokkee Harl +++ GnuPG-ID: 0x8501C7FC +++ http://tokkee.org/ Those who would give up Essential Liberty to purchase a little Temporary Safety, deserve neither Liberty nor Safety. -- Benjamin Franklin From eef8309d3863ced3b93948412a81cc7a67990dd8 Mon Sep 17 00:00:00 2001 From: Sebastian Harl [EMAIL PROTECTED] Date: Sun, 3 Aug 2008 21:56:33 +0200 Subject: [PATCH] rrd_gfx.c: Convert strings passed to pango_layout_set_{markup,text}() to UTF-8. Those functions expect UTF-8 strings and will else complain loudly. --- src/rrd_gfx.c | 15 +-- 1 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/rrd_gfx.c b/src/rrd_gfx.c index ca7f9ea..ca9b2dc 100644 --- a/src/rrd_gfx.c +++ b/src/rrd_gfx.c @@ -133,6 +133,8 @@ static PangoLayout *gfx_prep_text( long tab_shift = fmod(x, tabwidth); int border = im-text_prop[TEXT_PROP_LEGEND].size * 2.0; +gchar *utf8_text; + PangoTabArray *tab_array; PangoContext *pango_context; @@ -156,10 +158,19 @@ static PangoLayout *gfx_prep_text( font_desc = pango_font_description_from_string(font); pango_font_description_set_size(font_desc, size * PANGO_SCALE); pango_layout_set_font_description(layout, font_desc); + +/* pango expects the string to be utf-8 encoded */ +utf8_text = g_locale_to_utf8((const gchar *)text, -1, NULL, NULL, NULL); + +/* In case of an error, i.e. utf8_text == NULL (locale settings messed + * up?), we fall back to a possible invalid UTF-8 string warning instead + * of provoking a failed assertion in libpango. */ if (im-with_markup) -pango_layout_set_markup(layout, text, -1); +pango_layout_set_markup(layout, utf8_text ? utf8_text : text, -1); else -pango_layout_set_text(layout, text, -1); +pango_layout_set_text(layout, utf8_text ? utf8_text : text, -1); + +g_free(utf8_text); return layout; } -- 1.6.0.rc0.79.gb0320 signature.asc Description: Digital signature
Bug#493553: [rrd-developers] Bug#493553: rrdtool: broken with non-UTF8 locales: Invalid UTF-8 string passed to pango_layout_set_text()
Hi Sebastian, cool ... thanks ... I have included cheers tobi Today Sebastian Harl wrote: tags 493553 + patch pending thanks Hi, On Sun, Aug 03, 2008 at 09:29:10AM +0300, Meelis Roos wrote: When invoking rrdtool graph in an environment with non-UTF8 locale (like my et_EE.ISO-8859-15) it still assumes the input is UTF-8. This results in messages like (process:8043): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text() and broken diacritics in graph output. Might also be a problem with pango but it seems more likely that rrdtool is wrong here. Well, imho, this is caused by some strange behavior of libpango. Anyway, that behavior seems to be intended, so this is a bug in rrdtool. The problem is, that pango_layout_set_text() and pango_layout_set_markup() expect strings which are UTF-8 encoded (instead of using the encoding as specified by the locale settings), so rrdtool has to make sure that this is true. The attached patch converts the given string to UTF-8 using glib's g_locale_to_utf8() function. This function expects the string to be encoded as specified by the locale settings, so this will fail if e.g. you're using some script which is encoded in some way incompatible to the locale settings. In this case, the patch falls back to use the original string as provided by the user as there is no way to tell how to interpret that string. So, in this case, you will still get the old behavior (that pango warning and messed up strings in the graph). However, imho this is perfectly fine since it should be up to the user to take care of a sane environment. I've just done some basic tests of that patch, so some more feedback would be appreciated. Tobi, besides that, the patch should be fine for inclusion in the next release of rrdtool. Cheers, Sebastian -- Tobi Oetiker, OETIKER+PARTNER AG, Aarweg 15 CH-4600 Olten, Switzerland http://it.oetiker.ch [EMAIL PROTECTED] ++41 62 775 9902 / sb: -9900 -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]
Bug#493553: rrdtool: broken with non-UTF8 locales: Invalid UTF-8 string passed to pango_layout_set_text()
Package: rrdtool Version: 1.3.1-2 Severity: normal When invoking rrdtool graph in an environment with non-UTF8 locale (like my et_EE.ISO-8859-15) it still assumes the input is UTF-8. This results in messages like (process:8043): Pango-WARNING **: Invalid UTF-8 string passed to pango_layout_set_text() and broken diacritics in graph output. Might also be a problem with pango but it seems more likely that rrdtool is wrong here. -- System Information: Debian Release: lenny/sid APT prefers unstable APT policy: (500, 'unstable') Architecture: i386 (i686) Kernel: Linux 2.6.26 (PREEMPT) Locale: LANG=et_EE.ISO-8859-15, LC_CTYPE=et_EE.ISO-8859-15 (charmap=ISO-8859-15) Shell: /bin/sh linked to /bin/bash Versions of packages rrdtool depends on: ii libc6 2.7-13GNU C Library: Shared libraries ii libfontconfig1 2.6.0-1 generic font configuration library ii libpixman-1-0 0.10.0-2 pixel-manipulation library for X a ii libpng12-0 1.2.27-1 PNG library - runtime ii librrd41.3.1-2 Time-series data storage and displ ii libx11-6 2:1.1.4-2 X11 client-side library ii libxcb-render-util00.2+git41-1 utility libraries for X C Binding ii libxcb-render0 1.1-1.1 X C Binding, render extension ii libxcb11.1-1.1 X C Binding ii libxrender11:0.9.4-2 X Rendering Extension client libra ii zlib1g 1:1.2.3.3.dfsg-12 compression library - runtime rrdtool recommends no packages. Versions of packages rrdtool suggests: pn librrds-perl none (no description available) -- no debconf information -- To UNSUBSCRIBE, email to [EMAIL PROTECTED] with a subject of unsubscribe. Trouble? Contact [EMAIL PROTECTED]