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 /common | |
parent | 575aa0c9325e68a60514cea949a40164e8c2670b (diff) | |
download | lightdm-git-522d3afa3e00f8e14e535f1c236d183713171c3b.tar.gz |
Handle trailing whitespace on boolean values
Diffstat (limited to 'common')
-rw-r--r-- | common/configuration.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/common/configuration.c b/common/configuration.c index dc7831a8..e7bee309 100644 --- a/common/configuration.c +++ b/common/configuration.c @@ -317,7 +317,22 @@ config_set_boolean (Configuration *config, const gchar *section, const gchar *ke gboolean config_get_boolean (Configuration *config, const gchar *section, const gchar *key) { - return g_key_file_get_boolean (config->priv->key_file, section, key, NULL); + /* We don't use the standard function because it doesn't work with trailing whitespace: + * https://bugzilla.gnome.org/show_bug.cgi?id=664740 + */ + /*return g_key_file_get_boolean (config->priv->key_file, section, key, NULL);*/ + + gchar *value; + gboolean v; + + value = g_key_file_get_value (config->priv->key_file, section, key, NULL); + if (!value) + return FALSE; + g_strchomp (value); + v = strcmp (value, "true") == 0; + g_free (value); + + return v; } static void |