1
0
mirror of https://github.com/haiwen/seafile-server.git synced 2025-08-31 23:19:36 +00:00

Remove trailing spaces from values when reading config file.

This commit is contained in:
Jonathan Xu
2016-12-28 15:04:13 +08:00
parent 6f70a910e1
commit 30e16a80bd
5 changed files with 37 additions and 46 deletions

View File

@@ -1226,28 +1226,6 @@ void parse_key_value_pairs2 (char *string, KeyValueFunc2 func, void *data)
}
}
/**
* handle the empty string problem.
*/
gchar*
ccnet_key_file_get_string (GKeyFile *keyf,
const char *category,
const char *key)
{
gchar *v;
if (!g_key_file_has_key (keyf, category, key, NULL))
return NULL;
v = g_key_file_get_string (keyf, category, key, NULL);
if (v != NULL && v[0] == '\0') {
g_free(v);
return NULL;
}
return v;
}
/**
* string_list_is_exists:
* @str_list:
@@ -2483,3 +2461,20 @@ is_permission_valid (const char *perm)
return strcmp (perm, "r") == 0 || strcmp (perm, "rw") == 0;
}
char *
seaf_key_file_get_string (GKeyFile *key_file,
const char *group,
const char *key,
GError **error)
{
char *v;
v = g_key_file_get_string (key_file, group, key, error);
if (!v || v[0] == '\0') {
g_free (v);
return NULL;
}
return g_strchomp(v);
}