From: David Bremner <david@tethera.net>
To: David Bremner <david@tethera.net>,
notmuch@notmuchmail.org,
Ciprian Dorin Craciun <ciprian.craciun@gmail.com>
Subject: [PATCH v2] lib/config: use g_key_file_get_string to read config values
Date: Thu, 30 Sep 2021 15:59:54 -0300 [thread overview]
Message-ID: <20210930185954.4132297-1-david@tethera.net> (raw)
In-Reply-To: <20210930182835.4125022-2-david@tethera.net>
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.
---
lib/config.cc | 2 +-
lib/open.cc | 4 ++--
test/T030-config.sh | 2 --
3 files changed, 3 insertions(+), 5 deletions(-)
diff --git a/lib/config.cc b/lib/config.cc
index 8775b00a..d57240d1 100644
--- a/lib/config.cc
+++ b/lib/config.cc
@@ -427,7 +427,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 8a835e98..0f44b858 100644
--- a/lib/open.cc
+++ b/lib/open.cc
@@ -199,7 +199,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);
@@ -637,7 +637,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 09dacda3..aacdb8c6 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)
--
2.33.0
next prev parent reply other threads:[~2021-09-30 19:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-04-24 10:36 Strip spaces in `tags` in `~/.notmuch-config` (and other fields) Ciprian Dorin Craciun
2020-04-24 11:12 ` David Bremner
2021-09-30 17:17 ` David Bremner
2021-09-30 17:17 ` [PATCH 1/2] test: known broken tests for leading/trailing ws in config David Bremner
2021-09-30 17:17 ` [PATCH 2/2] config: ignore leading/trailing spaces in ';'-delimited lists David Bremner
2021-09-30 18:28 ` [PATCH 1/2] test: known broken tests for escape characters in config files David Bremner
2021-09-30 18:28 ` [PATCH 2/2] lib/config: use g_key_file_get_string to read config values David Bremner
2021-09-30 18:59 ` David Bremner [this message]
2021-12-04 16:31 ` [PATCH 1/2] test: known broken tests for leading/trailing ws in config David Bremner
2021-12-05 12:41 ` Strip spaces in `tags` in `~/.notmuch-config` (and other fields) David Bremner
2021-12-13 9:09 ` Ciprian Craciun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://notmuchmail.org/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210930185954.4132297-1-david@tethera.net \
--to=david@tethera.net \
--cc=ciprian.craciun@gmail.com \
--cc=notmuch@notmuchmail.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://yhetil.org/notmuch.git/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).