wgt-info: Enforce lower case ids and version
authorJosé Bollo <jose.bollo@iot.bzh>
Wed, 14 Dec 2016 10:17:47 +0000 (11:17 +0100)
committerJosé Bollo <jose.bollo@iot.bzh>
Wed, 14 Dec 2016 10:17:47 +0000 (11:17 +0100)
This will be used next to avoid faking identity
of applications using the case difference.

Change-Id: I13cbdd5124b58b2a72c15054df6f3cd0e11a2cc5
Signed-off-by: José Bollo <jose.bollo@iot.bzh>
src/wgt-info.c

index c8308fa..089a563 100644 (file)
@@ -20,6 +20,7 @@
 #include <string.h>
 #include <errno.h>
 #include <assert.h>
+#include <ctype.h>
 
 #include <libxml/tree.h>
 
@@ -117,6 +118,16 @@ static char *mkidaver(char *id, char *ver)
        return NULL;
 }
 
+static void make_lowercase(char *s)
+{
+       if (s) {
+               while(*s) {
+                       *s = (char)tolower(*s);
+                       s++;
+               }
+       }
+}
+
 static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, int want_preferences)
 {
        xmlNodePtr node, pnode;
@@ -132,8 +143,10 @@ static int fill_desc(struct wgt_desc *desc, int want_icons, int want_features, i
                return -1;
        }
        desc->id = xmlGetProp(node, wgt_config_string_id);
+       make_lowercase(desc->id);
        desc->version = xmlGetProp(node, wgt_config_string_version);
        desc->ver = mkver(desc->version);
+       make_lowercase(desc->ver);
        desc->idaver = mkidaver(desc->id, desc->ver);
        desc->width = getpropnum(node, wgt_config_string_width, 0);
        desc->height = getpropnum(node, wgt_config_string_height, 0);