diff options
| author | Burt P <pburt0@gmail.com> | 2019-09-06 23:39:53 -0500 | 
|---|---|---|
| committer | Leandro A. F. Pereira <leandro@hardinfo.org> | 2019-10-24 07:53:24 -0700 | 
| commit | 61b99db86d3a0c7ce6e319dc6a019a3795bf0ee6 (patch) | |
| tree | 922627146bdca49f2fdd60f8cfbf0f0e324a4b64 | |
| parent | b9c1e7359a9b5261a69be7e8f5a177a86f7cd85b (diff) | |
don't try to escape multi-column values in flatten_group()
Signed-off-by: Burt P <pburt0@gmail.com>
| -rw-r--r-- | hardinfo/info.c | 25 | 
1 files changed, 22 insertions, 3 deletions
diff --git a/hardinfo/info.c b/hardinfo/info.c index 5f108814..7f682dfe 100644 --- a/hardinfo/info.c +++ b/hardinfo/info.c @@ -259,6 +259,21 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint              struct InfoField *field = &g_array_index(group->fields, struct InfoField, i);              gchar tmp_tag[256] = ""; /* for generated tag */ +            gboolean do_escape = TRUE; +            if (field->value && strchr(field->value, '|') ) { +                /* turning off escaping for values that may have columns */ +                do_escape = FALSE; +                /* TODO:/FIXME: struct InfoField should store the column values +                 * in an array instead of packing them into one value with '|'. +                 * Then each value can be escaped and joined together with '|' +                 * for flatten(). unflatten() can then split on non-escaped '|', +                 * and unescape the result values into the column value array. +                 * Another way to do this might be to check +                 * .column_headers_visible in struct Info, but that is not +                 * available here. +                 */ +            } +              const gchar *tp = field->tag;              gboolean tagged = !!tp;              gboolean flagged = field->highlight || field->report_details; @@ -274,9 +289,13 @@ static void flatten_group(GString *output, const struct InfoGroup *group, guint                      tp);              } -            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); +            if (do_escape) { +                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 { +                g_string_append_printf(output, "%s=%s\n", field->name, field->value); +            }          }      } else if (group->computed) {          g_string_append_printf(output, "%s\n", group->computed);  | 
