From 44fe6003ffdf6ab50feca5dd755d10e17b12846d Mon Sep 17 00:00:00 2001 From: Patrick Maia Date: Thu, 7 Aug 2014 14:37:03 -0300 Subject: fixes bug in which plain text emails were not being properly formatted --- web-ui/app/js/helpers/view_helper.js | 6 ++++-- web-ui/test/spec/helpers/view_helper.spec.js | 6 ++++++ web-ui/test/test_data.js | 2 +- 3 files changed, 11 insertions(+), 3 deletions(-) (limited to 'web-ui') 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('

Hello everyone!

'); }); + it('formats the body of a plain text email', function () { + var formatedMail = $('
'); + formatedMail.html(viewHelper.formatMailBody(testData.parsedMail.simpleTextPlain)); + expect(formatedMail).toContainHtml('

Hello Everyone

'); + }); + 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: [] }; }, -- cgit v1.2.3