[git] GpgOL - branch, nomapi, updated. gpgol-1.4.0-50-gd4f11b7

by Andre Heinecke cvs at cvs.gnupg.org
Thu Sep 22 15:53:04 CEST 2016


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, nomapi has been updated
       via  d4f11b756f1811d123759b96815fbd6aac3cb76f (commit)
       via  57ab9c118291ba25af0db667f33de59314d98637 (commit)
       via  27a18489402923163fd2358f1bd24dbf9b227c76 (commit)
       via  0b12e8baa959b72450dec98339cbe9f8c4fa4730 (commit)
       via  f0aacc3bfb2b89ddc86188c577111e511197c228 (commit)
       via  b84b06533884150e68d6846bde8e57c97114a041 (commit)
       via  c680a4d6715576df021c869a48c1e74b77273472 (commit)
      from  03353e62d35b54051198f1ef2f076c2fdbdf3136 (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 d4f11b756f1811d123759b96815fbd6aac3cb76f
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:52:05 2016 +0200

    tests: Add simple multiplart/signed test
    
    * tests/data/openpgp-signed-no-attach.mbox,
     tests/data/openpgp-signed-no-attach.plain: New.
    * tests/t-parser.cpp: Test it.
    (main): Add charset test.

diff --git a/tests/data/openpgp-signed-no-attach.mbox b/tests/data/openpgp-signed-no-attach.mbox
new file mode 100644
index 0000000..ca0a107
--- /dev/null
+++ b/tests/data/openpgp-signed-no-attach.mbox
@@ -0,0 +1,41 @@
+From andre.heinecke at intevation.de Thu Sep 22 12:49:10 2016
+From: Andre Heinecke <andre.heinecke at intevation.de>
+To: test at kolab.org
+Subject: Multipart Signed
+Date: Thu, 22 Sep 2016 14:49:10 +0200
+Message-ID: <1915945.LqWf2jQE2O at esus>
+X-KMail-Identity: 1688019700
+X-KMail-Dictionary: en
+User-Agent: KMail/4.14.10 (Linux/3.16.0-4-amd64; KDE/4.14.17; x86_64; git-61c3358; 2015-06-25)
+MIME-Version: 1.0
+Content-Type: multipart/signed; boundary="nextPart1693035.rOZRFYHO8F"; micalg="pgp-sha256"; protocol="application/pgp-signature"
+
+--nextPart1693035.rOZRFYHO8F
+Content-Transfer-Encoding: quoted-printable
+Content-Type: text/plain; charset="iso-8859-1"
+
+Hallo Welt!
+=2D-=20
+Andre Heinecke |  ++49-541-335083-262  | http://www.intevation.de/
+Intevation GmbH, Neuer Graben 17, 49074 Osnabr=FCck | AG Osnabr=FCck, H=
+R B 18998
+Gesch=E4ftsf=FChrer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wa=
+gner
+--nextPart1693035.rOZRFYHO8F
+Content-Type: application/pgp-signature; name="signature.asc"
+Content-Description: This is a digitally signed message part.
+Content-Transfer-Encoding: 7Bit
+
+-----BEGIN PGP SIGNATURE-----
+
+iQEcBAABCAAGBQJX49NGAAoJEI2YYMWPJG3mYDsH/3DuwYTTYSxYdk3WecCn2TPx
+UzzUB332tVE5SLzZcvH426jFwQ2qt7/f8kWjmr5+GCOenM6Nzz1FbC4K3ARuF4c3
+fZDlFegpsRg735uV8vjEEwQVkipyYMHeUJJ6d5O4FxF8q0dfkjNM53EC3cLiuKF7
+P4AjRZBycPyMf7XBaaU0zfMQkC+UkiBXMrcITQoPSSgbadlxLEc4oJIdD8zZDFVx
+q2I8RFoKzVpHMn/OjBfXi94JVz7wCTa4wGG/emxoamRvqMp2S5SWPNps79/Trvzv
+64F+3UalXGBfDybyUYgGb0wLtXnbFux03GJoY20NMjsMRBBKYfqMQbh0m8VZSI4=
+=UY6M
+-----END PGP SIGNATURE-----
+
+--nextPart1693035.rOZRFYHO8F--
+
diff --git a/tests/data/openpgp-signed-no-attach.plain b/tests/data/openpgp-signed-no-attach.plain
new file mode 100644
index 0000000..aba8dba
--- /dev/null
+++ b/tests/data/openpgp-signed-no-attach.plain
@@ -0,0 +1,5 @@
+Hallo Welt!
+-- 
+Andre Heinecke |  ++49-541-335083-262  | http://www.intevation.de/
+Intevation GmbH, Neuer Graben 17, 49074 Osnabrück | AG Osnabrück, HR B 18998
+Geschäftsführer: Frank Koormann, Bernhard Reiter, Dr. Jan-Oliver Wagner
\ No newline at end of file
diff --git a/tests/t-parser.cpp b/tests/t-parser.cpp
index bd41395..4548058 100644
--- a/tests/t-parser.cpp
+++ b/tests/t-parser.cpp
@@ -31,20 +31,30 @@ struct
   const char *expected_html_body_file;
   const char *expected_return;
   int attachment_cnt;
+  const char *expected_charset;
 } test_data[] = {
   { DATADIR "/inlinepgpencrypted.mbox",
     MSGTYPE_GPGOL_PGP_MESSAGE,
     DATADIR "/inlinepgpencrypted.plain",
     NULL,
     NULL,
-    0 },
+    0,
+    NULL},
   { DATADIR "/openpgp-encrypted.mbox",
     MSGTYPE_GPGOL_MULTIPART_ENCRYPTED,
     DATADIR "/openpgp-encrypted.plain",
     NULL,
     NULL,
-    0 },
-  { NULL, MSGTYPE_UNKNOWN, NULL, NULL, 0 }
+    0,
+    NULL},
+  { DATADIR "/openpgp-signed-no-attach.mbox",
+    MSGTYPE_GPGOL_MULTIPART_SIGNED,
+    DATADIR "/openpgp-signed-no-attach.plain",
+    NULL,
+    NULL,
+    0,
+    "iso-8859-1"},
+  { NULL, MSGTYPE_UNKNOWN, NULL, NULL, NULL, 0, NULL }
 };
 
 
@@ -133,6 +143,16 @@ int main()
               exit(1);
             }
         }
+      if (test_data[i].expected_charset)
+        {
+          if (parser.get_body_charset() != test_data[i].expected_charset)
+            {
+              fprintf (stderr, "Charset mismatch. Actual: %s Expected: %s\n",
+                      parser.get_body_charset().c_str(),
+                      test_data[i].expected_charset);
+              exit(1);
+            }
+        }
       fprintf (stderr, "Pass: %s\n", test_data[i].input_file);
       i++;
     }

commit 57ab9c118291ba25af0db667f33de59314d98637
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:51:07 2016 +0200

    Add .gitattributes to mark .mbox and .plain as bin
    
    * .gitattributes: New
    
    --
    This enables commiting raw test data that may contain
    what in code would be whitespace errors.

diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..49574b5
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+*.plain binary
+*.mbox binary

commit 27a18489402923163fd2358f1bd24dbf9b227c76
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:45:46 2016 +0200

    Add charset getters to parsecontroller
    
    * src/parsecontroller.cpp (ParseController::get_html_charset),
    (ParseController::get_body_charset): New.
    * src/parsecontroller.h: Update accordingly.

diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 627eff8..872d454 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -223,6 +223,32 @@ ParseController::get_body() const
     }
 }
 
+const std::string
+ParseController::get_body_charset() const
+{
+  if (m_outputprovider)
+    {
+      return m_outputprovider->get_body_charset();
+    }
+  else
+    {
+      return std::string();
+    }
+}
+
+const std::string
+ParseController::get_html_charset() const
+{
+  if (m_outputprovider)
+    {
+      return m_outputprovider->get_body_charset();
+    }
+  else
+    {
+      return std::string();
+    }
+}
+
 std::vector<std::shared_ptr<Attachment> >
 ParseController::get_attachments() const
 {
diff --git a/src/parsecontroller.h b/src/parsecontroller.h
index 622448b..350350d 100644
--- a/src/parsecontroller.h
+++ b/src/parsecontroller.h
@@ -68,6 +68,15 @@ public:
   /** Get the Body. Call parse first. */
   const std::string get_body() const;
 
+  /** Get the charset of the body. Call parse first.
+    *
+    * That is a bit of a clunky API to make testing
+    * without outlook easier as we use mlang for Charset
+    * conversion which is not available on GNU/Linux.
+  */
+  const std::string get_body_charset() const;
+  const std::string get_html_charset() const;
+
   /** Get an alternative? HTML Body. Call parse first. */
   const std::string get_html_body() const;
 

commit 0b12e8baa959b72450dec98339cbe9f8c4fa4730
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:45:07 2016 +0200

    tests: Improve run-parser output
    
    * tests/run-parser.cpp (main): Improve output.

diff --git a/tests/run-parser.cpp b/tests/run-parser.cpp
index 3144d4a..4c804fd 100644
--- a/tests/run-parser.cpp
+++ b/tests/run-parser.cpp
@@ -104,14 +104,17 @@ int main(int argc, char **argv)
 
   fp_in = fopen (argv[0], "rb");
 
-  ParseController parser(fp_in, msgtype);
-  std::cout << "Parse result: " << parser.parse();
-  std::cout << "\nDecrypt result:\n" << parser.decrypt_result()
-            << "\nVerify result:\n" << parser.verify_result()
-            << "\nBEGIN BODY\n" << parser.get_body() << "\nEND BODY"
-            << "\nBEGIN HTML\n" << parser.get_html_body() << "\nEND HTML";
-  for (auto attach: parser.get_attachments())
     {
-      std::cout << "Attachment: " << attach->get_display_name();
+      ParseController parser(fp_in, msgtype);
+      std::cout << "Parse result: " << parser.parse();
+      std::cout << "\nDecrypt result:\n" << parser.decrypt_result()
+                << "\nVerify result:\n" << parser.verify_result()
+                << "\nBEGIN BODY\n" << parser.get_body() << "\nEND BODY"
+                << "\nBEGIN HTML\n" << parser.get_html_body() << "\nEND HTML";
+      for (auto attach: parser.get_attachments())
+        {
+          std::cout << "Attachment: " << attach->get_display_name();
+        }
     }
+  fclose (fp_in);
 }

commit f0aacc3bfb2b89ddc86188c577111e511197c228
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:42:17 2016 +0200

    Do chained parsing for decrypted content with sigs
    
    * src/parsecontroller.cpp (ParseController::parse): Verify
    after a decrypt only if a signature was found.

diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 1ee6ad1..627eff8 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -136,22 +136,48 @@ ParseController::parse()
       auto combined_result = ctx->decryptAndVerify(input, output);
       m_decrypt_result = combined_result.first;
       m_verify_result = combined_result.second;
+      if (!m_decrypt_result.error () &&
+          m_verify_result.signatures ().empty() &&
+          m_outputprovider->signature ())
+        {
+          /* There is a signature in the output. So we have
+             to verify it now as an extra step. */
+          input = Data (m_outputprovider);
+          delete m_inputprovider;
+          m_inputprovider = m_outputprovider;
+          m_outputprovider = new MimeDataProvider();
+          output = Data(m_outputprovider);
+          verify = true;
+        }
+      else
+        {
+          verify = false;
+        }
     }
-  else
+  if (verify)
     {
       const auto sig = m_inputprovider->signature();
-      /* Ignore the first two bytes if we did not decrypt. */
-      input.seek (2, SEEK_SET);
+      input.seek (0, SEEK_SET);
       if (sig)
         {
           sig->seek (0, SEEK_SET);
           m_verify_result = ctx->verifyDetachedSignature(*sig, input);
+          /* Copy the input to output to do a mime parsing. */
+          char buf[4096];
+          input.seek (0, SEEK_SET);
+          output.seek (0, SEEK_SET);
+          size_t nread;
+          while ((nread = input.read (buf, 4096)) > 0)
+            {
+              output.write (buf, nread);
+            }
         }
       else
         {
           m_verify_result = ctx->verifyOpaqueSignature(input, output);
         }
     }
+  delete ctx;
   log_debug ("%s:%s: decrypt err: %i verify err: %i",
              SRCNAME, __func__, m_decrypt_result.error().code(),
              m_verify_result.error().code());

commit b84b06533884150e68d6846bde8e57c97114a041
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:39:39 2016 +0200

    Save body charset in mimedataprovider
    
    * src/mimedataprovider.cpp (MimeDataProvider::get_html_charset),
    (MimeDataProvider::get_body_charset): New.
    (MimeDataProvider::collect_input_lines): Collect charset. Fix html
    collection.
    * src/mimedataprovider.h: Update accordingly.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index da54055..5761a43 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -647,6 +647,11 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                           m_body += "\r\n";
                         }
                     }
+                  if (m_body_charset.empty())
+                    {
+                      m_body_charset = m_mime_ctx->mimestruct_cur->charset ?
+                                       m_mime_ctx->mimestruct_cur->charset : "";
+                    }
                   m_mime_ctx->collect_body = 2;
                 }
               else if (m_mime_ctx->collect_html_body)
@@ -656,9 +661,14 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                       m_html_body += std::string(linebuf, len);
                       if (!m_mime_ctx->is_base64_encoded && !slbrk)
                         {
-                          m_body += "\r\n";
+                          m_html_body += "\r\n";
                         }
                     }
+                  if (m_html_charset.empty())
+                    {
+                      m_html_charset = m_mime_ctx->mimestruct_cur->charset ?
+                                       m_mime_ctx->mimestruct_cur->charset : "";
+                    }
                   m_mime_ctx->collect_html_body = 2;
                 }
               else if (m_mime_ctx->current_attachment && len)
@@ -886,3 +896,13 @@ const std::string &MimeDataProvider::get_html_body()
     }
   return m_html_body;
 }
+
+const std::string &MimeDataProvider::get_html_charset() const
+{
+  return m_html_charset;
+}
+
+const std::string &MimeDataProvider::get_body_charset() const
+{
+  return m_body_charset;
+}
diff --git a/src/mimedataprovider.h b/src/mimedataprovider.h
index 2311881..28661a7 100644
--- a/src/mimedataprovider.h
+++ b/src/mimedataprovider.h
@@ -101,10 +101,15 @@ public:
 
   mime_context_t mime_context() {return m_mime_ctx;}
 
+  /* Checks if there is body data left in the buffer e.g. for inline messages
+     that did not end with a linefeed and adds it to body / returns the body. */
   const std::string &get_body();
+  /* Similar for html body */
   const std::string &get_html_body();
   const std::vector <std::shared_ptr<Attachment> > get_attachments() const
     {return m_attachments;}
+  const std::string &get_html_charset() const;
+  const std::string &get_body_charset() const;
 private:
 #ifdef HAVE_W32_SYSTEM
   /* Collect the data from mapi. */
@@ -130,5 +135,9 @@ private:
   mime_context_t m_mime_ctx;
   /* List of attachments. */
   std::vector<std::shared_ptr<Attachment> > m_attachments;
+  /* Charset of html */
+  std::string m_html_charset;
+  /* Charset of body */
+  std::string m_body_charset;
 };
 #endif // MIMEDATAPROVIDER_H

commit c680a4d6715576df021c869a48c1e74b77273472
Author: Andre Heinecke <aheinecke at intevation.de>
Date:   Thu Sep 22 15:38:45 2016 +0200

    Fix collecting body when not collecting crypto
    
    * src/mimedataprovider.cpp (MimeDataProvider::collect_input_lines):
    Collect body correctly.

diff --git a/src/mimedataprovider.cpp b/src/mimedataprovider.cpp
index bf84b7a..da54055 100644
--- a/src/mimedataprovider.cpp
+++ b/src/mimedataprovider.cpp
@@ -623,8 +623,7 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
               m_crypto_data.write (linebuf, pos);
               m_mime_ctx->collect_crypto_data = 2;
             }
-          if (m_mime_ctx->in_data && m_mime_ctx->collect_attachment
-              && !m_mime_ctx->collect_crypto_data)
+          if (m_mime_ctx->in_data && m_mime_ctx->collect_attachment)
             {
               /* We are inside of an attachment part.  Write it out. */
               if (m_mime_ctx->collect_attachment == 1)  /* Skip the first line. */
@@ -701,7 +700,7 @@ MimeDataProvider::collect_input_lines(const char *input, size_t insize)
                     m_signature->write("\r\n", 2);
                 }
             }
-          else if (m_mime_ctx->in_data)
+          else if (m_mime_ctx->in_data && !m_mime_ctx->start_hashing)
             {
               /* We are inside the data.  That should be the actual
                  ciphertext in the given encoding. */

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

Summary of changes:
 .gitattributes                            |  2 ++
 src/mimedataprovider.cpp                  | 27 +++++++++++---
 src/mimedataprovider.h                    |  9 +++++
 src/parsecontroller.cpp                   | 58 +++++++++++++++++++++++++++++--
 src/parsecontroller.h                     |  9 +++++
 tests/data/openpgp-signed-no-attach.mbox  | 41 ++++++++++++++++++++++
 tests/data/openpgp-signed-no-attach.plain |  5 +++
 tests/run-parser.cpp                      | 19 +++++-----
 tests/t-parser.cpp                        | 26 ++++++++++++--
 9 files changed, 178 insertions(+), 18 deletions(-)
 create mode 100644 .gitattributes
 create mode 100644 tests/data/openpgp-signed-no-attach.mbox
 create mode 100644 tests/data/openpgp-signed-no-attach.plain


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




More information about the Gnupg-commits mailing list