From: David Bremner Date: Thu, 30 Sep 2021 18:59:54 +0000 (-0300) Subject: lib/config: use g_key_file_get_string to read config values X-Git-Tag: 0.35_rc0~81 X-Git-Url: https://git.notmuchmail.org/git?p=notmuch;a=commitdiff_plain;h=18cdd21b8b2ef056062700607eade43909c32cd2 lib/config: use g_key_file_get_string to read config values Unlike the previous g_key_file_get_value, this version processes escape codes for whitespace and \. The remaining two broken tests from the last commit are because "notmuch config get" treats every value as a list, and thus the previously introduces stripping of leading whitespace applies. --- diff --git a/lib/config.cc b/lib/config.cc index e502858d..7a2882de 100644 --- a/lib/config.cc +++ b/lib/config.cc @@ -435,7 +435,7 @@ _notmuch_config_load_from_file (notmuch_database_t *notmuch, for (gchar **keys_p = keys; *keys_p; keys_p++) { char *absolute_key = talloc_asprintf (notmuch, "%s.%s", *grp, *keys_p); char *normalized_val; - val = g_key_file_get_value (file, *grp, *keys_p, NULL); + val = g_key_file_get_string (file, *grp, *keys_p, NULL); if (! val) { status = NOTMUCH_STATUS_FILE_ERROR; goto DONE; diff --git a/lib/open.cc b/lib/open.cc index c2cb2818..a91d22ef 100644 --- a/lib/open.cc +++ b/lib/open.cc @@ -198,7 +198,7 @@ _choose_database_path (void *ctx, } if (! *database_path && key_file) { - char *path = g_key_file_get_value (key_file, "database", "path", NULL); + char *path = g_key_file_get_string (key_file, "database", "path", NULL); if (path) { if (path[0] == '/') *database_path = talloc_strdup (ctx, path); @@ -642,7 +642,7 @@ notmuch_database_create_with_config (const char *database_path, if (key_file && ! split) { char *mail_root = notmuch_canonicalize_file_name ( - g_key_file_get_value (key_file, "database", "mail_root", NULL)); + g_key_file_get_string (key_file, "database", "mail_root", NULL)); char *db_path = notmuch_canonicalize_file_name (database_path); split = (mail_root && (0 != strcmp (mail_root, db_path))); diff --git a/test/T030-config.sh b/test/T030-config.sh index 1fdde9fe..43bbce31 100755 --- a/test/T030-config.sh +++ b/test/T030-config.sh @@ -85,13 +85,11 @@ output=$(notmuch config get foo.bar) test_expect_equal "${output}" "thing other" test_begin_subtest "Round trip config item with embedded backslash" -test_subtest_known_broken notmuch config set foo.bar 'thing\other' output=$(notmuch config get foo.bar) test_expect_equal "${output}" "thing\other" test_begin_subtest "Round trip config item with embedded NL/CR" -test_subtest_known_broken notmuch config set foo.bar 'thing other' output=$(notmuch config get foo.bar)