diff options
author | Robert Ancell <robert.ancell@canonical.com> | 2015-10-21 16:07:24 +1300 |
---|---|---|
committer | Robert Ancell <robert.ancell@canonical.com> | 2015-10-21 16:07:24 +1300 |
commit | 522d3afa3e00f8e14e535f1c236d183713171c3b (patch) | |
tree | 379b745184d61f1ed253b6dbba65a3d015ba2a41 /src | |
parent | 575aa0c9325e68a60514cea949a40164e8c2670b (diff) | |
download | lightdm-git-522d3afa3e00f8e14e535f1c236d183713171c3b.tar.gz |
Handle trailing whitespace on boolean values
Diffstat (limited to 'src')
-rw-r--r-- | src/seat.c | 14 |
1 files changed, 13 insertions, 1 deletions
@@ -147,7 +147,19 @@ seat_get_string_list_property (Seat *seat, const gchar *name) gboolean seat_get_boolean_property (Seat *seat, const gchar *name) { - return g_strcmp0 (seat_get_string_property (seat, name), "true") == 0; + const gchar *value; + gint i, length = 0; + + value = seat_get_string_property (seat, name); + if (!value) + return FALSE; + + /* Count the number of non-whitespace characters */ + for (i = 0; value[i]; i++) + if (!g_ascii_isspace (value[i])) + length = i + 1; + + return strncmp (value, "true", MAX (length, 4)) == 0; } gint |