summaryrefslogtreecommitdiff
path: root/web-ui/app
diff options
context:
space:
mode:
authorBruno Wagner and Fabio Pio <bwagner+fpio@thoughtworks.com>2015-01-16 19:30:02 -0200
committerPixpoa pairing <pixpoapairing@pixelated-project.org>2015-01-16 19:30:02 -0200
commit9b878c19d87c1c77e32f87bc1dde5c96102aee61 (patch)
tree0ce31d4c04f0adbc44e0ca657d9cb46775e73f85 /web-ui/app
parent636862357da282171c78a712b4a398b725f8ae94 (diff)
Issue #233 plain text body now escapes html tags
Diffstat (limited to 'web-ui/app')
-rw-r--r--web-ui/app/js/helpers/view_helper.js25
1 files changed, 24 insertions, 1 deletions
diff --git a/web-ui/app/js/helpers/view_helper.js b/web-ui/app/js/helpers/view_helper.js
index 01ab45ed..bb909cea 100644
--- a/web-ui/app/js/helpers/view_helper.js
+++ b/web-ui/app/js/helpers/view_helper.js
@@ -35,10 +35,33 @@ define(
return textPlainBody.replace(/^(.*?)$/mg, '<p>$1</p>');
}
+ function escapeHtmlTags (body) {
+
+ var escapeIndex = {
+ "&": "&amp;",
+ "<": "&lt;",
+ ">": "&gt;",
+ '"': '&quot;',
+ "'":'&#39;',
+ "/": '&#x2f;'
+
+ };
+
+ return body.replace(/["'<>\/&]/g, function(char){
+ return escapeIndex[char];
+ } )
+
+ }
+
+ function escapeHtmlAndAddParagraphs (body) {
+ var escapedBody = escapeHtmlTags(body);
+ return addParagraphsToPlainText(escapedBody);
+ }
+
function formatMailBody (mail) {
var body = mail.htmlBodyPart ?
htmlWhitelister.sanitize(mail.htmlBody, htmlWhitelister.tagPolicy) :
- addParagraphsToPlainText(mail.textPlainBody);
+ escapeHtmlAndAddParagraphs(mail.textPlainBody);
return $(body);
}