[git] GpgOL - branch, master, updated. gpgol-2.0.1-8-gc499ce5

by Andre Heinecke cvs at cvs.gnupg.org
Fri Nov 10 17:59:17 CET 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GnuPG extension for MS Outlook".

The branch, master has been updated
       via  c499ce50aa9f1e9fe85549e82d0e799aa7de0134 (commit)
       via  474cc15d8e331c9def298dbbfe3b99e6c8cf8035 (commit)
       via  8d5e9d19ecaf0f753b5204a70d72d2505b373048 (commit)
      from  3cadd0e929e4e30db0b604d096c91c11e44c9925 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit c499ce50aa9f1e9fe85549e82d0e799aa7de0134
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 10 17:56:57 2017 +0100

    Fix reversion for S/MIME mails if S/MIME disabled
    
    * src/mailitem-events.cpp (EVENT_SINK_INVOKE): Revert
    again if S/MIME is disabled but we parsed the mail.
    
    --
    While reversion is no longer neccessary for crypto mails
    to hide the plaintext we still might need it to change
    the message class back. And wiping the body etc. is also
    a good idea when we "leave a mail alone"
    
    GnuPG-Bug-ID: T3494

diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index f9f827b..0772004 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -215,6 +215,9 @@ EVENT_SINK_INVOKE(MailItemEvents)
             {
               /* We want to save the mail when it's an smime mail and smime
                  is disabled to revert it. */
+              log_debug ("%s:%s: S/MIME mail but S/MIME is disabled."
+                         " Need save.",
+                         SRCNAME, __func__);
               m_mail->set_needs_save (true);
             }
           break;
@@ -378,6 +381,18 @@ EVENT_SINK_INVOKE(MailItemEvents)
                          SRCNAME, __func__);
               return S_OK;
             }
+
+          if (m_mail->is_crypto_mail () && m_mail->needs_save () &&
+              m_mail->revert ())
+            {
+              /* An error cleaning the mail should not happen normally.
+                 But just in case there is an error we cancel the
+                 write here. */
+              log_debug ("%s:%s: Failed to remove plaintext.",
+                         SRCNAME, __func__);
+              *(parms->rgvarg[0].pboolVal) = VARIANT_TRUE;
+            }
+
           log_debug ("%s:%s: Passing write event.",
                      SRCNAME, __func__);
           m_mail->set_needs_save (false);

commit 474cc15d8e331c9def298dbbfe3b99e6c8cf8035
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 10 17:52:01 2017 +0100

    Fix handling of "own" S/MIME Mails
    
    * src/mimedataprovider.cpp (MimeDataProvider::collect_data):
    Expect headers if the first line of the data starts with MIME-Version.
    
    --
    
    This fixes the problem that S/MIME Mails in the sent folder
    are not handled.
    
    The problem is that for received S/MIME Mails GpgOL sees
    the S/MIME part as the original structure and just needs
    to copy this part to gpgol.
    But for our own mails in the sent mails folder we get our
    MIME Structure that we created for the MAPI to MIME conversion
    including headers.
    
    To avoid a big mess with another content type we check the
    first bytes of the data we parse if they say "MIME-Version"
    in that case we expect MIME headers.
    
    GnuPG-Bug-ID: T3442

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index 82a84f0..4e825b8 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -752,6 +752,7 @@ MimeDataProvider::collect_data(LPSTREAM stream)
   HRESULT hr;
   char buf[BUFSIZE];
   ULONG bRead;
+  bool first_read = true;
   while ((hr = stream->Read (buf, BUFSIZE, &bRead)) == S_OK ||
          hr == S_FALSE)
     {
@@ -764,6 +765,27 @@ MimeDataProvider::collect_data(LPSTREAM stream)
       log_mime_parser ("%s:%s: Read %lu bytes.",
                        SRCNAME, __func__, bRead);
 
+      if (first_read)
+        {
+          if (bRead > 12 && strncmp ("MIME-Version", buf, 12) == 0)
+            {
+              /* Fun! In case we have exchange or sent messages created by us
+                 we get the mail attachment like it is before the MAPI to MIME
+                 conversion. So it has our MIME structure. In that case
+                 we have to expect MIME data even if the initial data check
+                 suggests that we don't.
+
+                 Checking if the content starts with MIME-Version appears
+                 to be a robust way to check if we try to parse MIME data. */
+              m_collect_everything = false;
+              log_debug ("%s:%s: Found MIME-Version marker."
+                         "Expecting headers even if type suggested not to.",
+                         SRCNAME, __func__);
+
+            }
+        }
+      first_read = false;
+
       if (m_collect_everything)
         {
           /* For S/MIME, Clearsigned, PGP MESSAGES we just pass everything

commit 8d5e9d19ecaf0f753b5204a70d72d2505b373048
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 10 17:51:18 2017 +0100

    Add some more tracing in mail
    
    * src/mail.cpp (Mail::update_body): Add some traces.
    
    --
    Possibly something fishy in here where we crash.

diff --git a/src/mail.cpp b/src/mail.cpp
index e7a2a51..9db7c85 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -776,6 +776,7 @@ void
 Mail::update_body()
 {
   const auto error = m_parser->get_formatted_error ();
+  TRACEPOINT;
   if (!error.empty())
     {
       if (opt.prefer_html)
@@ -801,7 +802,9 @@ Mail::update_body()
   auto html = m_parser->get_html_body ();
   /** Outlook does not show newlines if \r\r\n is a newline. We replace
     these as apparently some other buggy MUA sends this. */
+  TRACEPOINT;
   find_and_replace (html, "\r\r\n", "\r\n");
+  TRACEPOINT;
   if (opt.prefer_html && !html.empty())
     {
       char *converted = ansi_charset_to_utf8 (m_parser->get_html_charset().c_str(),
@@ -813,6 +816,8 @@ Mail::update_body()
           log_error ("%s:%s: Failed to modify html body of item.",
                      SRCNAME, __func__);
         }
+
+      TRACEPOINT;
       return;
     }
   auto body = m_parser->get_body ();
@@ -820,12 +825,14 @@ Mail::update_body()
   char *converted = ansi_charset_to_utf8 (m_parser->get_body_charset().c_str(),
                                           body.c_str(), body.size());
   int ret = put_oom_string (m_mailitem, "Body", converted ? converted : "");
+  TRACEPOINT;
   xfree (converted);
   if (ret)
     {
       log_error ("%s:%s: Failed to modify body of item.",
                  SRCNAME, __func__);
     }
+  TRACEPOINT;
   return;
 }
 

-----------------------------------------------------------------------

Summary of changes:
 src/mail.cpp             |  7 +++++++
 src/mailitem-events.cpp  | 15 +++++++++++++++
 src/mimedataprovider.cpp | 22 ++++++++++++++++++++++
 3 files changed, 44 insertions(+)


hooks/post-receive
-- 
GnuPG extension for MS Outlook
http://git.gnupg.org




More information about the Gnupg-commits mailing list