[git] GpgOL - branch, master, updated. gpgol-2.0.2-6-g2788938

by Andre Heinecke cvs at cvs.gnupg.org
Fri Nov 17 13:34:54 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  278893850ed926d4646929ee97576a8d09fd4998 (commit)
       via  307ac9b2eda9a14e7be66b8f37aaff354d214cf4 (commit)
       via  79dbefe275d30761f9ce8dd3d6b6049959c4e33f (commit)
       via  4f9c720433aabc37484bc4f365efc5949f8fa3f0 (commit)
      from  82ac4be96443afdc88a7bb75edee70159bf8a5f5 (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 278893850ed926d4646929ee97576a8d09fd4998
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 17 13:33:40 2017 +0100

    Add more fallbacks and error for body wipe
    
    * src/mail.cpp, src/mail.h (Mail::wipe): Add force parameter.
    * src/mailitem-events.cpp (EVENT_SINK_INVOKE): Check for
    OOM wiped body and try again to wipe it in case there is
    something.

diff --git a/src/mail.cpp b/src/mail.cpp
index cb78825..5da75a7 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -970,9 +970,9 @@ Mail::needs_crypto ()
 }
 
 int
-Mail::wipe ()
+Mail::wipe (bool force)
 {
-  if (!m_needs_wipe)
+  if (!m_needs_wipe && !force)
     {
       return 0;
     }
diff --git a/src/mail.h b/src/mail.h
index 1b94184..e497190 100644
--- a/src/mail.h
+++ b/src/mail.h
@@ -156,7 +156,7 @@ public:
   /** @brief wipe the plaintext from the message and encrypt attachments.
    *
    * @returns 0 on success; */
-  int wipe ();
+  int wipe (bool force = false);
 
   /** @brief revert the message to the original mail before our changes.
    *
diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index 69c139e..2f1a866 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -356,9 +356,49 @@ EVENT_SINK_INVOKE(MailItemEvents)
           invoke_oom_method (m_object, "Save", NULL);
           if (m_mail->crypto_successful ())
             {
-               log_debug ("%s:%s: Passing send event for message %p.",
-                          SRCNAME, __func__, m_object);
-               break;
+              /* Fishy behavior catcher: Sometimes the save does not clean
+                 out the body. Weird. Happened at least for one user.
+                 The following code checks for plain text leaks and
+                 prevents send in case the body can't be wiped. */
+              if (!m_mail->get_body().empty() || !m_mail->get_html_body().empty())
+                {
+                  log_debug ("%s:%s: Body found after encryption %p.",
+                            SRCNAME, __func__, m_object);
+                  const auto body = m_mail->get_body();
+                  if (body.size() > 10 && !strncmp (body.c_str(), "-----BEGIN", 10))
+                    {
+                      log_debug ("%s:%s: Looks like inline body. You can pass %p.",
+                                SRCNAME, __func__, m_object);
+                      break;
+                    }
+
+                  if (!m_mail->wipe (true))
+                    {
+                      log_debug ("%s:%s: Wipe succeded. %p.",
+                                 SRCNAME, __func__, m_object);
+
+                      log_debug ("%s:%s: Passing send event for message %p.",
+                                SRCNAME, __func__, m_object);
+                      break;
+                    }
+                  log_debug ("%s:%s: Cancel send for %p.",
+                            SRCNAME, __func__, m_object);
+                  wchar_t *title = utf8_to_wchar (_("GpgOL: Encryption not possible!"));
+                  wchar_t *msg = utf8_to_wchar (_(
+                  "Outlook returned an error when trying to send the encrypted mail.\n\n"
+                  "Please restart Outlook and try again.\n\n"
+                  "If it still fails consider using an encrypted attachment or\n"
+                  "switching to PGP/Inline in GpgOL's options."));
+                  MessageBoxW (get_active_hwnd(), msg, title,
+                               MB_ICONERROR | MB_OK);
+                  xfree (msg);
+                  xfree (title);
+                  *(parms->rgvarg[0].pboolVal) = VARIANT_TRUE;
+                  return S_OK;
+                }
+              log_debug ("%s:%s: Passing send event for message %p.",
+                         SRCNAME, __func__, m_object);
+              break;
             }
           else
             {

commit 307ac9b2eda9a14e7be66b8f37aaff354d214cf4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 17 12:41:30 2017 +0100

    Revert "Add some more tracing in mail"
    
    This reverts commit 8d5e9d19ecaf0f753b5204a70d72d2505b373048.

diff --git a/src/mail.cpp b/src/mail.cpp
index 4862b38..cb78825 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -776,7 +776,6 @@ void
 Mail::update_body()
 {
   const auto error = m_parser->get_formatted_error ();
-  TRACEPOINT;
   if (!error.empty())
     {
       if (opt.prefer_html)
@@ -802,9 +801,7 @@ 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(),
@@ -816,8 +813,6 @@ Mail::update_body()
           log_error ("%s:%s: Failed to modify html body of item.",
                      SRCNAME, __func__);
         }
-
-      TRACEPOINT;
       return;
     }
   auto body = m_parser->get_body ();
@@ -825,14 +820,12 @@ 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;
 }
 

commit 79dbefe275d30761f9ce8dd3d6b6049959c4e33f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Nov 17 12:41:16 2017 +0100

    Clarify comment about send event
    
    --

diff --git a/src/mailitem-events.cpp b/src/mailitem-events.cpp
index 36b4542..69c139e 100644
--- a/src/mailitem-events.cpp
+++ b/src/mailitem-events.cpp
@@ -328,16 +328,16 @@ EVENT_SINK_INVOKE(MailItemEvents)
         }
       case Send:
         {
-          /* This is the only event where we can cancel the send of an
+          /* This is the only event where we can cancel the send of a
              mailitem. But it is too early for us to encrypt as the MAPI
              structures are not yet filled. Crypto based on the
              Outlook Object Model data did not work as the messages
              were only sent out empty. See 2b376a48 for a try of
              this.
 
-             The we store send_seend and invoke a save which will result
-             in an error but only after triggering all the behavior
-             we need -> filling mapi structures and invoking the
+             This is why we store send_seen and invoke a save which
+             may result in an error but only after triggering all the
+             behavior we need -> filling mapi structures and invoking the
              AfterWrite handler where we encrypt.
 
              If this encryption is successful and we pass the send

commit 4f9c720433aabc37484bc4f365efc5949f8fa3f0
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Nov 16 12:43:38 2017 +0100

    Use table view reading pane for OL <= 2013
    
    * src/explorer-events.cpp (EVENT_SINK_INVOKE),
    src/ribbon-callbacks.cpp (get_mail_from_control): Check
    version to determine codepath.
    
    --
    The crash only appeared on Outlook 2016. Older Versions
    don't have the previewPane object. So we need to have
    a fallback.

diff --git a/src/explorer-events.cpp b/src/explorer-events.cpp
index 1529a88..8ed0784 100644
--- a/src/explorer-events.cpp
+++ b/src/explorer-events.cpp
@@ -82,34 +82,38 @@ EVENT_SINK_INVOKE(ExplorerEvents)
         {
           log_oom_extra ("%s:%s: Selection change in explorer: %p",
                          SRCNAME, __func__, this);
-#if 0
-          Somehow latest Outlook 2016 crashes when accessing the current view
+          /* Somehow latest Outlook 2016 crashes when accessing the current view
           of the Explorer. This is even reproducible with
           GpgOL disabled and only with Outlook Spy active. If you select
           the explorer of an Outlook.com resource and then access
           the CurrentView and close the CurrentView again in Outlook Spy
-          outlook crashes.
+          outlook crashes. */
 
-          LPDISPATCH tableView = get_oom_object (m_object, "CurrentView");
-          if (!tableView)
-            {
-              TRACEPOINT;
-              break;
-            }
-          int hasReadingPane = get_oom_bool (tableView, "ShowReadingPane");
-          gpgol_release (tableView);
-          if (!hasReadingPane)
+          if (g_ol_version_major <= 15)
             {
-              break;
+              LPDISPATCH tableView = get_oom_object (m_object, "CurrentView");
+              if (!tableView)
+                {
+                  TRACEPOINT;
+                  break;
+                }
+              int hasReadingPane = get_oom_bool (tableView, "ShowReadingPane");
+              gpgol_release (tableView);
+              if (!hasReadingPane)
+                {
+                  break;
+                }
             }
-#else
-          LPDISPATCH prevEdit = get_oom_object (m_object, "PreviewPane.WordEditor");
-          gpgol_release (prevEdit);
-          if (!prevEdit)
+          else
             {
-              break;
+              LPDISPATCH prevEdit = get_oom_object (m_object, "PreviewPane.WordEditor");
+              gpgol_release (prevEdit);
+              if (!prevEdit)
+                {
+                  break;
+                }
             }
-#endif
+
           HANDLE thread = CreateThread (NULL, 0, invalidate_ui, (LPVOID) this, 0,
                                         NULL);
 
diff --git a/src/ribbon-callbacks.cpp b/src/ribbon-callbacks.cpp
index c2a78d1..f787622 100644
--- a/src/ribbon-callbacks.cpp
+++ b/src/ribbon-callbacks.cpp
@@ -1463,7 +1463,7 @@ get_mail_from_control (LPDISPATCH ctrl, bool *none_selected)
         {
           *none_selected = true;
         }
-      else
+      else if (g_ol_version_major >= 16)
         {
           // Avoid showing wrong crypto state if we don't have a reading
           // pane. In that case the parser will finish for a mail which is gone
@@ -1477,6 +1477,30 @@ get_mail_from_control (LPDISPATCH ctrl, bool *none_selected)
               mailitem = nullptr;
             }
         }
+      else
+        {
+          // Preview Pane is not available in older outlooks
+          LPDISPATCH tableView = get_oom_object (context, "CurrentView");
+          if (!tableView)
+            {
+              // Woops, should not happen.
+              TRACEPOINT;
+              *none_selected = true;
+              gpgol_release (mailitem);
+              mailitem = nullptr;
+            }
+          else
+            {
+              int hasReadingPane = get_oom_bool (tableView, "ShowReadingPane");
+              gpgol_release (tableView);
+              if (!hasReadingPane)
+                {
+                  *none_selected = true;
+                  gpgol_release (mailitem);
+                  mailitem = nullptr;
+                }
+            }
+        }
     }
 
   gpgol_release (context);

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

Summary of changes:
 src/explorer-events.cpp  | 42 ++++++++++++++++++++-----------------
 src/mail.cpp             | 11 ++--------
 src/mail.h               |  2 +-
 src/mailitem-events.cpp  | 54 +++++++++++++++++++++++++++++++++++++++++-------
 src/ribbon-callbacks.cpp | 26 ++++++++++++++++++++++-
 5 files changed, 98 insertions(+), 37 deletions(-)


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




More information about the Gnupg-commits mailing list