Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Commit

Permalink
Adding decrypt support for OpenPGP/MIME RFC 3156 Thunderbird/Enigmail…
Browse files Browse the repository at this point in the history
… messages having text/plain, text/html and attachment content
  • Loading branch information
Barry de Graaff committed Feb 4, 2015
1 parent ee34f2c commit 8eb4f3c
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 12 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Bugs and feedback: https://github.com/barrydegraaff/pgp-zimlet/issues
su zimbra
cd /tmp
rm tk_barrydegraaff_zimbra_openpgp*
wget https://github.com/barrydegraaff/pgp-zimlet-binaries/raw/master/1.4.3/tk_barrydegraaff_zimbra_openpgp.zip
wget https://github.com/barrydegraaff/pgp-zimlet-binaries/raw/master/1.4.4/tk_barrydegraaff_zimbra_openpgp.zip
zmzimletctl deploy tk_barrydegraaff_zimbra_openpgp.zip
(wait 15 minutes for the deploy to propagate; or zmprov fc all)

Expand Down
2 changes: 1 addition & 1 deletion conf.mk
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION=1.4.3
VERSION=1.4.4
PACKAGE=zcs-openpgp
MAINTAINER=Barry de Graaff <[email protected]>
SECTION=free/zcs-mail
Expand Down
Binary file modified test/thunderbird-engimail-test-message.eml.tgz
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
61 changes: 52 additions & 9 deletions tk_barrydegraaff_zimbra_openpgp/tk_barrydegraaff_zimbra_openpgp.js
Original file line number Diff line number Diff line change
Expand Up @@ -603,19 +603,62 @@ function() {
{
sigStatus ='was not signed.';
}

if (decrypted.text.indexOf('<html><body>') < 0 )
{
var preOpen = '<pre>';
var preClose = '</pre>';

var preOpen = '';
var preClose = '';
var original = decrypted.text;
var msgSearch = decrypted.text.substring(0,60);
if (msgSearch.indexOf("Content-Type: multipart/mixed;") > -1 ) {
try{
var boundary = decrypted.text.match(/boundary="([^"\\]*(?:\\.[^"\\]*)*)"/i);
var multipart = decrypted.text.split(boundary[1]);
multipart.forEach(function(part) {
var partArr=part.split('\n\n', 2);
if(partArr[0].indexOf('text/plain')> 0)
{
preOpen = '<pre>'+part+'</pre>';
}
else if(partArr[0].indexOf('text/html')> 0)
{
preOpen = part;
}
else if (partArr[0].indexOf('Content-Disposition: attachment')> 0)
{
var filename = partArr[0].match(/filename="([^"\\]*(?:\\.[^"\\]*)*)"/i);
partArr[1] = partArr[1].split('=\n', 1);
partArr[1] = partArr[1] + '=';
partArr[1] = partArr[1].replace(/(\r\n|\n|\r)/gm,"");
preClose = preClose + '<br><a onclick="tk_barrydegraaff_zimbra_openpgp.prototype.downloadBlob(\''+filename[1]+'\',\'octet/stream\',\''+partArr[1]+'\')">'+filename[1]+'</a>';
}
});
if(preClose.length > 0)
{
preClose = '<br><br><hr style="border: none; height: 1px; background-color: #888888;"><b>Attachments</b>'+preClose;
}
decrypted.text='';
} catch (err) {
console.log('multipart parser failed: ' + err);
preOpen = '<pre>';
preClose = '</pre>';
decrypted.text=original;
}

}
else
{
var preOpen = '';
var preClose = '';
{
if (decrypted.text.indexOf('<html><body>') < 0 )
{
preOpen = '<pre>';
preClose = '</pre>';
}
else
{
preOpen = '';
preClose = '';
}
}
myWindow._dialog.setTitle('Decrypted message '+ sigStatus);
myWindow._dialog.setContent('<div style="width:650px; height: 350px; overflow-x: auto; overflow-y: auto; background-color:white; padding:5px;" contenteditable="true">'+ preOpen + decrypted.text + preClose +'</div><br><small><a id="original-a" onclick="document.getElementById(\'openpgp-original\').style.display = \'inline\';document.getElementById(\'original-a\').style.display = \'none\';">original</a></small><textarea id="openpgp-original" class="barrydegraaff_zimbra_openpgp-msg" style="height:40px; display:none">'+decrypted.text+'</textarea>');
myWindow._dialog.setContent('<div style="width:650px; height: 350px; overflow-x: auto; overflow-y: auto; background-color:white; padding:5px;" contenteditable="true">'+ preOpen + decrypted.text + preClose +'</div><br><small><a id="original-a" onclick="document.getElementById(\'openpgp-original\').style.display = \'inline\';document.getElementById(\'original-a\').style.display = \'none\';">original</a></small><textarea id="openpgp-original" class="barrydegraaff_zimbra_openpgp-msg" style="height:80px; display:none">'+original+'</textarea>');
},
function(err) {
tk_barrydegraaff_zimbra_openpgp.prototype.status("Decryption failed!", ZmStatusView.LEVEL_WARNING);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<zimlet name="tk_barrydegraaff_zimbra_openpgp" version="1.4.3" label="OpenPGP" description="Encrypt/Decrypt messages with OpenPGP">
<zimlet name="tk_barrydegraaff_zimbra_openpgp" version="1.4.4" label="OpenPGP" description="Encrypt/Decrypt messages with OpenPGP">
<summary>
Zimbra OpenPGP Zimlet

Expand Down

0 comments on commit 8eb4f3c

Please sign in to comment.