Re: [Patch] make IMAP messages translatable
Peter Bloomfield <[email protected]>
| Newsgroups | gmane.comp.gnome.apps.balsa |
|---|---|
| Message-ID | <[email protected]> |
On 01/11/2019 08:39:36 PM Fri, Peter Bloomfield wrote: > Hi Albrecht: > > On 01/05/2019 03:28:44 PM Sat, Peter Bloomfield wrote: > … >> I've pushed all three patches to GitLab, autocrypt branch. I've had one instance of some CRITICAL messages related to AutoCrypt, but to my shame I was not in gdb so I didn't get a stack trace. I /am/ in gdb now, so if it happens again I should be able to debug. > > The message is: > > (balsa:9235): autocrypt-CRITICAL **: 11:18:05.376: autocrypt_from_message: assertion 'LIBBALSA_IS_MESSAGE(message) && (message->headers != NULL) && (message->headers->from != NULL) && (message->headers->content_type != NULL) && GMIME_IS_OBJECT(message->mime_msg) && (autocrypt_db != NULL)' failed > > and it fails because message->mime_msg is NULL. I see it only in IMAP mailboxes, and only for certain messages--perhaps those with HTML parts(?). Do we really need mime_msg, or can we get the autocrypt headers instead from message->headers? Could the attached work? Peter _______________________________________________ balsa-list mailing list [email protected] https://mail.gnome.org/mailman/listinfo/balsa-list
alt-autocrypt.diff
(text/x-patch, 2.6 KB)
diff --git a/libbalsa/autocrypt.c b/libbalsa/autocrypt.c
index 6c6c5f5a7..1d35459e9 100644
--- a/libbalsa/autocrypt.c
+++ b/libbalsa/autocrypt.c
@@ -196,12 +196,11 @@ autocrypt_from_message(LibBalsaMessage *message,
GError **error)
{
const gchar *from_addr;
- GMimeHeaderList *headers;
- GMimeHeaderIter iter;
AutocryptData *autocrypt = NULL;
+ const gchar *autocrypt_hdr;
g_return_if_fail(LIBBALSA_IS_MESSAGE(message) && (message->headers != NULL) && (message->headers->from != NULL) &&
- (message->headers->content_type != NULL) && GMIME_IS_OBJECT(message->mime_msg) && (autocrypt_db != NULL));
+ (message->headers->content_type != NULL) && (autocrypt_db != NULL));
// FIXME - we should ignore spam - how can we detect it?
@@ -231,30 +230,28 @@ autocrypt_from_message(LibBalsaMessage *message,
g_debug("message from '%s', date %ld", from_addr, message->headers->date);
/* scan for Autocrypt headers */
- headers = g_mime_object_get_header_list(GMIME_OBJECT(message->mime_msg));
- if (g_mime_header_list_get_iter(headers, &iter)) {
- do {
- if ((g_ascii_strcasecmp(g_mime_header_iter_get_name(&iter), "Autocrypt") == 0) &&
- (g_mime_header_iter_get_value(&iter) != NULL)) {
- AutocryptData *new_data;
-
- new_data = parse_autocrypt_header(g_mime_header_iter_get_value(&iter));
- if (new_data != NULL) {
- if (autocrypt == NULL) {
- autocrypt = new_data;
- } else {
- g_info("more than one valid Autocrypt header, ignore message");
- autocrypt_free(autocrypt);
- autocrypt_free(new_data);
- return;
- }
- } else {
- /* ignore message with broken Autocrypt header */
- autocrypt_free(autocrypt);
- return;
- }
- }
- } while (g_mime_header_iter_next(&iter));
+
+ autocrypt_hdr = libbalsa_message_get_user_header(message, "Autocrypt");
+ if (autocrypt_hdr != NULL) {
+ AutocryptData *new_data;
+
+ new_data = parse_autocrypt_header(autocrypt_hdr);
+ if (new_data != NULL) {
+ if (autocrypt == NULL) {
+ autocrypt = new_data;
+ } else {
+ g_info("more than one valid Autocrypt header, ignore message");
+ autocrypt_free(autocrypt);
+ autocrypt_free(new_data);
+
+ return;
+ }
+ } else {
+ /* ignore message with broken Autocrypt header */
+ autocrypt_free(autocrypt);
+
+ return;
+ }
}
/* check if addr matches From: - ignore otherwise */
signature.asc
(application/pgp-signature, 195 B)
-----BEGIN PGP SIGNATURE----- iF0EABECAB0WIQS030wPRfNNA5alz3MfX9S1uSp09QUCXDlkSwAKCRAfX9S1uSp0 9TSfAJ9Nj37JqwqXTK25c4+cJPwt2jLf6wCfXnb3aH31DJQIKb1491lMwXPhJeU= =1UVn -----END PGP SIGNATURE-----