Strip leading/trailing whitespace when parsing colors and other strings (bug #4937)
authorDana Jansens <danakj@orodu.net>
Fri, 14 Oct 2011 21:06:05 +0000 (17:06 -0400)
committerDana Jansens <danakj@orodu.net>
Fri, 14 Oct 2011 21:23:52 +0000 (17:23 -0400)
obrender/theme.c

index e06706da1c99c27832bf7aec96acdd9bae862d09..92cb2a27365f0b3478a14132b8a6908487b6a451 100644 (file)
@@ -1798,6 +1798,7 @@ static gboolean read_string(XrmDatabase db, const gchar *rname, gchar **value)
 
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
+        g_strstrip(retvalue.addr);
         *value = retvalue.addr;
         ret = TRUE;
     }
@@ -1816,7 +1817,13 @@ static gboolean read_color(XrmDatabase db, const RrInstance *inst,
 
     if (XrmGetResource(db, rname, rclass, &rettype, &retvalue) &&
         retvalue.addr != NULL) {
-        RrColor *c = RrColorParse(inst, retvalue.addr);
+        /* strip leading/trailing whitespace, but the returned value is
+           inside the X db and we are not to modify it, so we must make a copy
+        */
+        RrColor *c;
+
+        g_strstrip(retvalue.addr);
+        c = RrColorParse(inst, retvalue.addr);
         if (c != NULL) {
             *value = c;
             ret = TRUE;