[git] GpgOL - branch, master, updated. outlook-2007-removal-12-gfc05ec0
by Andre Heinecke
cvs at cvs.gnupg.org
Fri Jun 1 14:17:09 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 fc05ec08203882176486d7b19ab8504c12910f0c (commit)
via 5f31ee9b15b34c37ef5696097292782a565ccaa0 (commit)
via f46586d886cda26ba9c452a959a0d14013a11add (commit)
from a193ad36f82ecf8e5a18b74dc9bc71fcf1ff2b38 (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 fc05ec08203882176486d7b19ab8504c12910f0c
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jun 1 14:09:07 2018 +0200
Try to convert clearsigned to utf8 on verify fail
* src/parsecontroller.cpp (ParseController::parse): Try again
with UTF-8 if verify opaque failed.
--
We have a bit of a problem in that we access the body
through the 8 bit interface and we need to give it
to GnuPG as 8 bit.
We now try utf8 if the native encoding did not
give us a result. It's a bit of a hack but will
work for messages from gpgol to gpgol and hopefully
for some others, too.
GnuPG-Bug-Id: T3962
diff --git a/src/parsecontroller.cpp b/src/parsecontroller.cpp
index 0db7734..88263a6 100644
--- a/src/parsecontroller.cpp
+++ b/src/parsecontroller.cpp
@@ -371,6 +371,54 @@ ParseController::parse()
else
{
m_verify_result = ctx->verifyOpaqueSignature(input, output);
+
+ const auto sigs = m_verify_result.signatures();
+ bool allBad = sigs.size();
+ for (const auto s :sigs)
+ {
+ if (!(s.summary() & Signature::Red))
+ {
+ allBad = false;
+ break;
+ }
+ }
+
+ if (allBad)
+ {
+ log_debug ("%s:%s:%p inline verify error trying native to utf8.",
+ SRCNAME, __func__, this);
+
+ // Maybe we would need to take the internetcodepage here instead
+ // of native?
+ char *utf8 = native_to_utf8 (input.toString().c_str());
+ if (utf8)
+ {
+ // Try again after conversion.
+ delete ctx;
+ ctx = Context::createForProtocol (protocol);
+ ctx->setArmor (true);
+ if (!m_sender.empty())
+ {
+ ctx->setSender(m_sender.c_str());
+ }
+
+ input = Data (utf8, strlen (utf8));
+ xfree (utf8);
+
+ // Use a fresh output
+ auto provider = new MimeDataProvider (true);
+
+ // Warning: The dtor of the Data object touches
+ // the provider. So we have to delete it after
+ // the assignment.
+ output = Data (provider);
+ delete m_outputprovider;
+ m_outputprovider = provider;
+
+ // Try again
+ m_verify_result = ctx->verifyOpaqueSignature(input, output);
+ }
+ }
}
}
delete ctx;
commit 5f31ee9b15b34c37ef5696097292782a565ccaa0
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jun 1 14:07:10 2018 +0200
Properly set UTF8 encoding for clearsigned
* src/cryptcontroller.cpp(CryptController::update_mail_mapi):
Set CPID.
* src/mail.cpp (Mail::update_body): Fix charset variable.
(Mail::inline_body_to_body): Also set CPID in OOM.
* src/mymapitags.h: Define PR_INTERNET_CPID.
--
GnuPG-Bug-Id: T3962
diff --git a/src/cryptcontroller.cpp b/src/cryptcontroller.cpp
index 2e9829b..7f701b2 100644
--- a/src/cryptcontroller.cpp
+++ b/src/cryptcontroller.cpp
@@ -29,6 +29,7 @@
#include "wks-helper.h"
#include "overlay.h"
#include "keycache.h"
+#include "mymapitags.h"
#include <gpgme++/context.h>
#include <gpgme++/signingresult.h>
@@ -883,14 +884,6 @@ CryptController::update_mail_mapi ()
{
log_debug ("%s:%s", SRCNAME, __func__);
- if (m_mail->do_pgp_inline ())
- {
- // Nothing to do for inline.
- log_debug ("%s:%s: Inline mail. No MAPI update.",
- SRCNAME, __func__);
- return 0;
- }
-
LPMESSAGE message = get_oom_base_message (m_mail->item());
if (!message)
{
@@ -899,6 +892,24 @@ CryptController::update_mail_mapi ()
return -1;
}
+ if (m_mail->do_pgp_inline ())
+ {
+ // Nothing to do for inline.
+ log_debug ("%s:%s: Inline mail. Setting encoding.",
+ SRCNAME, __func__);
+
+ SPropValue prop;
+ prop.ulPropTag = PR_INTERNET_CPID;
+ prop.Value.l = 65001;
+ if (HrSetOneProp (message, &prop))
+ {
+ log_error ("%s:%s: Failed to set CPID mapiprop.",
+ SRCNAME, __func__);
+ }
+
+ return 0;
+ }
+
mapi_attach_item_t *att_table = mapi_create_attach_table (message, 0);
// Set up the sink object for our MSOXSMIME attachment.
diff --git a/src/mail.cpp b/src/mail.cpp
index 4bdf8a6..b2d0fbe 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1090,7 +1090,7 @@ Mail::update_body()
const auto charset = m_parser->get_html_charset();
int codepage = 0;
- if (html_charset.empty())
+ if (charset.empty())
{
codepage = get_oom_int (m_mailitem, "InternetCodepage");
log_debug ("%s:%s: Did not find html charset."
@@ -2675,6 +2675,9 @@ Mail::inline_body_to_body()
return 0;
}
+ /* For inline we always work with UTF-8 */
+ put_oom_int (m_mailitem, "InternetCodepage", 65001);
+
int ret = put_oom_string (m_mailitem, "Body",
body.c_str ());
return ret;
diff --git a/src/mapihelp.cpp b/src/mapihelp.cpp
index 1dcef01..a4774cb 100644
--- a/src/mapihelp.cpp
+++ b/src/mapihelp.cpp
@@ -500,7 +500,7 @@ mapi_get_body_as_stream (LPMESSAGE message)
{
/* The store knows about the Internet Charset Body property,
thus try to get the body from this property if it exists. */
-
+
hr = message->OpenProperty (tag, &IID_IStream, 0, 0,
(LPUNKNOWN*)&stream);
if (!hr)
diff --git a/src/mymapitags.h b/src/mymapitags.h
index 1458102..69d1eef 100644
--- a/src/mymapitags.h
+++ b/src/mymapitags.h
@@ -847,6 +847,7 @@
#define PR_SENT_REPRESENTING_SMTP_ADDRESS_W PROP_TAG( PT_UNICODE, 0x5d02)
#define PidTagSenderSmtpAddress_W PROP_TAG( PT_UNICODE, 0x5d01)
#define PR_BLOCK_STATUS PROP_TAG( PT_LONG, 0x1096)
+#define PR_INTERNET_CPID PROP_TAG( PT_LONG, 0x3FDE)
#define PROP_ID_SECURE_MIN 0x67F0
#define PROP_ID_SECURE_MAX 0x67FF
commit f46586d886cda26ba9c452a959a0d14013a11add
Author: Andre Heinecke <aheinecke at intevation.de>
Date: Fri Jun 1 11:30:18 2018 +0200
Fix encoding for some inline pgp mails
* src/mail.cpp (Mail::update_body): Use InternetCodepage if
charset is not set by the parser.
* src/mlang-charset.cpp (ansi_charset_to_utf8): Add handling
for a directly provided codepage.
* src/rfc2047parse.c (rfc2047_decode_tokens): Update caller.
--
For PGP Inline the charset is not detected by the parsecontroller
in that case we now just use the InternetCodepage from OOM.
Tests show that this works properly.
GnuPG-Bug-Id: T3962
diff --git a/src/mail.cpp b/src/mail.cpp
index fefe2f9..4bdf8a6 100644
--- a/src/mail.cpp
+++ b/src/mail.cpp
@@ -1087,8 +1087,19 @@ Mail::update_body()
find_and_replace (html, "\r\r\n", "\r\n");
if (opt.prefer_html && !html.empty() && !m_block_html)
{
- char *converted = ansi_charset_to_utf8 (m_parser->get_html_charset().c_str(),
- html.c_str(), html.size());
+ const auto charset = m_parser->get_html_charset();
+
+ int codepage = 0;
+ if (html_charset.empty())
+ {
+ codepage = get_oom_int (m_mailitem, "InternetCodepage");
+ log_debug ("%s:%s: Did not find html charset."
+ " Using internet Codepage %i.",
+ SRCNAME, __func__, codepage);
+ }
+
+ char *converted = ansi_charset_to_utf8 (charset.c_str(), html.c_str(),
+ html.size(), codepage);
int ret = put_oom_string (m_mailitem, "HTMLBody", converted ? converted : "");
xfree (converted);
if (ret)
@@ -1162,8 +1173,21 @@ Mail::update_body()
}
find_and_replace (body, "\r\r\n", "\r\n");
- char *converted = ansi_charset_to_utf8 (m_parser->get_body_charset().c_str(),
- body.c_str(), body.size());
+
+ const auto plain_charset = m_parser->get_body_charset();
+
+ int codepage = 0;
+ if (plain_charset.empty())
+ {
+ codepage = get_oom_int (m_mailitem, "InternetCodepage");
+ log_debug ("%s:%s: Did not find body charset. "
+ "Using internet Codepage %i.",
+ SRCNAME, __func__, codepage);
+ }
+
+ char *converted = ansi_charset_to_utf8 (plain_charset.c_str(),
+ body.c_str(), body.size(),
+ codepage);
int ret = put_oom_string (m_mailitem, "Body", converted ? converted : "");
xfree (converted);
if (ret)
diff --git a/src/mlang-charset.cpp b/src/mlang-charset.cpp
index d800893..934c1e3 100644
--- a/src/mlang-charset.cpp
+++ b/src/mlang-charset.cpp
@@ -32,7 +32,7 @@ DEFINE_GUID (IID_IMultiLanguage, 0x275c23e1,0x3747,0x11d0,0x9f,
#include "mlang-charset.h"
char *ansi_charset_to_utf8 (const char *charset, const char *input,
- size_t inlen)
+ size_t inlen, int codepage)
{
LPMULTILANGUAGE multilang = NULL;
MIMECSETINFO mime_info;
@@ -44,9 +44,9 @@ char *ansi_charset_to_utf8 (const char *charset, const char *input,
wchar_t *buf;
char *ret;
- if (!charset || !strlen (charset))
+ if ((!charset || !strlen (charset)) && !codepage)
{
- log_debug ("%s:%s: No charset returning plain.",
+ log_debug ("%s:%s: No charset / codepage returning plain.",
SRCNAME, __func__);
return strdup (input);
}
@@ -71,20 +71,27 @@ char *ansi_charset_to_utf8 (const char *charset, const char *input,
uinlen = (unsigned int) inlen;
- mime_info.uiCodePage = 0;
- mime_info.uiInternetEncoding = 0;
- BSTR w_charset = utf8_to_wchar (charset);
- err = multilang->GetCharsetInfo (w_charset, &mime_info);
- xfree (w_charset);
- if (err != S_OK)
+ if (!codepage)
{
- log_error ("%s:%s: Failed to find charset for: %s",
- SRCNAME, __func__, charset);
- gpgol_release (multilang);
- return strdup(input);
+ mime_info.uiCodePage = 0;
+ mime_info.uiInternetEncoding = 0;
+ BSTR w_charset = utf8_to_wchar (charset);
+ err = multilang->GetCharsetInfo (w_charset, &mime_info);
+ xfree (w_charset);
+ if (err != S_OK)
+ {
+ log_error ("%s:%s: Failed to find charset for: %s",
+ SRCNAME, __func__, charset);
+ gpgol_release (multilang);
+ return strdup(input);
+ }
+ enc = (mime_info.uiInternetEncoding == 0) ? mime_info.uiCodePage :
+ mime_info.uiInternetEncoding;
+ }
+ else
+ {
+ enc = codepage;
}
- enc = (mime_info.uiInternetEncoding == 0) ? mime_info.uiCodePage :
- mime_info.uiInternetEncoding;
/** Get the size of the result */
err = multilang->ConvertStringToUnicode(&mode, enc, const_cast<char*>(input),
diff --git a/src/mlang-charset.h b/src/mlang-charset.h
index 06b0e68..7aaa26d 100644
--- a/src/mlang-charset.h
+++ b/src/mlang-charset.h
@@ -33,12 +33,13 @@ extern "C" {
* @param charset: ANSI name of the charset to decode.
* @param input: The input to convert.
* @param inlen: The size of the input.
+ * @param codepage: Alternative codepage to be prefered over the name.
*
* @returns NULL on error or an UTF-8 encoded NULL terminated string.
*/
char *ansi_charset_to_utf8 (const char *charset, const char *input,
- size_t inlen);
+ size_t inlen, int codepage);
#ifdef __cplusplus
}
#endif
diff --git a/src/rfc2047parse.c b/src/rfc2047parse.c
index 17c7f73..5c96467 100644
--- a/src/rfc2047parse.c
+++ b/src/rfc2047parse.c
@@ -581,7 +581,7 @@ rfc2047_decode_tokens (rfc2047_token *tokens, size_t buflen)
strncat (decoded, (char *) outptr, outlen);
} else {
#ifdef HAVE_W32_SYSTEM
- str = ansi_charset_to_utf8 (charset, outptr, outlen);
+ str = ansi_charset_to_utf8 (charset, outptr, outlen, 0);
#else
log_debug ("%s:%s: Conversion not available on non W32 systems",
SRCNAME, __func__);
-----------------------------------------------------------------------
Summary of changes:
src/cryptcontroller.cpp | 27 +++++++++++++++++++--------
src/mail.cpp | 35 +++++++++++++++++++++++++++++++----
src/mapihelp.cpp | 2 +-
src/mlang-charset.cpp | 37 ++++++++++++++++++++++---------------
src/mlang-charset.h | 3 ++-
src/mymapitags.h | 1 +
src/parsecontroller.cpp | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
src/rfc2047parse.c | 2 +-
8 files changed, 125 insertions(+), 30 deletions(-)
hooks/post-receive
--
GnuPG extension for MS Outlook
http://git.gnupg.org
More information about the Gnupg-commits
mailing list