mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
OpenPGP - part 2 - unstable (#53)
This commit is contained in:
parent
d181974127
commit
0bb69d4494
23 changed files with 600 additions and 339 deletions
|
|
@ -6,6 +6,7 @@
|
|||
function AdminSecurity()
|
||||
{
|
||||
this.csrfProtection = ko.observable(!!RL.settingsGet('UseTokenProtection'));
|
||||
this.openPGP = ko.observable(!!RL.settingsGet('OpenPGP'));
|
||||
|
||||
this.adminLogin = ko.observable(RL.settingsGet('AdminLogin'));
|
||||
this.adminPassword = ko.observable('');
|
||||
|
|
@ -65,6 +66,12 @@ AdminSecurity.prototype.onBuild = function ()
|
|||
'TokenProtection': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.openPGP.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
||||
'OpenPGP': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AdminSecurity.prototype.onHide = function ()
|
||||
|
|
|
|||
|
|
@ -238,6 +238,7 @@ AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
|||
*/
|
||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
|
|
|
|||
|
|
@ -703,6 +703,7 @@ RainLoopApp.prototype.mailToHelper = function (sMailToUrl)
|
|||
|
||||
RainLoopApp.prototype.bootstart = function ()
|
||||
{
|
||||
RL.pub('rl.bootstart');
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
RL.data().populateDataOnStart();
|
||||
|
|
@ -785,17 +786,26 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
if (bValue)
|
||||
{
|
||||
// if (window.crypto && window.crypto.getRandomValues)
|
||||
// {
|
||||
// $.ajax({
|
||||
// 'url': RL.link().openPgpJs(),
|
||||
// 'dataType': 'script',
|
||||
// 'cache': true,
|
||||
// 'success': function () {
|
||||
// window.console.log('openPgpJs');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
if (window.crypto && window.crypto.getRandomValues && RL.settingsGet('OpenPGP'))
|
||||
{
|
||||
$.ajax({
|
||||
'url': RL.link().openPgpJs(),
|
||||
'dataType': 'script',
|
||||
'cache': true,
|
||||
'success': function () {
|
||||
if (window.openpgp)
|
||||
{
|
||||
// window.console.log(window.openpgp);
|
||||
Globals.bAllowOpenPGP = true;
|
||||
RL.pub('openpgp.init');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.bAllowOpenPGP = false;
|
||||
}
|
||||
|
||||
kn.startScreens([MailBoxScreen, SettingsScreen]);
|
||||
|
||||
|
|
@ -846,13 +856,15 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
}, 2000);
|
||||
|
||||
|
||||
Plugins.runHook('rl-start-user-screens');
|
||||
RL.pub('rl.bootstart-user-screens');
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
}
|
||||
|
||||
if (window.SimplePace)
|
||||
|
|
@ -878,6 +890,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
|
||||
if (window.SimplePace)
|
||||
{
|
||||
|
|
@ -925,6 +938,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
});
|
||||
|
||||
Plugins.runHook('rl-start-screens');
|
||||
RL.pub('rl.bootstart-end');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -65,6 +65,11 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
|||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowOpenPGP = false;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -82,11 +82,16 @@ function MessageModel()
|
|||
}, this);
|
||||
|
||||
this.body = null;
|
||||
this.plainRaw = '';
|
||||
this.isRtl = ko.observable(false);
|
||||
this.isHtml = ko.observable(false);
|
||||
this.hasImages = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
||||
this.isPgpSigned = ko.observable(false);
|
||||
this.isPgpEncrypted = ko.observable(false);
|
||||
this.pgpSignature = ko.observable('');
|
||||
|
||||
this.priority = ko.observable(Enums.MessagePriority.Normal);
|
||||
this.readReceipt = ko.observable('');
|
||||
|
||||
|
|
@ -254,6 +259,10 @@ MessageModel.prototype.clear = function ()
|
|||
this.hasImages(false);
|
||||
this.attachments([]);
|
||||
|
||||
this.isPgpSigned(false);
|
||||
this.isPgpEncrypted(false);
|
||||
this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.readReceipt('');
|
||||
this.aDraftInfo = [];
|
||||
|
|
@ -347,6 +356,13 @@ MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
|
|||
this.sInReplyTo = oJsonMessage.InReplyTo;
|
||||
this.sReferences = oJsonMessage.References;
|
||||
|
||||
if (Globals.bAllowOpenPGP)
|
||||
{
|
||||
this.isPgpSigned(!!oJsonMessage.PgpSigned);
|
||||
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);
|
||||
this.pgpSignature(oJsonMessage.PgpSignature);
|
||||
}
|
||||
|
||||
this.hasAttachments(!!oJsonMessage.HasAttachments);
|
||||
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
|
||||
|
||||
|
|
@ -808,6 +824,10 @@ MessageModel.prototype.populateByMessageListItem = function (oMessage)
|
|||
// this.hasImages(false);
|
||||
// this.attachments([]);
|
||||
|
||||
// this.isPgpSigned(false);
|
||||
// this.isPgpEncrypted(false);
|
||||
// this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.aDraftInfo = [];
|
||||
this.sMessageId = '';
|
||||
|
|
|
|||
|
|
@ -709,6 +709,10 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody = null,
|
||||
oTextBody = null,
|
||||
sId = '',
|
||||
sPlain = '',
|
||||
bPgpSigned = false,
|
||||
bPgpEncrypted = false,
|
||||
mPgpMessage = null,
|
||||
oMessagesBodiesDom = this.messagesBodiesDom(),
|
||||
oMessage = this.message()
|
||||
;
|
||||
|
|
@ -747,7 +751,57 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
|
||||
{
|
||||
bIsHtml = false;
|
||||
oBody.html(oData.Result.Plain.toString()).addClass('b-text-part plain');
|
||||
sPlain = oData.Result.Plain.toString();
|
||||
|
||||
if (Globals.bAllowOpenPGP && (oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
|
||||
Utils.isNormal(oData.Result.PlainRaw))
|
||||
{
|
||||
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw);
|
||||
if (!bPgpEncrypted)
|
||||
{
|
||||
bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oData.Result.PlainRaw) &&
|
||||
/-----BEGIN PGP SIGNATURE-----/.test(oData.Result.PlainRaw);
|
||||
}
|
||||
|
||||
if (bPgpSigned && oMessage.isPgpSigned() && oMessage.pgpSignature())
|
||||
{
|
||||
sPlain = '<pre class="b-plain-openpgp signed">' + oData.Result.PlainRaw + '</pre>';
|
||||
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.cleartext.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
if (mPgpMessage && mPgpMessage.getText)
|
||||
{
|
||||
sPlain = mPgpMessage.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
bPgpSigned = false;
|
||||
}
|
||||
}
|
||||
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
|
||||
{
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.message.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
sPlain = '<pre class="b-plain-openpgp encrypted">' + oData.Result.PlainRaw + '</pre>';
|
||||
}
|
||||
|
||||
if (bPgpSigned || bPgpEncrypted)
|
||||
{
|
||||
oBody.data('rl-plain-raw', oData.Result.PlainRaw);
|
||||
oBody.data('rl-plain-pgp-encrypted', bPgpEncrypted);
|
||||
oBody.data('rl-plain-pgp-signed', bPgpSigned);
|
||||
}
|
||||
}
|
||||
|
||||
oBody.html(sPlain).addClass('b-text-part plain');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -760,15 +814,19 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody.addClass('rtl-text-part');
|
||||
}
|
||||
|
||||
oMessagesBodiesDom.append(oBody);
|
||||
|
||||
oBody.data('rl-is-html', bIsHtml);
|
||||
oBody.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oBody.data('rl-has-images'));
|
||||
oMessage.body = oBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessagesBodiesDom.append(oMessage.body);
|
||||
|
||||
oMessage.body.data('rl-is-html', bIsHtml);
|
||||
oMessage.body.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
|
||||
if (bHasInternals)
|
||||
{
|
||||
|
|
@ -784,12 +842,26 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
}
|
||||
else
|
||||
{
|
||||
oTextBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
|
||||
oMessage.isRtl(!!oTextBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oTextBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oTextBody.data('rl-has-images'));
|
||||
oMessage.body = oTextBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
}
|
||||
|
||||
if (Globals.bAllowOpenPGP && oMessage.body)
|
||||
{
|
||||
oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed'));
|
||||
oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
oMessage.isPgpSigned(false);
|
||||
oMessage.isPgpEncrypted(false);
|
||||
}
|
||||
|
||||
this.messageActiveDom(oMessage.body);
|
||||
|
|
|
|||
|
|
@ -145,24 +145,4 @@
|
|||
color: #fff;
|
||||
}
|
||||
}
|
||||
|
||||
.editorTextArea, .editorHtmlArea {
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 14px;
|
||||
|
||||
table {
|
||||
border-collapse: separate;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -76,12 +76,15 @@
|
|||
|
||||
.box-sizing(border-box);
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
|
||||
border: 0px !important;
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
|
||||
|
|
@ -102,9 +105,11 @@
|
|||
}
|
||||
|
||||
blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
padding-left: 5px
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
|
||||
img {
|
||||
|
|
@ -119,14 +124,17 @@
|
|||
.editorTextArea {
|
||||
.box-sizing(border-box);
|
||||
|
||||
background: #fff;
|
||||
color: #000;
|
||||
|
||||
display: block;
|
||||
border: 0px !important;
|
||||
width: 100%;
|
||||
line-height: 16px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
|
|
|
|||
|
|
@ -181,7 +181,7 @@ html.rl-no-preview-pane {
|
|||
height: 0px;
|
||||
}
|
||||
|
||||
.showImages, .readReceipt {
|
||||
.showImages, .readReceipt, .pgpSigned, .pgpEncrypted {
|
||||
cursor: pointer;
|
||||
padding: 10px 15px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
|
@ -192,6 +192,10 @@ html.rl-no-preview-pane {
|
|||
background-color: #ffffd9;
|
||||
}
|
||||
|
||||
.pgpSigned, .pgpEncrypted {
|
||||
cursor: default;
|
||||
}
|
||||
|
||||
.attachmentsPlace {
|
||||
|
||||
padding: 10px;
|
||||
|
|
@ -306,14 +310,13 @@ html.rl-no-preview-pane {
|
|||
&.plain {
|
||||
|
||||
padding: 15px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
|
||||
pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: arial, sans-serif;
|
||||
background: #fff;
|
||||
border: none;
|
||||
white-space: normal;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
|
|
|
|||
|
|
@ -103,11 +103,6 @@ class Message
|
|||
*/
|
||||
private $sPlain;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $sPlainRaw;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
|
|
@ -168,6 +163,16 @@ class Message
|
|||
*/
|
||||
private $sPgpSignature;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bPgpSigned;
|
||||
|
||||
/**
|
||||
* @var bool
|
||||
*/
|
||||
private $bPgpEncrypted;
|
||||
|
||||
/**
|
||||
* @access private
|
||||
*/
|
||||
|
|
@ -201,7 +206,6 @@ class Message
|
|||
$this->oBcc = null;
|
||||
|
||||
$this->sPlain = '';
|
||||
$this->sPlainRaw = '';
|
||||
$this->sHtml = '';
|
||||
|
||||
$this->oAttachments = null;
|
||||
|
|
@ -220,6 +224,8 @@ class Message
|
|||
$this->iParentThread = 0;
|
||||
|
||||
$this->sPgpSignature = '';
|
||||
$this->bPgpSigned = false;
|
||||
$this->bPgpEncrypted = false;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
|
@ -240,14 +246,6 @@ class Message
|
|||
return $this->sPlain;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function PlainRaw()
|
||||
{
|
||||
return $this->sPlainRaw;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
|
|
@ -264,6 +262,22 @@ class Message
|
|||
return $this->sPgpSignature;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function PgpSigned()
|
||||
{
|
||||
return $this->bPgpSigned;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function PgpEncrypted()
|
||||
{
|
||||
return $this->bPgpEncrypted;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sHtml
|
||||
*
|
||||
|
|
@ -776,24 +790,20 @@ class Message
|
|||
}
|
||||
else
|
||||
{
|
||||
$this->sPlain = \implode("\n", $sPlainParts);
|
||||
$this->sPlainRaw = $this->sPlain;
|
||||
$this->sPlain = \trim(\implode("\n", $sPlainParts));
|
||||
}
|
||||
|
||||
$aMatch = array();
|
||||
if (\preg_match('/-----BEGIN PGP SIGNATURE-----(.+)-----END PGP SIGNATURE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0]))
|
||||
{
|
||||
$this->sPgpSignature = $aMatch[0];
|
||||
$this->sPlain = \trim($this->sPlain);
|
||||
$this->sPgpSignature = \trim($aMatch[0]);
|
||||
$this->bPgpSigned = true;
|
||||
}
|
||||
|
||||
$aMatch = array();
|
||||
if (!empty($this->sPgpSignature) &&
|
||||
\preg_match('/-----BEGIN PGP SIGNED MESSAGE-----(.+)-----BEGIN PGP SIGNATURE-----(.+)-----END PGP SIGNATURE-----/ism', $this->sPlain, $aMatch) &&
|
||||
!empty($aMatch[0]) && isset($aMatch[1]))
|
||||
if (\preg_match('/-----BEGIN PGP MESSAGE-----/ism', $this->sPlain, $aMatch) && !empty($aMatch[0]))
|
||||
{
|
||||
$this->sPlain = \str_replace($aMatch[0], $aMatch[1], $this->sPlain);
|
||||
$this->sPlain = \trim(\preg_replace('/^Hash: [^\s]+/i', '', \trim($this->sPlain)));
|
||||
$this->bPgpEncrypted = true;
|
||||
}
|
||||
|
||||
unset($sHtmlParts, $sPlainParts, $aMatch);
|
||||
|
|
@ -812,6 +822,7 @@ class Message
|
|||
if (\is_string($sPgpSignatureText) && 0 < \strlen($sPgpSignatureText) && 0 < \strpos($sPgpSignatureText, 'BEGIN PGP SIGNATURE'))
|
||||
{
|
||||
$this->sPgpSignature = \trim($sPgpSignatureText);
|
||||
$this->bPgpSigned = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -902,6 +902,7 @@ class Actions
|
|||
'LoginDescription' => $oConfig->Get('branding', 'login_desc', ''),
|
||||
'LoginCss' => $oConfig->Get('branding', 'login_css', ''),
|
||||
'Token' => $oConfig->Get('security', 'csrf_protection', false) ? \RainLoop\Utils::GetCsrfToken() : '',
|
||||
'OpenPGP' => $oConfig->Get('security', 'openpgp', false),
|
||||
'InIframe' => (bool) $oConfig->Get('labs', 'in_iframe', false),
|
||||
'AllowAdminPanel' => (bool) $oConfig->Get('security', 'allow_admin_panel', true),
|
||||
'CustomLoginLink' => $oConfig->Get('labs', 'custom_login_link', ''),
|
||||
|
|
@ -1955,6 +1956,7 @@ class Actions
|
|||
$this->setConfigFromParams($oConfig, 'LoginCss', 'branding', 'login_css', 'string');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'TokenProtection', 'security', 'csrf_protection', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'OpenPGP', 'security', 'openpgp', 'bool');
|
||||
$this->setConfigFromParams($oConfig, 'EnabledPlugins', 'plugins', 'enable', 'bool');
|
||||
|
||||
$this->setConfigFromParams($oConfig, 'GoogleEnable', 'social', 'google_enable', 'bool');
|
||||
|
|
@ -6320,14 +6322,13 @@ class Actions
|
|||
}
|
||||
}
|
||||
|
||||
$sPlain = $sPlainRaw = '';
|
||||
$sPlain = '';
|
||||
$sHtml = $mResponse->Html();
|
||||
$bRtl = false;
|
||||
|
||||
if (0 === \strlen($sHtml))
|
||||
{
|
||||
$sPlain = $mResponse->Plain();
|
||||
$sPlainRaw = $mResponse->PlainRaw();
|
||||
$bRtl = \MailSo\Base\Utils::IsRTL($sPlain);
|
||||
}
|
||||
else
|
||||
|
|
@ -6341,13 +6342,15 @@ class Actions
|
|||
$mResult['Html'] = 0 === \strlen($sHtml) ? '' : \MailSo\Base\HtmlUtils::ClearHtml(
|
||||
$sHtml, $bHasExternals, $mFoundedCIDs, $aContentLocationUrls, $mFoundedContentLocationUrls);
|
||||
|
||||
$mResult['PlainRaw'] = $sPlain;
|
||||
$mResult['Plain'] = 0 === \strlen($sPlain) ? '' : \MailSo\Base\HtmlUtils::ConvertPlainToHtml($sPlain);
|
||||
$mResult['PlainRaw'] = $sPlainRaw;
|
||||
$mResult['Rtl'] = $bRtl;
|
||||
|
||||
$mResult['PgpSigned'] = $mResponse->PgpSigned();
|
||||
$mResult['PgpEncrypted'] = $mResponse->PgpEncrypted();
|
||||
$mResult['PgpSignature'] = $mResponse->PgpSignature();
|
||||
|
||||
unset($sHtml, $sPlain, $sPlainRaw);
|
||||
unset($sHtml, $sPlain);
|
||||
|
||||
$mResult['HasExternals'] = $bHasExternals;
|
||||
$mResult['HasInternals'] = (\is_array($mFoundedCIDs) && 0 < \count($mFoundedCIDs)) ||
|
||||
|
|
|
|||
|
|
@ -103,6 +103,7 @@ class Application extends \RainLoop\Config\AbstractConfig
|
|||
'Enable CSRF protection (http://en.wikipedia.org/wiki/Cross-site_request_forgery)'),
|
||||
|
||||
'custom_server_signature' => array('RainLoop'),
|
||||
'openpgp' => array(false),
|
||||
'admin_login' => array('admin', 'Login and password for web admin panel'),
|
||||
'admin_password' => array('12345'),
|
||||
'allow_admin_panel' => array(true, 'Access settings'),
|
||||
|
|
|
|||
|
|
@ -12,6 +12,15 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<label data-bind="click: function () { openPGP(!openPGP()); }">
|
||||
<i data-bind="css: openPGP() ? 'icon-checkbox-checked' : 'icon-checkbox-unchecked'"></i>
|
||||
|
||||
Allow OpenPGP (beta)
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<a href="#" target="_blank" class="g-ui-link" data-bind="link: phpInfoLink()">Show PHP information</a>
|
||||
|
|
|
|||
|
|
@ -194,6 +194,16 @@
|
|||
|
||||
<span class="i18n text" data-i18n-text="MESSAGE/BUTTON_NOTIFY_READ_RECEIPT"></span>
|
||||
</div>
|
||||
<div class="pgpSigned" data-bind="visible: message() && message().isPgpSigned(), click: function() {}">
|
||||
<i class="icon-lock"></i>
|
||||
|
||||
PGP signed
|
||||
</div>
|
||||
<div class="pgpEncrypted" data-bind="visible: message() && message().isPgpEncrypted(), click: function() {}">
|
||||
<i class="icon-lock"></i>
|
||||
|
||||
PGP encrypted
|
||||
</div>
|
||||
<div class="attachmentsPlace" data-bind="visible: message() && message().hasVisibleAttachments()">
|
||||
<ul class="attachmentList" data-bind="foreach: message() ? message().attachments() : []">
|
||||
<li class="attachmentItem" draggable="true" data-bind="visible: !isLinked, title: fileName, event: { 'dragstart': eventDragStart }">
|
||||
|
|
|
|||
|
|
@ -7064,7 +7064,9 @@ showImages html.rl-no-preview-pane .messageView.message-selected {
|
|||
height: 0px;
|
||||
}
|
||||
.messageView .b-content .messageItem .showImages,
|
||||
.messageView .b-content .messageItem .readReceipt {
|
||||
.messageView .b-content .messageItem .readReceipt,
|
||||
.messageView .b-content .messageItem .pgpSigned,
|
||||
.messageView .b-content .messageItem .pgpEncrypted {
|
||||
cursor: pointer;
|
||||
padding: 10px 15px;
|
||||
border-bottom: 1px solid #ddd;
|
||||
|
|
@ -7073,6 +7075,10 @@ showImages html.rl-no-preview-pane .messageView.message-selected {
|
|||
.messageView .b-content .messageItem .readReceipt {
|
||||
background-color: #ffffd9;
|
||||
}
|
||||
.messageView .b-content .messageItem .pgpSigned,
|
||||
.messageView .b-content .messageItem .pgpEncrypted {
|
||||
cursor: default;
|
||||
}
|
||||
.messageView .b-content .messageItem .attachmentsPlace {
|
||||
padding: 10px;
|
||||
}
|
||||
|
|
@ -7165,14 +7171,13 @@ showImages html.rl-no-preview-pane .messageView.message-selected {
|
|||
}
|
||||
.messageView .b-content .messageItem .bodyText .b-text-part.plain {
|
||||
padding: 15px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
}
|
||||
.messageView .b-content .messageItem .bodyText .b-text-part.plain pre {
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
font-family: arial, sans-serif;
|
||||
background: #fff;
|
||||
border: none;
|
||||
white-space: normal;
|
||||
}
|
||||
.messageView .b-content .messageItem .bodyText .b-text-part.plain blockquote {
|
||||
border-left: 2px solid blue;
|
||||
|
|
@ -7686,25 +7691,6 @@ html.rl-message-fullscreen .messageView .b-content .buttonFull {
|
|||
background: #777;
|
||||
color: #fff;
|
||||
}
|
||||
.b-compose .editorTextArea,
|
||||
.b-compose .editorHtmlArea {
|
||||
background: #fff;
|
||||
color: #000;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 14px;
|
||||
}
|
||||
.b-compose .editorTextArea table,
|
||||
.b-compose .editorHtmlArea table {
|
||||
border-collapse: separate;
|
||||
}
|
||||
.b-compose .editorTextArea blockquote,
|
||||
.b-compose .editorHtmlArea blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.b-admin-left .b-toolbar {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
|
|
@ -8650,12 +8636,14 @@ html.rl-started-trigger.no-mobile #rl-content {
|
|||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
border: 0px !important;
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
line-height: 16px;
|
||||
font-family: Arial, Verdana, Geneva, sans-serif;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
}
|
||||
|
|
@ -8672,8 +8660,10 @@ html.rl-started-trigger.no-mobile #rl-content {
|
|||
list-style-type: decimal !important;
|
||||
}
|
||||
.textAreaParent .editorHtmlArea blockquote {
|
||||
border: 0;
|
||||
border-left: solid 2px #444;
|
||||
margin-left: 5px;
|
||||
margin: 5px 0;
|
||||
padding-left: 5px;
|
||||
}
|
||||
.textAreaParent .editorHtmlArea img {
|
||||
|
|
@ -8686,14 +8676,16 @@ html.rl-started-trigger.no-mobile #rl-content {
|
|||
-webkit-box-sizing: border-box;
|
||||
-moz-box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
background: #fff;
|
||||
color: #000;
|
||||
display: block;
|
||||
border: 0px !important;
|
||||
width: 100%;
|
||||
line-height: 16px;
|
||||
margin: 0px;
|
||||
padding: 8px;
|
||||
font-family: arial, sans-serif;
|
||||
font-size: 14px;
|
||||
font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
|
||||
font-size: 13px;
|
||||
line-height: 15px;
|
||||
overflow: auto;
|
||||
overflow-y: scroll;
|
||||
}
|
||||
|
|
|
|||
2
rainloop/v/0.0.0/static/css/app.min.css
vendored
2
rainloop/v/0.0.0/static/css/app.min.css
vendored
File diff suppressed because one or more lines are too long
|
|
@ -143,6 +143,11 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
|||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowOpenPGP = false;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
|
@ -5774,6 +5779,7 @@ AdminDomains.prototype.onDomainListChangeRequest = function ()
|
|||
function AdminSecurity()
|
||||
{
|
||||
this.csrfProtection = ko.observable(!!RL.settingsGet('UseTokenProtection'));
|
||||
this.openPGP = ko.observable(!!RL.settingsGet('OpenPGP'));
|
||||
|
||||
this.adminLogin = ko.observable(RL.settingsGet('AdminLogin'));
|
||||
this.adminPassword = ko.observable('');
|
||||
|
|
@ -5833,6 +5839,12 @@ AdminSecurity.prototype.onBuild = function ()
|
|||
'TokenProtection': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
|
||||
this.openPGP.subscribe(function (bValue) {
|
||||
RL.remote().saveAdminConfig(Utils.emptyFunction, {
|
||||
'OpenPGP': bValue ? '1' : '0'
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
AdminSecurity.prototype.onHide = function ()
|
||||
|
|
@ -7365,6 +7377,7 @@ AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
|||
*/
|
||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
|
|
|
|||
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
4
rainloop/v/0.0.0/static/js/admin.min.js
vendored
File diff suppressed because one or more lines are too long
|
|
@ -143,6 +143,11 @@ Globals.bDisableNanoScroll = Globals.bMobileDevice;
|
|||
*/
|
||||
Globals.bAllowPdfPreview = !Globals.bMobileDevice;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
Globals.bAllowOpenPGP = false;
|
||||
|
||||
/**
|
||||
* @type {boolean}
|
||||
*/
|
||||
|
|
@ -6402,11 +6407,16 @@ function MessageModel()
|
|||
}, this);
|
||||
|
||||
this.body = null;
|
||||
this.plainRaw = '';
|
||||
this.isRtl = ko.observable(false);
|
||||
this.isHtml = ko.observable(false);
|
||||
this.hasImages = ko.observable(false);
|
||||
this.attachments = ko.observableArray([]);
|
||||
|
||||
this.isPgpSigned = ko.observable(false);
|
||||
this.isPgpEncrypted = ko.observable(false);
|
||||
this.pgpSignature = ko.observable('');
|
||||
|
||||
this.priority = ko.observable(Enums.MessagePriority.Normal);
|
||||
this.readReceipt = ko.observable('');
|
||||
|
||||
|
|
@ -6574,6 +6584,10 @@ MessageModel.prototype.clear = function ()
|
|||
this.hasImages(false);
|
||||
this.attachments([]);
|
||||
|
||||
this.isPgpSigned(false);
|
||||
this.isPgpEncrypted(false);
|
||||
this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.readReceipt('');
|
||||
this.aDraftInfo = [];
|
||||
|
|
@ -6667,6 +6681,13 @@ MessageModel.prototype.initUpdateByMessageJson = function (oJsonMessage)
|
|||
this.sInReplyTo = oJsonMessage.InReplyTo;
|
||||
this.sReferences = oJsonMessage.References;
|
||||
|
||||
if (Globals.bAllowOpenPGP)
|
||||
{
|
||||
this.isPgpSigned(!!oJsonMessage.PgpSigned);
|
||||
this.isPgpEncrypted(!!oJsonMessage.PgpEncrypted);
|
||||
this.pgpSignature(oJsonMessage.PgpSignature);
|
||||
}
|
||||
|
||||
this.hasAttachments(!!oJsonMessage.HasAttachments);
|
||||
this.attachmentsMainType(oJsonMessage.AttachmentsMainType);
|
||||
|
||||
|
|
@ -7128,6 +7149,10 @@ MessageModel.prototype.populateByMessageListItem = function (oMessage)
|
|||
// this.hasImages(false);
|
||||
// this.attachments([]);
|
||||
|
||||
// this.isPgpSigned(false);
|
||||
// this.isPgpEncrypted(false);
|
||||
// this.pgpSignature('');
|
||||
|
||||
this.priority(Enums.MessagePriority.Normal);
|
||||
this.aDraftInfo = [];
|
||||
this.sMessageId = '';
|
||||
|
|
@ -14292,6 +14317,10 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody = null,
|
||||
oTextBody = null,
|
||||
sId = '',
|
||||
sPlain = '',
|
||||
bPgpSigned = false,
|
||||
bPgpEncrypted = false,
|
||||
mPgpMessage = null,
|
||||
oMessagesBodiesDom = this.messagesBodiesDom(),
|
||||
oMessage = this.message()
|
||||
;
|
||||
|
|
@ -14330,7 +14359,57 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
|
||||
{
|
||||
bIsHtml = false;
|
||||
oBody.html(oData.Result.Plain.toString()).addClass('b-text-part plain');
|
||||
sPlain = oData.Result.Plain.toString();
|
||||
|
||||
if (Globals.bAllowOpenPGP && (oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) &&
|
||||
Utils.isNormal(oData.Result.PlainRaw))
|
||||
{
|
||||
bPgpEncrypted = /---BEGIN PGP MESSAGE---/.test(oData.Result.PlainRaw);
|
||||
if (!bPgpEncrypted)
|
||||
{
|
||||
bPgpSigned = /-----BEGIN PGP SIGNED MESSAGE-----/.test(oData.Result.PlainRaw) &&
|
||||
/-----BEGIN PGP SIGNATURE-----/.test(oData.Result.PlainRaw);
|
||||
}
|
||||
|
||||
if (bPgpSigned && oMessage.isPgpSigned() && oMessage.pgpSignature())
|
||||
{
|
||||
sPlain = '<pre class="b-plain-openpgp signed">' + oData.Result.PlainRaw + '</pre>';
|
||||
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.cleartext.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
if (mPgpMessage && mPgpMessage.getText)
|
||||
{
|
||||
sPlain = mPgpMessage.getText();
|
||||
}
|
||||
else
|
||||
{
|
||||
bPgpSigned = false;
|
||||
}
|
||||
}
|
||||
else if (bPgpEncrypted && oMessage.isPgpEncrypted())
|
||||
{
|
||||
try
|
||||
{
|
||||
mPgpMessage = window.openpgp.message.readArmored(oData.Result.PlainRaw);
|
||||
}
|
||||
catch (oExc) {}
|
||||
|
||||
sPlain = '<pre class="b-plain-openpgp encrypted">' + oData.Result.PlainRaw + '</pre>';
|
||||
}
|
||||
|
||||
if (bPgpSigned || bPgpEncrypted)
|
||||
{
|
||||
oBody.data('rl-plain-raw', oData.Result.PlainRaw);
|
||||
oBody.data('rl-plain-pgp-encrypted', bPgpEncrypted);
|
||||
oBody.data('rl-plain-pgp-signed', bPgpSigned);
|
||||
}
|
||||
}
|
||||
|
||||
oBody.html(sPlain).addClass('b-text-part plain');
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -14343,15 +14422,19 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
oBody.addClass('rtl-text-part');
|
||||
}
|
||||
|
||||
oMessagesBodiesDom.append(oBody);
|
||||
|
||||
oBody.data('rl-is-html', bIsHtml);
|
||||
oBody.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oBody.data('rl-has-images'));
|
||||
oMessage.body = oBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessagesBodiesDom.append(oMessage.body);
|
||||
|
||||
oMessage.body.data('rl-is-html', bIsHtml);
|
||||
oMessage.body.data('rl-has-images', bHasExternals);
|
||||
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
|
||||
if (bHasInternals)
|
||||
{
|
||||
|
|
@ -14367,12 +14450,26 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
|
|||
}
|
||||
else
|
||||
{
|
||||
oTextBody.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
|
||||
oMessage.isRtl(!!oTextBody.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oTextBody.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oTextBody.data('rl-has-images'));
|
||||
oMessage.body = oTextBody;
|
||||
if (oMessage.body)
|
||||
{
|
||||
oMessage.body.data('rl-cache-count', ++Globals.iMessageBodyCacheCount);
|
||||
oMessage.isRtl(!!oMessage.body.data('rl-is-rtl'));
|
||||
oMessage.isHtml(!!oMessage.body.data('rl-is-html'));
|
||||
oMessage.hasImages(!!oMessage.body.data('rl-has-images'));
|
||||
oMessage.plainRaw = Utils.pString(oMessage.body.data('rl-plain-raw'));
|
||||
}
|
||||
}
|
||||
|
||||
if (Globals.bAllowOpenPGP && oMessage.body)
|
||||
{
|
||||
oMessage.isPgpSigned(!!oMessage.body.data('rl-plain-pgp-signed'));
|
||||
oMessage.isPgpEncrypted(!!oMessage.body.data('rl-plain-pgp-encrypted'));
|
||||
}
|
||||
else
|
||||
{
|
||||
oMessage.isPgpSigned(false);
|
||||
oMessage.isPgpEncrypted(false);
|
||||
}
|
||||
|
||||
this.messageActiveDom(oMessage.body);
|
||||
|
|
@ -16514,6 +16611,7 @@ AbstractApp.prototype.sub = function (sName, fFunc, oContext)
|
|||
*/
|
||||
AbstractApp.prototype.pub = function (sName, aArgs)
|
||||
{
|
||||
Plugins.runHook('rl-pub', [sName, aArgs]);
|
||||
if (!Utils.isUnd(this.oSubs[sName]))
|
||||
{
|
||||
_.each(this.oSubs[sName], function (aItem) {
|
||||
|
|
@ -17289,6 +17387,7 @@ RainLoopApp.prototype.mailToHelper = function (sMailToUrl)
|
|||
|
||||
RainLoopApp.prototype.bootstart = function ()
|
||||
{
|
||||
RL.pub('rl.bootstart');
|
||||
AbstractApp.prototype.bootstart.call(this);
|
||||
|
||||
RL.data().populateDataOnStart();
|
||||
|
|
@ -17371,17 +17470,26 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
if (bValue)
|
||||
{
|
||||
// if (window.crypto && window.crypto.getRandomValues)
|
||||
// {
|
||||
// $.ajax({
|
||||
// 'url': RL.link().openPgpJs(),
|
||||
// 'dataType': 'script',
|
||||
// 'cache': true,
|
||||
// 'success': function () {
|
||||
// window.console.log('openPgpJs');
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
if (window.crypto && window.crypto.getRandomValues && RL.settingsGet('OpenPGP'))
|
||||
{
|
||||
$.ajax({
|
||||
'url': RL.link().openPgpJs(),
|
||||
'dataType': 'script',
|
||||
'cache': true,
|
||||
'success': function () {
|
||||
if (window.openpgp)
|
||||
{
|
||||
// window.console.log(window.openpgp);
|
||||
Globals.bAllowOpenPGP = true;
|
||||
RL.pub('openpgp.init');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Globals.bAllowOpenPGP = false;
|
||||
}
|
||||
|
||||
kn.startScreens([MailBoxScreen, SettingsScreen]);
|
||||
|
||||
|
|
@ -17432,13 +17540,15 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
|
||||
}, 2000);
|
||||
|
||||
|
||||
Plugins.runHook('rl-start-user-screens');
|
||||
RL.pub('rl.bootstart-user-screens');
|
||||
}
|
||||
else
|
||||
{
|
||||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
}
|
||||
|
||||
if (window.SimplePace)
|
||||
|
|
@ -17464,6 +17574,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
kn.startScreens([LoginScreen]);
|
||||
|
||||
Plugins.runHook('rl-start-login-screens');
|
||||
RL.pub('rl.bootstart-login-screens');
|
||||
|
||||
if (window.SimplePace)
|
||||
{
|
||||
|
|
@ -17511,6 +17622,7 @@ RainLoopApp.prototype.bootstart = function ()
|
|||
});
|
||||
|
||||
Plugins.runHook('rl-start-screens');
|
||||
RL.pub('rl.bootstart-end');
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
|||
16
rainloop/v/0.0.0/static/js/app.min.js
vendored
16
rainloop/v/0.0.0/static/js/app.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue