[Xfce4-commits] <xfce4-weather-plugin:master> weather-config: Be a bit more generous when sanitizing location name.

Harald Judt noreply at xfce.org
Thu Aug 2 23:08:03 CEST 2012


Updating branch refs/heads/master
         to 6e8ad2ce7cac713bd02e5116f8ddc69404d88ecd (commit)
       from 58d13a246eeebc312e751c6db5d364db01fc4476 (commit)

commit 6e8ad2ce7cac713bd02e5116f8ddc69404d88ecd
Author: Harald Judt <h.judt at gmx.at>
Date:   Thu Aug 2 12:08:42 2012 +0200

    weather-config: Be a bit more generous when sanitizing location name.
    
    Instead of cutting off the rest of the string after the first
    comma ',', search for a second comma and cut it off after that.

 panel-plugin/weather-config.c |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

diff --git a/panel-plugin/weather-config.c b/panel-plugin/weather-config.c
index 0c9dab4..5ff3f4c 100644
--- a/panel-plugin/weather-config.c
+++ b/panel-plugin/weather-config.c
@@ -198,11 +198,17 @@ make_label(void)
 gchar *
 sanitize_location_name(const gchar *location_name)
 {
-    gchar *pos, sane[LOC_NAME_MAX_LEN * 4];
+    gchar *pos, *pos2, sane[LOC_NAME_MAX_LEN * 4];
     glong len, offset;
 
     pos = g_utf8_strchr(location_name, -1, ',');
     if (pos != NULL) {
+        pos2 = pos;
+        while (pos2 = g_utf8_find_next_char(pos2, NULL))
+            if (g_utf8_get_char(pos2) == ',') {
+                pos = pos2;
+                break;
+            }
         offset = g_utf8_pointer_to_offset(location_name, pos);
         if (offset > LOC_NAME_MAX_LEN)
             offset = LOC_NAME_MAX_LEN;


More information about the Xfce4-commits mailing list