[git] GpgOL - branch, master, updated. gpgol-2.3.0-25-ga0671cc

by Andre Heinecke cvs at cvs.gnupg.org
Fri Sep 7 10:35:19 CEST 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  a0671ccbb477e31d25547532004fa6fd16a29f78 (commit)
       via  50c514d6bd6026076f5f467b7d8523dff2ce97aa (commit)
      from  1cefdea05092b68a3db0c6eaa32341c3123f9f37 (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 a0671ccbb477e31d25547532004fa6fd16a29f78
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 7 10:28:11 2018 +0200

    Fix encoding of last line
    
    * src/mimedataprovider.cpp (get_body, get_html_body): Don't
    append raw undecoded data anymore.
    (MimeDataProvider::finalize): New. Parse the last unfinished data.
    * src/parsecontroller.cpp (ParseController::parse): Call
    finalize.
    
    --
    Before this a quoted printable line without a line feed at the
    end would not be decoded. Leading to a broken display.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index e869cc5..ba49428 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -1030,37 +1030,29 @@ MimeDataProvider::create_attachment()
   /* TODO handle encoding */
 }
 
-const std::string &MimeDataProvider::get_body ()
+void MimeDataProvider::finalize ()
 {
-  if (m_rawbuf.size())
+  if (m_rawbuf.size ())
     {
-      /* If there was some data left in the rawbuf this could
-         mean that some plaintext was not finished with a linefeed.
-         In that case we append it to the bodies. */
-      m_body += m_rawbuf;
-      m_html_body += m_rawbuf;
-      m_rawbuf.clear();
+      m_rawbuf += "\r\n";
+      size_t not_taken = collect_input_lines (m_rawbuf.c_str(),
+                                              m_rawbuf.size());
+      m_rawbuf.erase (0, m_rawbuf.size() - not_taken);
+      if (m_rawbuf.size ())
+        {
+          log_error ("%s:%s: Collect left data in buffer.\n",
+                     SRCNAME, __func__);
+        }
     }
+}
+
+const std::string &MimeDataProvider::get_body ()
+{
   return m_body;
 }
 
 const std::string &MimeDataProvider::get_html_body ()
 {
-  if (!m_has_html_body)
-    {
-      /* Don't do the last line handling if we don't
-         have html */
-      return m_html_body;
-    }
-  if (m_rawbuf.size())
-    {
-      /* If there was some data left in the rawbuf this could
-         mean that some plaintext was not finished with a linefeed.
-         In that case we append it to the bodies. */
-      m_body += m_rawbuf;
-      m_html_body += m_rawbuf;
-      m_rawbuf.clear();
-    }
   return m_html_body;
 }
 
diff --git a/src/mimedataprovider.h b/src/mimedataprovider.h
index 4841d73..40e1c18 100644
--- a/src/mimedataprovider.h
+++ b/src/mimedataprovider.h
@@ -118,6 +118,9 @@ public:
   const std::string &get_body_charset() const;
 
   void set_has_html_body(bool value) {m_has_html_body = value;}
+
+  /* Finalize the bodys */
+  void finalize ();
 private:
 #ifdef HAVE_W32_SYSTEM
   /* Collect the data from mapi. */
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index df5b8fe..82d10e7 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -519,6 +519,11 @@ ParseController::parse()
     }
   TRACEPOINT;
 
+  if (m_outputprovider)
+    {
+      m_outputprovider->finalize ();
+    }
+
   return;
 }
 

commit 50c514d6bd6026076f5f467b7d8523dff2ce97aa
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Fri Sep 7 09:56:35 2018 +0200

    Fix a possible crash when reactivating gpgol
    
    * src/gpgoladdin.cpp (GpgolAddin::invalidateRibbons)
    (GpgolAddin::addRibbon): New.
    (g_ribbon_uis): Removed.
    
    --
    This keeps the ribbon ui in a member variable so that they
    are cleared out when the GpgolAddin class is remvoved on
    unload.
    
    Fixes a potential crash when a user would activate gpgol
    after deactivating it in the same outlook session and
    stale ribbon ui pointers would be accessed.

diff --git a/src/gpgoladdin.cpp b/src/gpgoladdin.cpp
index 6ab5919..75e9cc8 100644
--- a/src/gpgoladdin.cpp
+++ b/src/gpgoladdin.cpp
@@ -63,8 +63,6 @@ ULONG addinLocks = 0;
 
 bool can_unload = false;
 
-static std::list<LPDISPATCH> g_ribbon_uis;
-
 static GpgolAddin * addin_instance = NULL;
 
 /* This is the main entry point for the addin
@@ -792,7 +790,7 @@ GpgolRibbonExtender::Invoke (DISPID dispid, REFIID riid, LCID lcid,
 
       case ID_ON_LOAD:
           {
-            g_ribbon_uis.push_back (parms->rgvarg[0].pdispVal);
+            GpgolAddin::get_instance ()->addRibbon (parms->rgvarg[0].pdispVal);
             return S_OK;
           }
       case ID_CMD_OPEN_OPTIONS:
@@ -1142,16 +1140,10 @@ GpgolRibbonExtender::GetCustomUI (BSTR RibbonID, BSTR * RibbonXml)
    Updated. Sadly we don't know which ribbon_ui needs updates
    so we have to invalidate everything.
 */
-void gpgoladdin_invalidate_ui ()
+void
+gpgoladdin_invalidate_ui ()
 {
-  std::list<LPDISPATCH>::iterator it;
-
-  for (it = g_ribbon_uis.begin(); it != g_ribbon_uis.end(); ++it)
-    {
-      log_debug ("%s:%s: Invalidating ribbon: %p",
-                 SRCNAME, __func__, *it);
-      invoke_oom_method (*it, "Invalidate", NULL);
-    }
+  GpgolAddin::get_instance ()->invalidateRibbons();
 }
 
 GpgolAddin *
@@ -1170,6 +1162,27 @@ GpgolAddin::get_instance ()
 }
 
 void
+GpgolAddin::invalidateRibbons()
+{
+  /* This can only be done in the main thread so no
+     need for locking or copying here. */
+  for (const auto it: m_ribbon_uis)
+    {
+      log_debug ("%s:%s: Invalidating ribbon: %p",
+                 SRCNAME, __func__, it);
+      invoke_oom_method (it, "Invalidate", NULL);
+    }
+  log_debug ("%s:%s: Invalidation done.",
+             SRCNAME, __func__);
+}
+
+void
+GpgolAddin::addRibbon (LPDISPATCH disp)
+{
+  m_ribbon_uis.push_back (disp);
+}
+
+void
 GpgolAddin::shutdown ()
 {
   if (m_shutdown)
diff --git a/src/gpgoladdin.h b/src/gpgoladdin.h
index 1641942..3627a01 100644
--- a/src/gpgoladdin.h
+++ b/src/gpgoladdin.h
@@ -217,6 +217,12 @@ public:
   std::shared_ptr<DispCache> get_dispcache () { return m_dispcache; }
   bool isShutdown() { return m_shutdown; };
 
+  /* Register a ribbon ui component */
+  void addRibbon (LPDISPATCH ribbon);
+
+  /* Invalidate the ribbons. */
+  void invalidateRibbons ();
+
 private:
   ULONG m_lRef;
   GpgolRibbonExtender* m_ribbonExtender;
@@ -231,6 +237,7 @@ private:
   HHOOK m_hook;
   std::vector<LPDISPATCH> m_explorerEventSinks;
   std::shared_ptr<DispCache> m_dispcache;
+  std::vector<LPDISPATCH> m_ribbon_uis;
 };
 
 class GpgolAddinFactory: public IClassFactory

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

Summary of changes:
 src/gpgoladdin.cpp       | 37 +++++++++++++++++++++++++------------
 src/gpgoladdin.h         |  7 +++++++
 src/mimedataprovider.cpp | 38 +++++++++++++++-----------------------
 src/mimedataprovider.h   |  3 +++
 src/parsecontroller.cpp  |  5 +++++
 5 files changed, 55 insertions(+), 35 deletions(-)


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




More information about the Gnupg-commits mailing list