correct display of text/plain and text/html multipart messages with quoted-printable transfer type

This commit is contained in:
mathias.wasserthal 2014-12-12 15:22:56 +01:00
parent 537f51a6f6
commit 72ec3f7142
2 changed files with 10 additions and 3 deletions

View file

@ -181,7 +181,7 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessagePlain = function(message) { $scope.getMessagePlain = function(message) {
var l = $scope.findMatchingMIME(message, "text/plain"); var l = $scope.findMatchingMIME(message, "text/plain");
if(l != null && l !== "undefined") { if(l != null && l !== "undefined") {
return l.Body; return $scope.tryDecode(l);
} }
return message.Content.Body; return message.Content.Body;
} }
@ -217,11 +217,18 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) {
$scope.getMessageHTML = function(message) { $scope.getMessageHTML = function(message) {
var l = $scope.findMatchingMIME(message, "text/html"); var l = $scope.findMatchingMIME(message, "text/html");
if(l != null && l !== "undefined") { if(l != null && l !== "undefined") {
return l.Body; return $scope.tryDecode(l);
} }
return "<HTML not found>"; return "<HTML not found>";
} }
$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) { $scope.date = function(timestamp) {
return (new Date(timestamp)).toString(); return (new Date(timestamp)).toString();
}; };

View file

@ -228,7 +228,7 @@
</ul> </ul>
<div class="tab-content"> <div class="tab-content">
<div ng-if="hasHTML(preview)" ng-class="{ active: hasHTML(preview) }" class="tab-pane" id="preview-html" ng-bind-html="preview.previewHTML"></div> <div ng-if="hasHTML(preview)" ng-class="{ active: hasHTML(preview) }" class="tab-pane" id="preview-html" ng-bind-html="preview.previewHTML"></div>
<div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ tryDecodeContent(preview, getMessagePlain(preview)) }}</div> <div class="tab-pane" ng-class="{ active: !hasHTML(preview) }" id="preview-plain">{{ getMessagePlain(preview) }}</div>
<div class="tab-pane" id="preview-source">{{ getSource(preview) }}</div> <div class="tab-pane" id="preview-source">{{ getSource(preview) }}</div>
<div class="tab-pane" id="preview-mime"> <div class="tab-pane" id="preview-mime">
<div ng-repeat="part in preview.MIME.Parts" class="mime-part"> <div ng-repeat="part in preview.MIME.Parts" class="mime-part">