Small fixes

This commit is contained in:
RainLoop Team 2014-07-31 19:13:32 +04:00
parent 9ac4d3ac14
commit 3b29e93db1
7 changed files with 117 additions and 279 deletions

View file

@ -1666,13 +1666,12 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br\s?\/?>/gmi, '\n')
.replace(/<\/h\d>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')
.replace(/<\/td>/gi, '\n') .replace(/<\/td>/gi, '\n')
.replace(/<\/tr>/gi, '\n') .replace(/<\/tr>/gi, '\n')
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n') .replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
.replace(/<img [^>]*>/gmi, '')
.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) .replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n') .replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n') .replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
@ -1680,7 +1679,6 @@ Utils.htmlToPlain = function (sHtml)
.replace(/<\/div>/gi, '\n') .replace(/<\/div>/gi, '\n')
.replace(/&nbsp;/gi, ' ') .replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"') .replace(/&quot;/gi, '"')
.replace(/&amp;/gi, '&')
.replace(/<[^>]*>/gm, '') .replace(/<[^>]*>/gm, '')
; ;
@ -1691,6 +1689,7 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\n]{3,}/gm, '\n\n') .replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>') .replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<') .replace(/&lt;/gi, '<')
.replace(/&amp;/gi, '&')
; ;
iPos = 0; iPos = 0;
@ -1738,9 +1737,10 @@ Utils.htmlToPlain = function (sHtml)
/** /**
* @param {string} sPlain * @param {string} sPlain
* @param {boolean} bLinkify = false
* @return {string} * @return {string}
*/ */
Utils.plainToHtml = function (sPlain) Utils.plainToHtml = function (sPlain, bLinkify)
{ {
sPlain = sPlain.toString().replace(/\r/g, ''); sPlain = sPlain.toString().replace(/\r/g, '');
@ -1805,14 +1805,29 @@ Utils.plainToHtml = function (sPlain)
.replace(/[\-_~]{10,}/g, '<hr />') .replace(/[\-_~]{10,}/g, '<hr />')
.replace(/\n/g, '<br />'); .replace(/\n/g, '<br />');
return bLinkify ? Utils.linkify(sPlain) : sPlain;
};
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
window.rainloop_Utils_plainToHtml = Utils.plainToHtml;
/**
* @param {string} sHtml
* @return {string}
*/
Utils.linkify = function (sHtml)
{
if ($.fn && $.fn.linkify) if ($.fn && $.fn.linkify)
{ {
sPlain = Utils.$div.html(sPlain) sHtml = Utils.$div.html(sHtml.replace(/&amp;/ig, 'amp_amp_12345_amp_amp'))
.linkify().find('.linkified').removeClass('linkified').end() .linkify()
.html(); .find('.linkified').removeClass('linkified').end()
.html()
.replace(/amp_amp_12345_amp_amp/g, '&amp;')
;
} }
return sPlain; return sHtml;
}; };
Utils.resizeAndCrop = function (sUrl, iValue, fCallback) Utils.resizeAndCrop = function (sUrl, iValue, fCallback)

View file

@ -893,7 +893,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
oBody = null, oBody = null,
oTextBody = null, oTextBody = null,
sId = '', sId = '',
sPlainAsHtml = '', sResultHtml = '',
bPgpSigned = false, bPgpSigned = false,
bPgpEncrypted = false, bPgpEncrypted = false,
oMessagesBodiesDom = this.messagesBodiesDom(), oMessagesBodiesDom = this.messagesBodiesDom(),
@ -929,16 +929,12 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
{ {
bIsHtml = true; bIsHtml = true;
oBody sResultHtml = oData.Result.Html.toString();
.html(oData.Result.Html.toString())
.linkify().find('.linkified').removeClass('linkified').end()
.addClass('b-text-part html')
;
} }
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain) else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
{ {
bIsHtml = false; bIsHtml = false;
sPlainAsHtml = Utils.plainToHtml(oData.Result.Plain.toString()); sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false);
if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().capaOpenPGP()) if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().capaOpenPGP())
{ {
@ -954,7 +950,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
$proxyDiv.empty(); $proxyDiv.empty();
if (bPgpSigned && oMessage.isPgpSigned()) if (bPgpSigned && oMessage.isPgpSigned())
{ {
sPlainAsHtml = sResultHtml =
$proxyDiv.append( $proxyDiv.append(
$('<pre class="b-plain-openpgp signed"></pre>').text(oMessage.plainRaw) $('<pre class="b-plain-openpgp signed"></pre>').text(oMessage.plainRaw)
).html() ).html()
@ -962,7 +958,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
} }
else if (bPgpEncrypted && oMessage.isPgpEncrypted()) else if (bPgpEncrypted && oMessage.isPgpEncrypted())
{ {
sPlainAsHtml = sResultHtml =
$proxyDiv.append( $proxyDiv.append(
$('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw) $('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw)
).html() ).html()
@ -974,18 +970,17 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
oMessage.isPgpSigned(bPgpSigned); oMessage.isPgpSigned(bPgpSigned);
oMessage.isPgpEncrypted(bPgpEncrypted); oMessage.isPgpEncrypted(bPgpEncrypted);
} }
oBody
.html(sPlainAsHtml)
.linkify().find('.linkified').removeClass('linkified').end()
.addClass('b-text-part plain')
;
} }
else else
{ {
bIsHtml = false; bIsHtml = false;
} }
oBody
.html(Utils.linkify(sResultHtml))
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
;
oMessage.isHtml(!!bIsHtml); oMessage.isHtml(!!bIsHtml);
oMessage.hasImages(!!bHasExternals); oMessage.hasImages(!!bHasExternals);
oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None); oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);

View file

@ -2,243 +2,44 @@
(function() { (function() {
var var
simplePlainToHtml = function (sPlain) {
$div = $('<div></div>'), return sPlain
.replace(/&/g, '&amp;')
/** .replace(/>/g, '&gt;').replace(/</g, '&lt;')
* @param {string} sHtml .replace(/[\-_~]{10,}/g, '<hr />')
* @return {string} .replace(/\n/g, '<br />')
*/
htmlToPlain = function (sHtml)
{
var
iPos = 0,
iP1 = 0,
iP2 = 0,
iP3 = 0,
iLimit = 0,
sText = '',
splitPlainText = function (sText)
{
var
iLen = 100,
sPrefix = '',
sSubText = '',
sResult = sText,
iSpacePos = 0,
iNewLinePos = 0
;
while (sResult.length > iLen)
{
sSubText = sResult.substring(0, iLen);
iSpacePos = sSubText.lastIndexOf(' ');
iNewLinePos = sSubText.lastIndexOf('\n');
if (-1 !== iNewLinePos)
{
iSpacePos = iNewLinePos;
}
if (-1 === iSpacePos)
{
iSpacePos = iLen;
}
sPrefix += sSubText.substring(0, iSpacePos) + '\n';
sResult = sResult.substring(iSpacePos + 1);
}
return sPrefix + sResult;
},
convertBlockquote = function (sText) {
sText = splitPlainText($.trim(sText));
sText = '> ' + sText.replace(/\n/gm, '\n> ');
return sText.replace(/(^|\n)([> ]+)/gm, function () {
return (arguments && 2 < arguments.length) ? arguments[1] + $.trim(arguments[2].replace(/[\s]/, '')) + ' ' : '';
});
},
convertDivs = function () {
if (arguments && 1 < arguments.length)
{
var sText = $.trim(arguments[1]);
if (0 < sText.length)
{
sText = sText.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs);
sText = '\n' + $.trim(sText) + '\n';
}
return sText;
}
return '';
},
fixAttibuteValue = function () {
return (arguments && 1 < arguments.length) ?
'' + arguments[1] + arguments[2].replace(/</g, '&lt;').replace(/>/g, '&gt;') : '';
},
convertLinks = function () {
return (arguments && 1 < arguments.length) ? $.trim(arguments[1]) : '';
}
; ;
},
sText = sHtml simpleHtmlToPlain = function (sHtml) {
var sText = sHtml
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br\s?\/?>/gmi, '\n')
.replace(/<\/h\d>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')
.replace(/<\/td>/gi, '\n') .replace(/<\/td>/gi, '\n')
.replace(/<\/tr>/gi, '\n') .replace(/<\/tr>/gi, '\n')
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
.replace(/<img [^>]*>/gmi, '')
.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
.replace(/<a [^>]*>([\s\S\r\n]*?)<\/a>/gmi, convertLinks)
.replace(/<\/div>/gi, '\n') .replace(/<\/div>/gi, '\n')
.replace(/<blockquote[^>]*>/gmi, '\n')
.replace(/<\/blockquote>/gi, '\n')
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
.replace(/&nbsp;/gi, ' ') .replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"') .replace(/&quot;/gi, '"')
.replace(/&amp;/gi, '&')
.replace(/<[^>]*>/gm, '') .replace(/<[^>]*>/gm, '')
; ;
sText = $div.html(sText).text(); sText = $('<div></div>').html(sText).text();
sText = sText sText = sText
.replace(/\n[ \t]+/gm, '\n') .replace(/\n[ \t]+/gm, '\n')
.replace(/[\n]{3,}/gm, '\n\n') .replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>') .replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<') .replace(/&lt;/gi, '<')
; .replace(/&amp;/gi, '&')
iPos = 0;
iLimit = 100;
while (0 < iLimit)
{
iLimit--;
iP1 = sText.indexOf('__bq__start__', iPos);
if (-1 < iP1)
{
iP2 = sText.indexOf('__bq__start__', iP1 + 5);
iP3 = sText.indexOf('__bq__end__', iP1 + 5);
if ((-1 === iP2 || iP3 < iP2) && iP1 < iP3)
{
sText = sText.substring(0, iP1) +
convertBlockquote(sText.substring(iP1 + 13, iP3)) +
sText.substring(iP3 + 11);
iPos = 0;
}
else if (-1 < iP2 && iP2 < iP3)
{
iPos = iP2 - 1;
}
else
{
iPos = 0;
}
}
else
{
break;
}
}
sText = sText
.replace(/__bq__start__/gm, '')
.replace(/__bq__end__/gm, '')
; ;
return sText; return sText;
},
/**
* @param {string} sPlain
* @return {string}
*/
plainToHtml = function (sPlain)
{
sPlain = sPlain.toString().replace(/\r/g, '');
var
bIn = false,
bDo = true,
bStart = true,
aNextText = [],
sLine = '',
iIndex = 0,
aText = sPlain.split("\n")
;
do
{
bDo = false;
aNextText = [];
for (iIndex = 0; iIndex < aText.length; iIndex++)
{
sLine = aText[iIndex];
bStart = '>' === sLine.substr(0, 1);
if (bStart && !bIn)
{
bDo = true;
bIn = true;
aNextText.push('~~~blockquote~~~');
aNextText.push(sLine.substr(1));
}
else if (!bStart && bIn)
{
bIn = false;
aNextText.push('~~~/blockquote~~~');
aNextText.push(sLine);
}
else if (bStart && bIn)
{
aNextText.push(sLine.substr(1));
}
else
{
aNextText.push(sLine);
}
}
if (bIn)
{
bIn = false;
aNextText.push('~~~/blockquote~~~');
}
aText = aNextText;
}
while (bDo);
sPlain = aText.join("\n");
sPlain = sPlain
.replace(/&/g, '&amp;')
.replace(/>/g, '&gt;').replace(/</g, '&lt;')
.replace(/~~~blockquote~~~[\s]*/g, '<blockquote>')
.replace(/[\s]*~~~\/blockquote~~~/g, '</blockquote>')
.replace(/[\-_~]{10,}/g, '<hr />')
.replace(/\n/g, '<br />');
if ($.fn && $.fn.linkify)
{
sPlain = $div.html(sPlain)
.linkify().find('.linkified').removeClass('linkified').end()
.html();
}
return sPlain;
} }
; ;
@ -322,7 +123,9 @@
base: CKEDITOR.editable, base: CKEDITOR.editable,
proto: { proto: {
setData: function(data) { setData: function(data) {
this.setValue(htmlToPlain(data)); this.setValue(window.rainloop_Utils_htmlToPlain ?
window.rainloop_Utils_htmlToPlain(data) : simpleHtmlToPlain(data));
this.editor.fire('dataReady'); this.editor.fire('dataReady');
}, },
setRawData: function(data) { setRawData: function(data) {
@ -330,7 +133,8 @@
this.editor.fire('dataReady'); this.editor.fire('dataReady');
}, },
getData: function() { getData: function() {
return plainToHtml(this.getValue()); return window.rainloop_Utils_plainToHtml ?
window.rainloop_Utils_plainToHtml(this.getValue(), true) : simplePlainToHtml(this.getValue());
}, },
getRawData: function() { getRawData: function() {
return this.getValue(); return this.getValue();

View file

@ -2468,13 +2468,12 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br\s?\/?>/gmi, '\n')
.replace(/<\/h\d>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')
.replace(/<\/td>/gi, '\n') .replace(/<\/td>/gi, '\n')
.replace(/<\/tr>/gi, '\n') .replace(/<\/tr>/gi, '\n')
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n') .replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
.replace(/<img [^>]*>/gmi, '')
.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) .replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n') .replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n') .replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
@ -2482,7 +2481,6 @@ Utils.htmlToPlain = function (sHtml)
.replace(/<\/div>/gi, '\n') .replace(/<\/div>/gi, '\n')
.replace(/&nbsp;/gi, ' ') .replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"') .replace(/&quot;/gi, '"')
.replace(/&amp;/gi, '&')
.replace(/<[^>]*>/gm, '') .replace(/<[^>]*>/gm, '')
; ;
@ -2493,6 +2491,7 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\n]{3,}/gm, '\n\n') .replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>') .replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<') .replace(/&lt;/gi, '<')
.replace(/&amp;/gi, '&')
; ;
iPos = 0; iPos = 0;
@ -2540,9 +2539,10 @@ Utils.htmlToPlain = function (sHtml)
/** /**
* @param {string} sPlain * @param {string} sPlain
* @param {boolean} bLinkify = false
* @return {string} * @return {string}
*/ */
Utils.plainToHtml = function (sPlain) Utils.plainToHtml = function (sPlain, bLinkify)
{ {
sPlain = sPlain.toString().replace(/\r/g, ''); sPlain = sPlain.toString().replace(/\r/g, '');
@ -2607,14 +2607,29 @@ Utils.plainToHtml = function (sPlain)
.replace(/[\-_~]{10,}/g, '<hr />') .replace(/[\-_~]{10,}/g, '<hr />')
.replace(/\n/g, '<br />'); .replace(/\n/g, '<br />');
return bLinkify ? Utils.linkify(sPlain) : sPlain;
};
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
window.rainloop_Utils_plainToHtml = Utils.plainToHtml;
/**
* @param {string} sHtml
* @return {string}
*/
Utils.linkify = function (sHtml)
{
if ($.fn && $.fn.linkify) if ($.fn && $.fn.linkify)
{ {
sPlain = Utils.$div.html(sPlain) sHtml = Utils.$div.html(sHtml.replace(/&amp;/ig, 'amp_amp_12345_amp_amp'))
.linkify().find('.linkified').removeClass('linkified').end() .linkify()
.html(); .find('.linkified').removeClass('linkified').end()
.html()
.replace(/amp_amp_12345_amp_amp/g, '&amp;')
;
} }
return sPlain; return sHtml;
}; };
Utils.resizeAndCrop = function (sUrl, iValue, fCallback) Utils.resizeAndCrop = function (sUrl, iValue, fCallback)

File diff suppressed because one or more lines are too long

View file

@ -2471,13 +2471,12 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\s]+/gm, ' ') .replace(/[\s]+/gm, ' ')
.replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue) .replace(/((?:href|data)\s?=\s?)("[^"]+?"|'[^']+?')/gmi, fixAttibuteValue)
.replace(/<br\s?\/?>/gmi, '\n') .replace(/<br\s?\/?>/gmi, '\n')
.replace(/<\/h\d>/gi, '\n') .replace(/<\/h[\d]>/gi, '\n')
.replace(/<\/p>/gi, '\n\n') .replace(/<\/p>/gi, '\n\n')
.replace(/<\/li>/gi, '\n') .replace(/<\/li>/gi, '\n')
.replace(/<\/td>/gi, '\n') .replace(/<\/td>/gi, '\n')
.replace(/<\/tr>/gi, '\n') .replace(/<\/tr>/gi, '\n')
.replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n') .replace(/<hr[^>]*>/gmi, '\n_______________________________\n\n')
.replace(/<img [^>]*>/gmi, '')
.replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs) .replace(/<div[^>]*>([\s\S\r\n]*)<\/div>/gmi, convertDivs)
.replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n') .replace(/<blockquote[^>]*>/gmi, '\n__bq__start__\n')
.replace(/<\/blockquote>/gmi, '\n__bq__end__\n') .replace(/<\/blockquote>/gmi, '\n__bq__end__\n')
@ -2485,7 +2484,6 @@ Utils.htmlToPlain = function (sHtml)
.replace(/<\/div>/gi, '\n') .replace(/<\/div>/gi, '\n')
.replace(/&nbsp;/gi, ' ') .replace(/&nbsp;/gi, ' ')
.replace(/&quot;/gi, '"') .replace(/&quot;/gi, '"')
.replace(/&amp;/gi, '&')
.replace(/<[^>]*>/gm, '') .replace(/<[^>]*>/gm, '')
; ;
@ -2496,6 +2494,7 @@ Utils.htmlToPlain = function (sHtml)
.replace(/[\n]{3,}/gm, '\n\n') .replace(/[\n]{3,}/gm, '\n\n')
.replace(/&gt;/gi, '>') .replace(/&gt;/gi, '>')
.replace(/&lt;/gi, '<') .replace(/&lt;/gi, '<')
.replace(/&amp;/gi, '&')
; ;
iPos = 0; iPos = 0;
@ -2543,9 +2542,10 @@ Utils.htmlToPlain = function (sHtml)
/** /**
* @param {string} sPlain * @param {string} sPlain
* @param {boolean} bLinkify = false
* @return {string} * @return {string}
*/ */
Utils.plainToHtml = function (sPlain) Utils.plainToHtml = function (sPlain, bLinkify)
{ {
sPlain = sPlain.toString().replace(/\r/g, ''); sPlain = sPlain.toString().replace(/\r/g, '');
@ -2610,14 +2610,29 @@ Utils.plainToHtml = function (sPlain)
.replace(/[\-_~]{10,}/g, '<hr />') .replace(/[\-_~]{10,}/g, '<hr />')
.replace(/\n/g, '<br />'); .replace(/\n/g, '<br />');
return bLinkify ? Utils.linkify(sPlain) : sPlain;
};
window.rainloop_Utils_htmlToPlain = Utils.htmlToPlain;
window.rainloop_Utils_plainToHtml = Utils.plainToHtml;
/**
* @param {string} sHtml
* @return {string}
*/
Utils.linkify = function (sHtml)
{
if ($.fn && $.fn.linkify) if ($.fn && $.fn.linkify)
{ {
sPlain = Utils.$div.html(sPlain) sHtml = Utils.$div.html(sHtml.replace(/&amp;/ig, 'amp_amp_12345_amp_amp'))
.linkify().find('.linkified').removeClass('linkified').end() .linkify()
.html(); .find('.linkified').removeClass('linkified').end()
.html()
.replace(/amp_amp_12345_amp_amp/g, '&amp;')
;
} }
return sPlain; return sHtml;
}; };
Utils.resizeAndCrop = function (sUrl, iValue, fCallback) Utils.resizeAndCrop = function (sUrl, iValue, fCallback)
@ -17332,7 +17347,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
oBody = null, oBody = null,
oTextBody = null, oTextBody = null,
sId = '', sId = '',
sPlainAsHtml = '', sResultHtml = '',
bPgpSigned = false, bPgpSigned = false,
bPgpEncrypted = false, bPgpEncrypted = false,
oMessagesBodiesDom = this.messagesBodiesDom(), oMessagesBodiesDom = this.messagesBodiesDom(),
@ -17368,16 +17383,12 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html) if (Utils.isNormal(oData.Result.Html) && '' !== oData.Result.Html)
{ {
bIsHtml = true; bIsHtml = true;
oBody sResultHtml = oData.Result.Html.toString();
.html(oData.Result.Html.toString())
.linkify().find('.linkified').removeClass('linkified').end()
.addClass('b-text-part html')
;
} }
else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain) else if (Utils.isNormal(oData.Result.Plain) && '' !== oData.Result.Plain)
{ {
bIsHtml = false; bIsHtml = false;
sPlainAsHtml = Utils.plainToHtml(oData.Result.Plain.toString()); sResultHtml = Utils.plainToHtml(oData.Result.Plain.toString(), false);
if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().capaOpenPGP()) if ((oMessage.isPgpSigned() || oMessage.isPgpEncrypted()) && RL.data().capaOpenPGP())
{ {
@ -17393,7 +17404,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
$proxyDiv.empty(); $proxyDiv.empty();
if (bPgpSigned && oMessage.isPgpSigned()) if (bPgpSigned && oMessage.isPgpSigned())
{ {
sPlainAsHtml = sResultHtml =
$proxyDiv.append( $proxyDiv.append(
$('<pre class="b-plain-openpgp signed"></pre>').text(oMessage.plainRaw) $('<pre class="b-plain-openpgp signed"></pre>').text(oMessage.plainRaw)
).html() ).html()
@ -17401,7 +17412,7 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
} }
else if (bPgpEncrypted && oMessage.isPgpEncrypted()) else if (bPgpEncrypted && oMessage.isPgpEncrypted())
{ {
sPlainAsHtml = sResultHtml =
$proxyDiv.append( $proxyDiv.append(
$('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw) $('<pre class="b-plain-openpgp encrypted"></pre>').text(oMessage.plainRaw)
).html() ).html()
@ -17413,18 +17424,17 @@ WebMailDataStorage.prototype.setMessage = function (oData, bCached)
oMessage.isPgpSigned(bPgpSigned); oMessage.isPgpSigned(bPgpSigned);
oMessage.isPgpEncrypted(bPgpEncrypted); oMessage.isPgpEncrypted(bPgpEncrypted);
} }
oBody
.html(sPlainAsHtml)
.linkify().find('.linkified').removeClass('linkified').end()
.addClass('b-text-part plain')
;
} }
else else
{ {
bIsHtml = false; bIsHtml = false;
} }
oBody
.html(Utils.linkify(sResultHtml))
.addClass('b-text-part ' + (bIsHtml ? 'html' : 'plain'))
;
oMessage.isHtml(!!bIsHtml); oMessage.isHtml(!!bIsHtml);
oMessage.hasImages(!!bHasExternals); oMessage.hasImages(!!bHasExternals);
oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None); oMessage.pgpSignedVerifyStatus(Enums.SignedVerifyStatus.None);

File diff suppressed because one or more lines are too long