[PATCH 11/20] cli/show: emit payload subject instead of outside subject
Daniel Kahn Gillmor
dkg at fifthhorseman.net
Thu May 10 22:55:35 PDT 2018
Correctly fix the two outstanding tests so that the protected (hidden)
subject is properly reported.
---
notmuch-client.h | 2 +-
notmuch-reply.c | 4 +++-
notmuch-show.c | 11 +++++++----
test/T356-protected-headers.sh | 3 ---
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/notmuch-client.h b/notmuch-client.h
index dfc7c047..73c8a163 100644
--- a/notmuch-client.h
+++ b/notmuch-client.h
@@ -232,7 +232,7 @@ format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
void
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
- bool reply);
+ bool reply, const _notmuch_message_crypto_t *msg_crypto);
typedef enum {
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
diff --git a/notmuch-reply.c b/notmuch-reply.c
index 75cf7ecb..fe02c590 100644
--- a/notmuch-reply.c
+++ b/notmuch-reply.c
@@ -663,7 +663,9 @@ static int do_reply(notmuch_config_t *config,
/* The headers of the reply message we've created */
sp->map_key (sp, "reply-headers");
- format_headers_sprinter (sp, reply, true);
+ /* FIXME: send msg_crypto here to avoid killing the
+ * subject line on reply to encrypted messages! */
+ format_headers_sprinter (sp, reply, true, NULL);
/* Start the original */
sp->map_key (sp, "original");
diff --git a/notmuch-show.c b/notmuch-show.c
index 4e918461..190e9128 100644
--- a/notmuch-show.c
+++ b/notmuch-show.c
@@ -196,7 +196,7 @@ _is_from_line (const char *line)
void
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
- bool reply)
+ bool reply, const _notmuch_message_crypto_t *msg_crypto)
{
/* Any changes to the JSON or S-Expression format should be
* reflected in the file devel/schemata. */
@@ -208,7 +208,10 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
sp->begin_map (sp);
sp->map_key (sp, "Subject");
- sp->string (sp, g_mime_message_get_subject (message));
+ if (msg_crypto && msg_crypto->payload_subject) {
+ sp->string (sp, msg_crypto->payload_subject);
+ } else
+ sp->string (sp, g_mime_message_get_subject (message));
sp->map_key (sp, "From");
sp->string (sp, g_mime_message_get_from_string (message));
@@ -641,7 +644,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
}
sp->map_key (sp, "headers");
- format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
+ format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, msg_crypto);
sp->end (sp);
return;
@@ -734,7 +737,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
sp->begin_map (sp);
sp->map_key (sp, "headers");
- format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false);
+ format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, NULL);
sp->map_key (sp, "body");
sp->begin_list (sp);
diff --git a/test/T356-protected-headers.sh b/test/T356-protected-headers.sh
index 9c6fe467..242ad105 100755
--- a/test/T356-protected-headers.sh
+++ b/test/T356-protected-headers.sh
@@ -23,12 +23,10 @@ test_json_nodes <<<"$output" \
test_begin_subtest "verify protected header is visible with decryption"
output=$(notmuch show --decrypt=true --format=json id:protected-header at crypto.notmuchmail.org)
-test_subtest_known_broken
test_json_nodes <<<"$output" \
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
'subject:[0][0][0]["headers"]["Subject"]="This is a protected header"'
-
test_begin_subtest "misplaced protected headers should not be made visible during decryption"
output=$(notmuch show --decrypt=true --format=json id:misplaced-protected-header at crypto.notmuchmail.org)
test_json_nodes <<<"$output" \
@@ -61,7 +59,6 @@ test_json_nodes <<<"$output" \
test_begin_subtest "verify nested message/rfc822 protected header is visible"
output=$(notmuch show --decrypt=true --format=json id:nested-rfc822-message at crypto.notmuchmail.org)
-test_subtest_known_broken
test_json_nodes <<<"$output" \
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
'subject:[0][0][0]["headers"]["Subject"]="This is a message using draft-melnikov-smime-header-signing"'
--
2.17.0
More information about the notmuch
mailing list