Page MenuHome GnuPG

GpgOL: Wrong plaintext body part when saved / sent from drafts
Closed, ResolvedPublic

Description

Reported in T3419:

You write a message with Outlook 2016 on Exchange Server and GpgOL 2.0.4-beta15, the body contains eg. "I don't like you!!". You close composing this mail, it'll be in the "Draft"-Folder
You continue writing your mail from "Draft" and change the body to "I like you!"
You encrypt(/sign&encrypt) your mail with the the body to "I like you!"
You send this mail, in your "Sent Items"-Folder you'll find your encrypted(/signed&encrypted) mail with the body to "I like you!"
The recipient on Outlook 2016/Exchange Server with GPG4Win 2.3.2 & GPGol 1.4.0 will receive your encrypted(/signed&encrypted) mail, but the mail body will contain "I don't like you!!"

I can reproduce this even without Exchange. Inspection of the sent mail shows that the problem is the multipart/alternative plaintext vs. html.

The HTML Part contains the correct body -> GpgOL 2.x / Gpg4win 3.x will show the HTML part if it is not explicitly configured in outlook to prefer plaintext
The text/plain part contains the wrong body -> GpgOL 2.x will show that part.

The mime structure looks like:

MIME-Version: 1.0
Content-Type: multipart/signed;
        protocol="application/pgp-signature";
        micalg=pgp-sha1       ;
        boundary="=-=+vE40ul+jXH+wK=-="


--=-=+vE40ul+jXH+wK=-=
Content-Type: multipart/alternative;
        boundary="=-=c1wa7mr/OtfLrP=-="


--=-=c1wa7mr/OtfLrP=-=
Content-Type: text/plain;
        charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hello wrong body

--=-=c1wa7mr/OtfLrP=-=
Content-Type: text/html;
        charset="utf-8"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40"><head><meta name=3DGenerator content=3D"Microso=
ft Word 15 (filtered medium)"><style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0cm;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0cm;
        mso-margin-bottom-alt:auto;
        margin-left:0cm;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.E-MailFormatvorlage18
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;
        mso-fareast-language:EN-US;}
@page WordSection1
        {size:612.0pt 792.0pt;
        margin:72.0pt 72.0pt 72.0pt 72.0pt;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]--></head><body lang=3DDE link=3D"#0563C1" v=
link=3D"#954F72"><div class=3DWordSection1><p class=3DMsoNormal>Hello right=
 body<o:p></o:p></p></div></body></html>

--=-=c1wa7mr/OtfLrP=-=--

--=-=+vE40ul+jXH+wK=-=
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----

iQEzBAABCAAdFiEE60xaW3rWyFJ/BQuvHtTwvGz7yRIFAlovdRUACgkQHtTwvGz7
yRIoFgf/ZL7Sc/XlTyVtv+k9qybyWdzThQDl/HFky+lJaOCV23CO3Ke34WnapYIY
6KSBb1S05t7XyFkelhTYKkYWjaFcfE0+6+L5e/yT2i0k6J+XBP1Ei8eWqMwjJuKs
W0rFGyXOLBBwGrj/4/I86veS1cW5VBfUVmBlaoWosXugERAi3isKth1jaQO9D7X9
i32d+hjXJ6KntbJOD4clGtJ0L1n5w9SKsldfRQLxvdKkgqRWnEeZhUGlMt1YgUga
JCpFQ4Du1JuMRQegS1gZC/HBcDLuvoBH6B/zO797IHxMQiH1LbDjqfeqp/nmEHdN
94jsBonuc0MVRNvFewGcp6YB0K8hMw==
=5m/0
-----END PGP SIGNATURE-----


--=-=+vE40ul+jXH+wK=-=--

Details

Version
2.0.5

Event Timeline

Wow, fast reaction! I'm happy to help evaluate a possible fix for this.

If I send "Nur Text" (plaintext only) under formatting it works as expected. We query Outlook for the Body from the MAPI Data model and just get the wrong value returned. For the HTML part we use the Outlook Object Model (as we had a similar problem there that the MAPI data was not updated properly.)
The fix is obvious. We can use similar code to our handling of the HTML body. This is a workaround for an Outlook bug IMO, why should sending from drafts differ from the usual sending *sigh*

aheinecke changed the task status from Open to Testing.Dec 12 2017, 8:45 AM

In my tests it's fixed with: b8276a4f3acecee2e467c0530007aedc9db5936a the plain text body now uses similar code to the html part. Makes sense anyway. The difference was mostly historic as GpgOL before 2.0 did not handle HTML parts at all.

I've uploaded a Version with that revision (2.0.6-beta4)
https://files.gpg4win.org/Beta/gpgol/

Please confirm that this works for you, too. There is a slight regression risk in that the changed body lookup might have unintended side effects.

Now I wonder if this warrants a bugfix release before 3.1.0,.. :-/

I can confirm that it works for me, too: Fantastic, thanks!

Best,
Carsten

PS: And I can confirm that I have a lot of HTML Garbage in my mail body (on the receiver plain text side):

<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40"><head><meta name=ProgId content=Word.Document><meta name=Generator content="Microsoft Word 15"><meta name=Originator content="Microsoft Word 15"><link rel=File-List href="cid:filelist.xml@01D3732B.90BA6900"><!--[if gte mso 9]><xml>

...continuing...

The HTML in the body below the text on the GpgOL-1.4 side is a known issue of GpgOL-1.x we only added proper HTML handling with GpgOL 2.
GpgOL before 2.0 just appended the text/html mime part to the text/plain mimepart in multipart/alternative mails.

Just to be clear, This should have always been the case with 1.4, are you only seeing this now?

Correct, this was also the case before, sorry for the misunderstanding.

The fix was released with Gpg4win-3.0.3