From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp2 ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms0.migadu.com with LMTPS id eJ/fAzwJVmFV+AAAgWs5BA (envelope-from ) for ; Thu, 30 Sep 2021 21:00:12 +0200 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp2 with LMTPS id 2Ao3OzsJVmE0QQAAB5/wlQ (envelope-from ) for ; Thu, 30 Sep 2021 19:00:11 +0000 Received: from mail.notmuchmail.org (nmbug.tethera.net [144.217.243.247]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6A14F32E77 for ; Thu, 30 Sep 2021 21:00:11 +0200 (CEST) Received: from nmbug.tethera.net (localhost [127.0.0.1]) by mail.notmuchmail.org (Postfix) with ESMTP id C1B9126DC3; Thu, 30 Sep 2021 15:00:07 -0400 (EDT) Received: from fethera.tethera.net (fethera.tethera.net [198.245.60.197]) by mail.notmuchmail.org (Postfix) with ESMTP id 8EAFF26D8C for ; Thu, 30 Sep 2021 15:00:04 -0400 (EDT) Received: by fethera.tethera.net (Postfix, from userid 1001) id 780965FD5C; Thu, 30 Sep 2021 15:00:04 -0400 (EDT) Received: (nullmailer pid 4132311 invoked by uid 1000); Thu, 30 Sep 2021 19:00:00 -0000 From: David Bremner To: David Bremner , notmuch@notmuchmail.org, Ciprian Dorin Craciun Subject: [PATCH v2] lib/config: use g_key_file_get_string to read config values Date: Thu, 30 Sep 2021 15:59:54 -0300 Message-Id: <20210930185954.4132297-1-david@tethera.net> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210930182835.4125022-2-david@tethera.net> References: <20210930182835.4125022-2-david@tethera.net> MIME-Version: 1.0 Message-ID-Hash: YU5662ZJPADGFCULDMBL5ATSCYAK2ZIA X-Message-ID-Hash: YU5662ZJPADGFCULDMBL5ATSCYAK2ZIA X-MailFrom: bremner@tethera.net X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-notmuch.notmuchmail.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.1 Precedence: list List-Id: "Use and development of the notmuch mail system." List-Help: List-Post: List-Subscribe: List-Unsubscribe: Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_IN ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1633028411; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=foKydspI7+8CwinBC48TFc9YxNRypGhR2Kr4FXVjaO0=; b=O/khAB3TRl+HGLP1tx0ngeynlynSyKbZl6Af4SxocWcbGfb3Rz5GkL6QPiPmcgM0JFyDIJ lCUcqhlIfzR6cGWxgvE3RMyzz+NnyHDrH+D5OG/EzklrBKqUmNG8EVFnCgLF452EG/u2nF OcZ7S37wbT+iZY6F6osIJxEFORWvLpt9VE2s99gQYzqxmmMRSGpFfl3ZD6R5pxofgPe5ga yveIclTMNZw0LfSutR7x21VPP/lJyeE4eSDYIquXfHYIKMK/vTGdHc36fBbbISpI2TX9TF cDc3zBysSrqQBaT/nb7/TePmZShNlY5SV2cstlD4yoOg7xJEhHmhmJu5XzGZ4A== ARC-Seal: i=1; s=key1; d=yhetil.org; t=1633028411; a=rsa-sha256; cv=none; b=N48Qs6w6mYIMN8azyRS1ak4zV1soCz0FwZyIt7Fn6ogV8bEKkz7SpEMtz6GkC2bnIgBQxT QXY9w5KKF1o/36a6mr7J71U5TeoLV+8ZzUptZBCRQcG0WjdAVsR4aT1Lg47WEYWImUlA1n eAIoabWNni4/WjAbrNDzR1Mi087JwoFkUEYFIqO/ktdgmJnlGSXGoOuDNB+/qaDjVBCamM lw9JMYscgv5IMZ0u4arb1OBPEP5jthNusmyE3hVnIXABauTxZDY9WTx8QxOZb8FUUMAyKW 4RFSZSjpJBAW8jdd3R4Slh/DO9wbDujCpt8UZ/8DT1cOu+uSVlrQc8hfMlIYKQ== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Spam-Score: -1.20 Authentication-Results: aspmx1.migadu.com; dkim=none; dmarc=none; spf=pass (aspmx1.migadu.com: domain of notmuch-bounces@notmuchmail.org designates 144.217.243.247 as permitted sender) smtp.mailfrom=notmuch-bounces@notmuchmail.org X-Migadu-Queue-Id: 6A14F32E77 X-Spam-Score: -1.20 X-Migadu-Scanner: scn0.migadu.com X-TUID: g32ksHaG/+AT 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