summaryrefslogtreecommitdiff
path: root/web-ui
diff options
context:
space:
mode:
authorPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-07 14:37:03 -0300
committerPatrick Maia <patrickjourdanmaia@gmail.com>2014-08-07 14:37:03 -0300
commit44fe6003ffdf6ab50feca5dd755d10e17b12846d (patch)
treecf4e8a8e67512dc7af1880db4c577426ead4d9a9 /web-ui
parent118e0428b906ed02f0189ffb23d7b67d1d8c4a1d (diff)
fixes bug in which plain text emails were not being properly formatted
Diffstat (limited to 'web-ui')
-rw-r--r--web-ui/app/js/helpers/view_helper.js6
-rw-r--r--web-ui/test/spec/helpers/view_helper.spec.js6
-rw-r--r--web-ui/test/test_data.js2
3 files changed, 11 insertions, 3 deletions
diff --git a/web-ui/app/js/helpers/view_helper.js b/web-ui/app/js/helpers/view_helper.js
index 02067005..76e574bf 100644
--- a/web-ui/app/js/helpers/view_helper.js
+++ b/web-ui/app/js/helpers/view_helper.js
@@ -21,7 +21,7 @@ define(
}
function isQuotedPrintableBodyPart (bodyPart) {
- return bodyPart.headers &&
+ return bodyPart.headers &&
bodyPart.headers['Content-Transfer-Encoding'] &&
bodyPart.headers['Content-Transfer-Encoding'] === 'quoted-printable';
}
@@ -37,8 +37,10 @@ define(
if (isQuotedPrintableBodyPart(bodyPart)) {
body = quotedPrintable.decode(bodyPart.body);
- } else {
+ } else if (bodyPart.body) {
body = bodyPart.body;
+ } else {
+ body = bodyPart;
}
return htmlWhitelister.sanitize(body, htmlWhitelister.tagPolicy);
diff --git a/web-ui/test/spec/helpers/view_helper.spec.js b/web-ui/test/spec/helpers/view_helper.spec.js
index 7fa10e56..1bcf68dd 100644
--- a/web-ui/test/spec/helpers/view_helper.spec.js
+++ b/web-ui/test/spec/helpers/view_helper.spec.js
@@ -59,6 +59,12 @@ define(['helpers/view_helper'], function (viewHelper) {
expect(viewHelper.formatMailBody(testData.parsedMail.html)).toContainHtml('<p>Hello everyone!</p>');
});
+ it('formats the body of a plain text email', function () {
+ var formatedMail = $('<div></div>');
+ formatedMail.html(viewHelper.formatMailBody(testData.parsedMail.simpleTextPlain));
+ expect(formatedMail).toContainHtml('<p>Hello Everyone</p>');
+ });
+
it('decodes a quoted-printable email body', function () {
var result = viewHelper.formatMailBody(testData.parsedMail.htmlQuotedPrintable);
diff --git a/web-ui/test/test_data.js b/web-ui/test/test_data.js
index 8c7b6f21..c32bc65f 100644
--- a/web-ui/test/test_data.js
+++ b/web-ui/test/test_data.js
@@ -84,7 +84,7 @@ define(function() {
ident:1,
tags:['textplain','inbox'],
status:[],
- body: 'Porro quam minus. Doloribus odio vel. Placeat alias sed est assumenda qui esse. Tenetur tempora deserunt est consequatur ducimus laborum. Velit dolor voluptatibus.\n\nRerum repellendus tempore. Aliquam dolores laudantium amet et dolor voluptas. Quod eos magni mollitia et ex. Corrupti quis reprehenderit quasi. Quam cum nobis voluptas accusamus quisquam ut asperiores.\n\nFacilis dicta mollitia non molestiae. Eligendi perspiciatis aut qui eos qui. Laborum cumque odit velit nobis. Cumque quo impedit dignissimos quia.',
+ body: 'Hello Everyone',
isSentMail: function() { return false; },
isDraftMail: function() { return false; },
replyToAddress: function() { return { to: ['laurel@hamill.info'], cc: [] }; },