From 66ca91749f64602504bc9ff6e4d45ccaaa86fe5d Mon Sep 17 00:00:00 2001 From: Ian Kent Date: Sun, 23 Nov 2014 16:10:47 +0000 Subject: [PATCH] Fix #9 - TODO support non-UTF-8 encodings --- MailHog-UI/assets/js/controllers.js | 15 +++++++++++++++ MailHog-UI/assets/templates/index.html | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/MailHog-UI/assets/js/controllers.js b/MailHog-UI/assets/js/controllers.js index 4eddc3c..09e654f 100644 --- a/MailHog-UI/assets/js/controllers.js +++ b/MailHog-UI/assets/js/controllers.js @@ -163,6 +163,21 @@ mailhogApp.controller('MailCtrl', function ($scope, $http, $sce, $timeout) { }, 10); } + $scope.tryDecodeContent = function(message, content) { + var charset = "UTF-8" + if(message.Content.Headers["Content-Type"][0]) { + // TODO + } + + if(message.Content.Headers["Content-Transfer-Encoding"][0]) { + if(message.Content.Headers["Content-Transfer-Encoding"][0] == "quoted-printable") { + content = unescapeFromQuotedPrintable(content, charset) + } + } + + return content + } + $scope.getMessagePlain = function(message) { var l = $scope.findMatchingMIME(message, "text/plain"); if(l != null && l !== "undefined") { diff --git a/MailHog-UI/assets/templates/index.html b/MailHog-UI/assets/templates/index.html index 332c3b6..bb4e820 100644 --- a/MailHog-UI/assets/templates/index.html +++ b/MailHog-UI/assets/templates/index.html @@ -228,7 +228,7 @@
-
{{ getMessagePlain(preview) }}
+
{{ tryDecodeContent(preview, getMessagePlain(preview)) }}
{{ getSource(preview) }}