Package: fbpanel
Version: 6.1-4

I submitted this patch several months ago to upstream.  You can see it
here:

https://sourceforge.net/tracker/?func=detail&aid=3131882&group_id=66031&atid=513127

I'm not sure upstream is going to take it.  As a package maintainer
myself, I'm generally reluctant to accept patches to the debian version
of something if upstream has not taken the patch, but I figured I'd
still offer this in case you'll be inclined to take it.  In this case, I
think it's pretty safe since it doesn't change the default behavior of
the plugin, but I'll let you be the judge.

The attached patch can be applied to the fbpanel source package for
6.1-4.  It updates debian/patches/series and adds a new patch called
genmon-pango.patch.  That patch adds the flag AllowPangoMarkup to the
configuration options for the genmon plugin.  If that flag is turned on,
then the genmon plugin allows pango markup to appear in the text output
by the process genmon calls.

I find this to be extremely useful.  I have my own very customized mail
monitoring tool that gives me information about specific inboxes, and I
add pango markup so that I can have different colors and render the
output in a fixed-with font.  This both enables me to notice changes and
also prevent the genmon area's size from changing based on which
characters are present in the output.  (I think it's really bad UI
design to have variable-length areas on something that just concatenates
a bunch of areas....it makes everything to the right of the genmon area
shift around whenever the text changes.)  The change is very small, and
a quick inspection of the patch should be enough to convince someone
that it's safe.

The patch also fixes a one-line bug: as written, genmon might end up
with a buffer that's not null-terminated if it fails to read from the
child process.  I should probably report that as a separate issue since
it could cause the process to read invalid memory.  It doesn't cause the
process to write past the end of a buffer, so it's not as much a
security problem as just a potential crash opportunity.

Thanks for your consideration.  If you decide not to accept this patch
either because you don't like it or because you don't want a
functionality enhancement patch that deviates from upstream, go ahead
and just close this bug.  I will respect your decision.

-- 
Jay Berkenbilt <q...@debian.org>

diff -urN ../fbpanel-6.1-4/debian/patches/genmon-pango.patch ./debian/patches/genmon-pango.patch
--- ../fbpanel-6.1-4/debian/patches/genmon-pango.patch	1969-12-31 19:00:00.000000000 -0500
+++ ./debian/patches/genmon-pango.patch	2011-09-04 09:37:53.481791463 -0400
@@ -0,0 +1,75 @@
+Index: fbpanel-6.1/plugins/genmon/genmon.c
+===================================================================
+--- fbpanel-6.1.orig/plugins/genmon/genmon.c	2011-09-04 09:37:08.585792098 -0400
++++ fbpanel-6.1/plugins/genmon/genmon.c	2011-09-04 09:37:43.541791603 -0400
+@@ -31,6 +31,7 @@
+     int time;
+     int timer;
+     int max_text_len;
++    int allow_pango_markup;
+     char *command;
+     char *textsize;
+     char *textcolor;
+@@ -41,24 +42,41 @@
+ text_update(genmon_priv *gm)
+ {
+     FILE *fp;  
+-    char text[256];
++    char *text;
++    int text_len;
+     char *markup;
+     int len;
+ 
+     ENTER;
+     fp = popen(gm->command, "r");
+-    fgets(text, sizeof(text), fp);
++    /* allow for multi-byte characters and a null-terminator */
++    text_len = (4 * gm->max_text_len) + 1;
++    text = malloc(text_len);
++    if (text == NULL)
++    {
++	/* ignore for now; try again later */
++	RET(TRUE);
++    }
++    /* Ensure null-termination even if read fails */
++    text[0] = 0;
++    fgets(text, text_len, fp);
+     pclose(fp);
+     len = strlen(text) - 1;
+     if (len >= 0) {
+         if (text[len] == '\n')
+             text[len] = 0;
+         
+-        markup = g_markup_printf_escaped(FMT, gm->textsize, gm->textcolor,
+-            text);
+-        gtk_label_set_markup (GTK_LABEL(gm->main), markup);
+-        g_free(markup);
++        if (gm->allow_pango_markup) {
++            gtk_label_set_markup (GTK_LABEL(gm->main), text);
++        }
++        else {
++            markup = g_markup_printf_escaped(FMT, gm->textsize, gm->textcolor,
++                text);
++            gtk_label_set_markup (GTK_LABEL(gm->main), markup);
++            g_free(markup);
++        }
+     }
++    free(text);
+     RET(TRUE);
+ }
+ 
+@@ -86,12 +104,14 @@
+     gm->textsize = "medium";
+     gm->textcolor = "darkblue";
+     gm->max_text_len = 30;
++    gm->allow_pango_markup = 0;
+     
+     XCG(p->xc, "Command", &gm->command, str);
+     XCG(p->xc, "TextSize", &gm->textsize, str);
+     XCG(p->xc, "TextColor", &gm->textcolor, str);
+     XCG(p->xc, "PollingTime", &gm->time, int);
+     XCG(p->xc, "MaxTextLength", &gm->max_text_len, int);
++    XCG(p->xc, "AllowPangoMarkup", &gm->allow_pango_markup, int);
+     
+     gm->main = gtk_label_new(NULL);
+     gtk_label_set_max_width_chars(GTK_LABEL(gm->main), gm->max_text_len);
diff -urN ../fbpanel-6.1-4/debian/patches/series ./debian/patches/series
--- ../fbpanel-6.1-4/debian/patches/series	2011-08-15 09:43:59.000000000 -0400
+++ ./debian/patches/series	2011-09-04 09:37:00.465792208 -0400
@@ -3,3 +3,4 @@
 debian-logo.patch
 gui-typo.patch
 ftbfs-hurd.patch
+genmon-pango.patch

Reply via email to