@@ -127,69 +127,74 @@ impl MimeMessage {
127
127
let mail_raw;
128
128
let mut gossipped_addr = Default :: default ( ) ;
129
129
130
- let ( mail, signatures) = match e2ee:: try_decrypt ( context, & mail, message_time) . await {
131
- Ok ( ( raw, signatures) ) => {
132
- if let Some ( raw) = raw {
133
- // Encrypted, but maybe unsigned message. Only if
134
- // `signatures` set is non-empty, it is a valid
135
- // autocrypt message.
136
-
137
- mail_raw = raw;
138
- let decrypted_mail = mailparse:: parse_mail ( & mail_raw) ?;
139
- if std:: env:: var ( crate :: DCC_MIME_DEBUG ) . is_ok ( ) {
140
- info ! ( context, "decrypted message mime-body:" ) ;
141
- println ! ( "{}" , String :: from_utf8_lossy( & mail_raw) ) ;
142
- }
143
-
144
- // Handle any gossip headers if the mail was encrypted. See section
145
- // "3.6 Key Gossip" of https://autocrypt.org/autocrypt-spec-1.1.0.pdf
146
- // but only if the mail was correctly signed:
147
- if !signatures. is_empty ( ) {
148
- let gossip_headers =
149
- decrypted_mail. headers . get_all_values ( "Autocrypt-Gossip" ) ;
150
- gossipped_addr =
151
- update_gossip_peerstates ( context, message_time, & mail, gossip_headers)
152
- . await ?;
153
- }
154
-
155
- // let known protected headers from the decrypted
156
- // part override the unencrypted top-level
157
-
158
- // Signature was checked for original From, so we
159
- // do not allow overriding it.
160
- let mut throwaway_from = from. clone ( ) ;
161
-
162
- // We do not want to allow unencrypted subject in encrypted emails because the user might falsely think that the subject is safe.
163
- // See https://github.com/deltachat/deltachat-core-rust/issues/1790.
164
- headers. remove ( "subject" ) ;
130
+ let ( mail, signatures, warn_empty_signature) =
131
+ match e2ee:: try_decrypt ( context, & mail, message_time) . await {
132
+ Ok ( ( raw, signatures) ) => {
133
+ if let Some ( raw) = raw {
134
+ // Encrypted, but maybe unsigned message. Only if
135
+ // `signatures` set is non-empty, it is a valid
136
+ // autocrypt message.
137
+
138
+ mail_raw = raw;
139
+ let decrypted_mail = mailparse:: parse_mail ( & mail_raw) ?;
140
+ if std:: env:: var ( crate :: DCC_MIME_DEBUG ) . is_ok ( ) {
141
+ info ! ( context, "decrypted message mime-body:" ) ;
142
+ println ! ( "{}" , String :: from_utf8_lossy( & mail_raw) ) ;
143
+ }
165
144
166
- MimeMessage :: merge_headers (
167
- context,
168
- & mut headers,
169
- & mut recipients,
170
- & mut throwaway_from,
171
- & mut chat_disposition_notification_to,
172
- & decrypted_mail. headers ,
173
- ) ;
145
+ // Handle any gossip headers if the mail was encrypted. See section
146
+ // "3.6 Key Gossip" of https://autocrypt.org/autocrypt-spec-1.1.0.pdf
147
+ // but only if the mail was correctly signed:
148
+ if !signatures. is_empty ( ) {
149
+ let gossip_headers =
150
+ decrypted_mail. headers . get_all_values ( "Autocrypt-Gossip" ) ;
151
+ gossipped_addr = update_gossip_peerstates (
152
+ context,
153
+ message_time,
154
+ & mail,
155
+ gossip_headers,
156
+ )
157
+ . await ?;
158
+ }
174
159
175
- ( decrypted_mail, signatures)
176
- } else {
177
- // Message was not encrypted
178
- ( mail, signatures)
160
+ // let known protected headers from the decrypted
161
+ // part override the unencrypted top-level
162
+
163
+ // Signature was checked for original From, so we
164
+ // do not allow overriding it.
165
+ let mut throwaway_from = from. clone ( ) ;
166
+
167
+ // We do not want to allow unencrypted subject in encrypted emails because the user might falsely think that the subject is safe.
168
+ // See https://github.com/deltachat/deltachat-core-rust/issues/1790.
169
+ headers. remove ( "subject" ) ;
170
+
171
+ MimeMessage :: merge_headers (
172
+ context,
173
+ & mut headers,
174
+ & mut recipients,
175
+ & mut throwaway_from,
176
+ & mut chat_disposition_notification_to,
177
+ & decrypted_mail. headers ,
178
+ ) ;
179
+
180
+ ( decrypted_mail, signatures, true )
181
+ } else {
182
+ // Message was not encrypted
183
+ ( mail, signatures, false )
184
+ }
179
185
}
180
- }
181
- Err ( err) => {
182
- // continue with the current, still encrypted, mime tree.
183
- // unencrypted parts will be replaced by an error message
184
- // that is added as "the message" to the chat then.
185
- //
186
- // if we just return here, the header is missing
187
- // and the caller cannot display the message
188
- // and try to assign the message to a chat
189
- warn ! ( context, "decryption failed: {}" , err) ;
190
- ( mail, Default :: default ( ) )
191
- }
192
- } ;
186
+ Err ( err) => {
187
+ // continue with the current, still encrypted, mime tree.
188
+ // unencrypted parts will be replaced by an error message
189
+ // that is added as "the message" to the chat then.
190
+ //
191
+ // if we just return here, the header is missing
192
+ // and the caller cannot display the message
193
+ // and try to assign the message to a chat
194
+ warn ! ( context, "decryption failed: {}" , err) ;
195
+ ( mail, Default :: default ( ) , true )
196
+ }
197
+ } ;
193
198
194
199
let mut parser = MimeMessage {
195
200
parts : Vec :: new ( ) ,
@@ -215,7 +220,7 @@ impl MimeMessage {
215
220
parser. heuristically_parse_ndn ( context) . await ;
216
221
parser. parse_headers ( context) ?;
217
222
218
- if parser. signatures . is_empty ( ) {
223
+ if warn_empty_signature && parser. signatures . is_empty ( ) {
219
224
for part in parser. parts . iter_mut ( ) {
220
225
part. error = "No valid signature" . to_string ( ) ;
221
226
}
0 commit comments