mirror of
https://git.notmuchmail.org/git/notmuch
synced 2024-11-27 13:17:56 +01:00
cli/show: emit payload subject instead of outside subject
Correctly fix the two outstanding tests so that the protected (hidden) subject is properly reported. Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
This commit is contained in:
parent
528f526f69
commit
1c7fbbcc99
4 changed files with 13 additions and 9 deletions
|
@ -232,7 +232,7 @@ format_part_sprinter (const void *ctx, struct sprinter *sp, mime_node_t *node,
|
||||||
|
|
||||||
void
|
void
|
||||||
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
|
format_headers_sprinter (struct sprinter *sp, GMimeMessage *message,
|
||||||
bool reply);
|
bool reply, const _notmuch_message_crypto_t *msg_crypto);
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
|
NOTMUCH_SHOW_TEXT_PART_REPLY = 1 << 0,
|
||||||
|
|
|
@ -663,7 +663,9 @@ static int do_reply(notmuch_config_t *config,
|
||||||
|
|
||||||
/* The headers of the reply message we've created */
|
/* The headers of the reply message we've created */
|
||||||
sp->map_key (sp, "reply-headers");
|
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 */
|
/* Start the original */
|
||||||
sp->map_key (sp, "original");
|
sp->map_key (sp, "original");
|
||||||
|
|
|
@ -197,7 +197,7 @@ _is_from_line (const char *line)
|
||||||
|
|
||||||
void
|
void
|
||||||
format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
|
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
|
/* Any changes to the JSON or S-Expression format should be
|
||||||
* reflected in the file devel/schemata. */
|
* reflected in the file devel/schemata. */
|
||||||
|
@ -209,6 +209,9 @@ format_headers_sprinter (sprinter_t *sp, GMimeMessage *message,
|
||||||
sp->begin_map (sp);
|
sp->begin_map (sp);
|
||||||
|
|
||||||
sp->map_key (sp, "Subject");
|
sp->map_key (sp, "Subject");
|
||||||
|
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->string (sp, g_mime_message_get_subject (message));
|
||||||
|
|
||||||
sp->map_key (sp, "From");
|
sp->map_key (sp, "From");
|
||||||
|
@ -616,6 +619,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
||||||
* reflected in the file devel/schemata. */
|
* reflected in the file devel/schemata. */
|
||||||
|
|
||||||
if (node->envelope_file) {
|
if (node->envelope_file) {
|
||||||
|
const _notmuch_message_crypto_t *msg_crypto = NULL;
|
||||||
sp->begin_map (sp);
|
sp->begin_map (sp);
|
||||||
format_message_sprinter (sp, node->envelope_file);
|
format_message_sprinter (sp, node->envelope_file);
|
||||||
|
|
||||||
|
@ -626,8 +630,8 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
||||||
sp->end (sp);
|
sp->end (sp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
msg_crypto = mime_node_get_message_crypto_status (node);
|
||||||
if (notmuch_format_version >= 4) {
|
if (notmuch_format_version >= 4) {
|
||||||
const _notmuch_message_crypto_t *msg_crypto = mime_node_get_message_crypto_status (node);
|
|
||||||
sp->map_key (sp, "crypto");
|
sp->map_key (sp, "crypto");
|
||||||
sp->begin_map (sp);
|
sp->begin_map (sp);
|
||||||
if (msg_crypto->sig_list ||
|
if (msg_crypto->sig_list ||
|
||||||
|
@ -655,7 +659,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
||||||
}
|
}
|
||||||
|
|
||||||
sp->map_key (sp, "headers");
|
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);
|
sp->end (sp);
|
||||||
return;
|
return;
|
||||||
|
@ -748,7 +752,7 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node,
|
||||||
sp->begin_map (sp);
|
sp->begin_map (sp);
|
||||||
|
|
||||||
sp->map_key (sp, "headers");
|
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->map_key (sp, "body");
|
||||||
sp->begin_list (sp);
|
sp->begin_list (sp);
|
||||||
|
|
|
@ -21,7 +21,6 @@ test_json_nodes <<<"$output" \
|
||||||
|
|
||||||
test_begin_subtest "verify protected header is visible with decryption"
|
test_begin_subtest "verify protected header is visible with decryption"
|
||||||
output=$(notmuch show --decrypt=true --format=json id:protected-header@crypto.notmuchmail.org)
|
output=$(notmuch show --decrypt=true --format=json id:protected-header@crypto.notmuchmail.org)
|
||||||
test_subtest_known_broken
|
|
||||||
test_json_nodes <<<"$output" \
|
test_json_nodes <<<"$output" \
|
||||||
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
|
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
|
||||||
'subject:[0][0][0]["headers"]["Subject"]="This is a protected header"'
|
'subject:[0][0][0]["headers"]["Subject"]="This is a protected header"'
|
||||||
|
@ -58,7 +57,6 @@ test_json_nodes <<<"$output" \
|
||||||
|
|
||||||
test_begin_subtest "verify nested message/rfc822 protected header is visible"
|
test_begin_subtest "verify nested message/rfc822 protected header is visible"
|
||||||
output=$(notmuch show --decrypt=true --format=json id:nested-rfc822-message@crypto.notmuchmail.org)
|
output=$(notmuch show --decrypt=true --format=json id:nested-rfc822-message@crypto.notmuchmail.org)
|
||||||
test_subtest_known_broken
|
|
||||||
test_json_nodes <<<"$output" \
|
test_json_nodes <<<"$output" \
|
||||||
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
|
'crypto:[0][0][0]["crypto"]={"decrypted": {"status": "full"}}' \
|
||||||
'subject:[0][0][0]["headers"]["Subject"]="This is a message using draft-melnikov-smime-header-signing"'
|
'subject:[0][0][0]["headers"]["Subject"]="This is a message using draft-melnikov-smime-header-signing"'
|
||||||
|
|
Loading…
Reference in a new issue