From 9c478d2a23fac7a2b0d7aa41981571d27631134e Mon Sep 17 00:00:00 2001 From: Burt P Date: Sun, 21 Jul 2019 12:45:56 -0500 Subject: shell/info: allow newlines in values Also fixed a FIXME: use g_key_file_get_string_list(). Signed-off-by: Burt P --- hardinfo/info.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'hardinfo/info.c') diff --git a/hardinfo/info.c b/hardinfo/info.c index bfc11fc2..ac18e0d9 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -18,6 +18,12 @@ #include "hardinfo.h" +/* Using a slightly modified gg_key_file_parse_string_as_value() + * from GLib in flatten(), to escape characters and the separator. + * The function is not public in GLib and we don't have a GKeyFile + * to pass it anyway. */ +#include "gg_key_file_parse_string_as_value.c" + static const gchar *info_column_titles[] = { "TextValue", "Value", "Progress", "Extra1", "Extra2" }; @@ -267,7 +273,9 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint tp); } - g_string_append_printf(output, "%s=%s\n", field->name, field->value); + gchar *escaped_value = gg_key_file_parse_string_as_value(field->value, '|'); + g_string_append_printf(output, "%s=%s\n", field->name, escaped_value); + g_free(escaped_value); } } else if (group->computed) { g_string_append_printf(output, "%s\n", group->computed); -- cgit v1.2.3