X-Git-Url: https://git.notmuchmail.org/git?a=blobdiff_plain;f=notmuch-show.c;h=4dfe9c1d9def25c6294e335f999d2b5891b33ebb;hb=1c879f39391b1144bfb2328fe778ab7d7e582100;hp=c6a7a10a270f4650a354611dd465efe94682f6e9;hpb=4cb789aa090fb6ba3c7897584ecbcc0a547b2f81;p=notmuch diff --git a/notmuch-show.c b/notmuch-show.c index c6a7a10a..4dfe9c1d 100644 --- a/notmuch-show.c +++ b/notmuch-show.c @@ -197,7 +197,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. */ @@ -209,7 +209,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)); @@ -616,12 +619,10 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, * reflected in the file devel/schemata. */ if (node->envelope_file) { + const _notmuch_message_crypto_t *msg_crypto = NULL; sp->begin_map (sp); format_message_sprinter (sp, node->envelope_file); - sp->map_key (sp, "headers"); - format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false); - if (output_body) { sp->map_key (sp, "body"); sp->begin_list (sp); @@ -629,8 +630,8 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->end (sp); } + msg_crypto = mime_node_get_message_crypto_status (node); 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->begin_map (sp); if (msg_crypto->sig_list || @@ -644,6 +645,12 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->map_key (sp, "encrypted"); sp->boolean (sp, msg_crypto->signature_encrypted); } + if (msg_crypto->payload_subject) { + sp->map_key (sp, "headers"); + sp->begin_list (sp); + sp->string (sp, "Subject"); + sp->end (sp); + } sp->end (sp); } if (msg_crypto->decryption_status != NOTMUCH_MESSAGE_DECRYPTED_NONE) { @@ -651,12 +658,30 @@ format_part_sprinter (const void *ctx, sprinter_t *sp, mime_node_t *node, sp->begin_map (sp); sp->map_key (sp, "status"); sp->string (sp, msg_crypto->decryption_status == NOTMUCH_MESSAGE_DECRYPTED_FULL ? "full" : "partial"); + + if (msg_crypto->payload_subject) { + const char *subject = g_mime_message_get_subject GMIME_MESSAGE (node->part); + if (subject == NULL || strcmp (subject, msg_crypto->payload_subject)) { + /* protected subject differs from the external header */ + sp->map_key (sp, "header-mask"); + sp->begin_map (sp); + sp->map_key (sp, "Subject"); + if (subject == NULL) + sp->null (sp); + else + sp->string (sp, subject); + sp->end (sp); + } + } sp->end (sp); } } sp->end (sp); } + sp->map_key (sp, "headers"); + format_headers_sprinter (sp, GMIME_MESSAGE (node->part), false, msg_crypto); + sp->end (sp); return; } @@ -748,7 +773,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);