[git] GpgOL - branch, master, updated. gpgol-2.0.6-73-ga243c8a

by Andre Heinecke cvs at cvs.gnupg.org
Tue Mar 6 11:58:49 CET 2018


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  a243c8af5f07ea375f4953808d31c4933e79b928 (commit)
       via  7f4d6d27fa0242d6d48dcc8f54149fd77af4891f (commit)
       via  149a0928250aad96a78cf695ec91d9a396b42dbc (commit)
       via  ba9ffe523a0848f35c6347e256f3cc74112752f7 (commit)
       via  8be065b5c8e095eea2ddbce5db2b5d2741a45dc4 (commit)
      from  ca9039910b1171bf503d052dcdee898fa814aa3d (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 a243c8af5f07ea375f4953808d31c4933e79b928
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 6 09:51:38 2018 +0100

    Bring Outlook back into focus after enc/sign
    
    * src/mail.cpp (do_crypt): Send BRING_TO_FRONT message
    after encryption.
    * src/windowmessages.cpp, src/windowmessages.h: New call
    to bring the active outlook window to front.
    
    --
    As explained in the comment this is a workaround for strange
    behavior with pinentry and foreground windows. After encrypt/sign
    often times the wrong window has focus. So we better bring
    Outlook to front.
    
    GnuPG-Bug-Id: T3732

diff --git a/src/mail.cpp b/src/mail.cpp
index 04dec00..07b41a7 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -759,6 +759,13 @@ do_crypt (LPVOID arg)
       mail->update_crypt_mapi ();
       mail->set_crypt_state (Mail::NeedsUpdateInOOM);
     }
+  /* This works around a bug in pinentry that it might
+     bring the wrong window to front. So after encryption /
+     signing we bring outlook back to front.
+
+     See GnuPG-Bug-Id: T3732
+     */
+  do_in_ui_thread_async (BRING_TO_FRONT, nullptr);
   gpgrt_lock_unlock (&dtor_lock);
   return 0;
 }
diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index e9934a5..b0e2311 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -118,6 +118,22 @@ gpgol_window_proc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
               WKSHelper::instance()->allow_notify ();
               break;
             }
+          case (BRING_TO_FRONT):
+            {
+              HWND wnd = get_active_hwnd ();
+              if (wnd)
+                {
+                  log_debug ("%s:%s: Bringing window %p to front.",
+                             SRCNAME, __func__, wnd);
+                  bring_to_front (wnd);
+                }
+              else
+                {
+                  log_debug ("%s:%s: No active window found for bring to front.",
+                             SRCNAME, __func__);
+                }
+              break;
+            }
           case (WKS_NOTIFY):
             {
               WKSHelper::instance ()->notify ((const char *) ctx->data);
diff --git a/src/windowmessages.h b/src/windowmessages.h
index 8fdd55e..979f0b4 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -49,6 +49,7 @@ typedef enum _gpgol_wmsg_type
   CLOSE, /* Close the message in the next event loop. */
   CRYPTO_DONE, /* Sign / Encrypt done. */
   WKS_NOTIFY, /* Show a WKS Notification. */
+  BRING_TO_FRONT, /* Bring the active Outlook window to the front. */
 } gpgol_wmsg_type;
 
 typedef struct

commit 7f4d6d27fa0242d6d48dcc8f54149fd77af4891f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 6 09:50:52 2018 +0100

    Add new Window Message helper
    
    * src/windowmessages.cpp (do_async, do_in_ui_thread_async):
    Add new fire and forget window messaging helper.
    * src/windowmessages.h: Update accordingly.

diff --git a/src/windowmessages.cpp b/src/windowmessages.cpp
index 9bb0f5c..e9934a5 100644
--- a/src/windowmessages.cpp
+++ b/src/windowmessages.cpp
@@ -194,6 +194,25 @@ do_in_ui_thread (gpgol_wmsg_type type, void *data)
   return ctx.err;
 }
 
+static DWORD WINAPI
+do_async (LPVOID arg)
+{
+  wm_ctx_t *ctx = (wm_ctx_t*) arg;
+  send_msg_to_ui_thread (ctx);
+  xfree (ctx);
+  return 0;
+}
+
+void
+do_in_ui_thread_async (gpgol_wmsg_type type, void *data)
+{
+  wm_ctx_t *ctx = (wm_ctx_t *) calloc (1, sizeof (wm_ctx_t));
+  ctx->wmsg_type = type;
+  ctx->data = data;
+
+  CloseHandle (CreateThread (NULL, 0, do_async, (LPVOID) ctx, 0, NULL));
+}
+
 static std::vector <LPDISPATCH> explorers;
 
 void
diff --git a/src/windowmessages.h b/src/windowmessages.h
index 69762af..8fdd55e 100644
--- a/src/windowmessages.h
+++ b/src/windowmessages.h
@@ -73,6 +73,11 @@ send_msg_to_ui_thread (wm_ctx_t *ctx);
 int
 do_in_ui_thread (gpgol_wmsg_type type, void *data);
 
+/** Send a message to the UI thread but returns
+    immediately without waiting for the execution. */
+void
+do_in_ui_thread_async (gpgol_wmsg_type type, void *data);
+
 /** Create our filter before outlook Window Messages. */
 HHOOK
 create_message_hook();

commit 149a0928250aad96a78cf695ec91d9a396b42dbc
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 6 09:02:20 2018 +0100

    Be more lenient with broken PGP Inline messages
    
    * src/mimedataprovider.cpp (MimeDataProvider::collect_data):
    Fix up PGP Messages.
    
    --
    In the Outlook world sometimes messages are rewritten / converted
    to HTML and then converted back to Plaintext etc.
    This can lead to broken PGP Messages where there is extra
    whitespace. We now fix up the whitespace and remove comments
    in the Mimedataprovider in the spirit of trying to accept
    as much input as possible.
    
    GnuPG-Bug-Id: T3821

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index a760486..ff6538c 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -22,12 +22,14 @@
 #include "xmalloc.h"
 #include <string.h>
 #include <vector>
+#include <sstream>
 
 #include "mimedataprovider.h"
 #include "parsetlv.h"
 #include "rfc822parse.h"
 #include "rfc2047parse.h"
 #include "attachment.h"
+#include "cpphelp.h"
 
 #ifndef HAVE_W32_SYSTEM
 #define stricmp strcasecmp
@@ -770,6 +772,8 @@ MimeDataProvider::collect_data(LPSTREAM stream)
   char buf[BUFSIZE];
   ULONG bRead;
   bool first_read = true;
+  bool is_pgp_message = false;
+  size_t allRead = 0;
   while ((hr = stream->Read (buf, BUFSIZE, &bRead)) == S_OK ||
          hr == S_FALSE)
     {
@@ -777,11 +781,11 @@ MimeDataProvider::collect_data(LPSTREAM stream)
         {
           log_mime_parser ("%s:%s: Input stream at EOF.",
                            SRCNAME, __func__);
-          return;
+          break;
         }
       log_mime_parser ("%s:%s: Read %lu bytes.",
                        SRCNAME, __func__, bRead);
-
+      allRead += bRead;
       if (first_read)
         {
           if (bRead > 12 && strncmp ("MIME-Version", buf, 12) == 0)
@@ -800,6 +804,18 @@ MimeDataProvider::collect_data(LPSTREAM stream)
                          SRCNAME, __func__);
 
             }
+          /* check for the PGP MESSAGE marker to see if we have it. */
+          if (bRead && m_collect_everything)
+            {
+              std::string tmp (buf, bRead);
+              std::size_t found = tmp.find ("-----BEGIN PGP MESSAGE-----");
+              if (found != std::string::npos)
+                {
+                  log_debug ("%s:%s: found PGP Message marker,",
+                             SRCNAME, __func__);
+                  is_pgp_message = true;
+                }
+            }
         }
       first_read = false;
 
@@ -822,12 +838,53 @@ MimeDataProvider::collect_data(LPSTREAM stream)
           log_error ("%s:%s: Collect failed to consume anything.\n"
                      "Buffer too small?",
                      SRCNAME, __func__);
-          return;
+          break;
         }
       log_mime_parser ("%s:%s: Consumed: " SIZE_T_FORMAT " bytes",
                        SRCNAME, __func__, m_rawbuf.size() - not_taken);
       m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
     }
+
+
+  if (is_pgp_message && allRead < (1024 * 100))
+    {
+      /* Sometimes received PGP Messsages contain extra whitespace /
+         newlines. To also accept such messages we fix up pgp inline
+         messages here. We only do this for messages which are smaller
+         then a hundred KByte for performance. */
+      log_debug ("%s:%s: Fixing up a possible broken message.",
+                 SRCNAME, __func__);
+      /* Copy crypto data to string */
+      std::string data = m_crypto_data.toString();
+      m_crypto_data = GpgME::Data();
+      std::istringstream iss (data);
+      // Now parse it by line.
+      std::string line;
+      while (std::getline (iss, line))
+        {
+          trim (line);
+          if (line == "-----BEGIN PGP MESSAGE-----")
+            {
+              /* Finish an armor header */
+              line += "\n\n";
+              m_crypto_data.write (line.c_str (), line.size ());
+              continue;
+            }
+          /* Remove empty lines */
+          if (line.empty())
+            {
+              continue;
+            }
+          if (line.find (':') != std::string::npos)
+            {
+              log_mime_parser ("%s:%s: Removing comment '%s'.",
+                               SRCNAME, __func__, line.c_str ());
+              continue;
+            }
+          line += '\n';
+          m_crypto_data.write (line.c_str (), line.size ());
+        }
+    }
 }
 #endif
 

commit ba9ffe523a0848f35c6347e256f3cc74112752f7
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 6 09:01:33 2018 +0100

    Add trim and ltrim to cpphelp
    
    * src/cpphelp.cpp (ltrim, trim): New.
    * src/cpphelp.h: Update accordingly.

diff --git a/src/cpphelp.cpp b/src/cpphelp.cpp
index 8d38feb..122703e 100644
--- a/src/cpphelp.cpp
+++ b/src/cpphelp.cpp
@@ -48,10 +48,26 @@ release_cArray (char **carray)
 }
 
 void
-rtrim(std::string &s) {
-    s.erase(std::find_if(s.rbegin(), s.rend(), [](int ch) {
-        return !std::isspace(ch);
-    }).base(), s.end());
+rtrim(std::string &s)
+{
+  s.erase (std::find_if (s.rbegin(), s.rend(), [] (int ch) {
+      return !std::isspace(ch);
+  }).base(), s.end());
+}
+
+void
+ltrim(std::string &s)
+{
+  s.erase (s.begin(), std::find_if (s.begin(), s.end(), [] (int ch) {
+      return !std::isspace(ch);
+  }));
+}
+
+void
+trim(std::string &s)
+{
+  ltrim (s);
+  rtrim (s);
 }
 
 char **
diff --git a/src/cpphelp.h b/src/cpphelp.h
index 51ffe80..c2f2983 100644
--- a/src/cpphelp.h
+++ b/src/cpphelp.h
@@ -32,7 +32,9 @@
 void release_cArray (char **carray);
 
 /* Trim whitespace from a string. */
-void rtrim(std::string &s);
+void rtrim (std::string &s);
+void ltrim (std::string &s);
+void trim (std::string &s);
 
 /* Convert a string vector to a null terminated char array */
 char **vector_to_cArray (const std::vector<std::string> &vec);

commit 8be065b5c8e095eea2ddbce5db2b5d2741a45dc4
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Tue Mar 6 08:36:53 2018 +0100

    Auto update translation
    
    * po/de.po: Msgmerge moves the newline.

diff --git a/po/de.po b/po/de.po
index 1436756..c0f8061 100644
--- a/po/de.po
+++ b/po/de.po
@@ -1152,8 +1152,7 @@ msgstr ""
 "\n"
 "Tragen Sie ihren öffentlichen Schlüssel in diesem\n"
 "Verzeichnis ein um es anderen leicht zu machen ihnen verschlüsselte\n"
-"Mails zu schicken. "
-"\n"
+"Mails zu schicken. \n"
 "Dies ist sicher und kostenlos!\n"
 "\n"
 "Automatisch eintragen?"

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

Summary of changes:
 po/de.po                 |  3 +--
 src/cpphelp.cpp          | 24 +++++++++++++++---
 src/cpphelp.h            |  4 ++-
 src/mail.cpp             |  7 ++++++
 src/mimedataprovider.cpp | 63 +++++++++++++++++++++++++++++++++++++++++++++---
 src/windowmessages.cpp   | 35 +++++++++++++++++++++++++++
 src/windowmessages.h     |  6 +++++
 7 files changed, 132 insertions(+), 10 deletions(-)


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




More information about the Gnupg-commits mailing list