From 72ec3f714262f9005c6dd1772d09d7c84fbd9956 Mon Sep 17 00:00:00 2001 From: "mathias.wasserthal" Date: Fri, 12 Dec 2014 15:22:56 +0100 Subject: [PATCH] correct display of text/plain and text/html multipart messages with quoted-printable transfer type --- MailHog-UI/assets/js/controllers.js | 11 +++++++++-- MailHog-UI/assets/templates/index.html | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/MailHog-UI/assets/js/controllers.js b/MailHog-UI/assets/js/controllers.js index 09e654f..11993d5 100644 --- a/MailHog-UI/assets/js/controllers.js +++ b/MailHog-UI/assets/js/controllers.js @@ -181,7 +181,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { $scope.getMessagePlain = function(message) { var l = $scope.findMatchingMIME(message, "text/plain"); if(l != null && l !== "undefined") { - return l.Body; + return $scope.tryDecode(l); } return message.Content.Body; } @@ -217,11 +217,18 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { $scope.getMessageHTML = function(message) { var l = $scope.findMatchingMIME(message, "text/html"); if(l != null && l !== "undefined") { - return l.Body; + return $scope.tryDecode(l); } return ""; } + $scope.tryDecode = function(l){ + if(l.Headers && l.Headers["Content-Type"] && l.Headers["Content-Transfer-Encoding"]){ + return $scope.tryDecodeContent({Content:l},l.Body.replace(/=[\r\n]+/gm,"")); + }else{ + return l.Body; + } + }; $scope.date = function(timestamp) { return (new Date(timestamp)).toString(); }; diff --git a/MailHog-UI/assets/templates/index.html b/MailHog-UI/assets/templates/index.html index bb4e820..332c3b6 100644 --- a/MailHog-UI/assets/templates/index.html +++ b/MailHog-UI/assets/templates/index.html @@ -228,7 +228,7 @@
-
{{ tryDecodeContent(preview, getMessagePlain(preview)) }}
+
{{ getMessagePlain(preview) }}
{{ getSource(preview) }}