From c5a8836b7e7d312d04c2823619dcdb847b6e5293 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Mon, 24 Apr 2023 22:27:57 +1200 Subject: [PATCH 1/2] Bugfix: Fix UI images not displaying when multiple cid names overlap Resolves #96 --- server/ui-src/App.vue | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/server/ui-src/App.vue b/server/ui-src/App.vue index 3faffc024..c4a05d6fa 100644 --- a/server/ui-src/App.vue +++ b/server/ui-src/App.vue @@ -213,7 +213,6 @@ export default { let uri = 'api/v1/message/' + self.currentPath self.get(uri, false, function (response) { - for (let i in self.items) { if (self.items[i].ID == self.currentPath) { if (!self.items[i].Read) { @@ -222,51 +221,56 @@ export default { } } } + let d = response.data; - // replace inline images + + // replace inline images embedded as inline attachments if (d.HTML && d.Inline) { for (let i in d.Inline) { let a = d.Inline[i]; if (a.ContentID != '') { d.HTML = d.HTML.replace( - new RegExp('cid:' + a.ContentID, 'g'), - window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + new RegExp('(=["\']?)(cid:' + a.ContentID + ')(["|\'|\s|\/|>|;])', 'g'), + '$1' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '$3' ); } if (a.FileName.match(/^[a-zA-Z0-9\_\-\.]+$/)) { // some old email clients use the filename d.HTML = d.HTML.replace( - new RegExp('src=(\'|")' + a.FileName + '(\'|")', 'g'), - 'src="' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '"' + new RegExp('(=["\']?)(' + a.FileName + ')(["|\'|\s|\/|>|;])', 'g'), + '$1' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '$3' ); } } } - // replace inline images + + // replace inline images embedded as regular attachments if (d.HTML && d.Attachments) { for (let i in d.Attachments) { let a = d.Attachments[i]; if (a.ContentID != '') { d.HTML = d.HTML.replace( - new RegExp('cid:' + a.ContentID, 'g'), - window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + new RegExp('(=["\']?)(cid:' + a.ContentID + ')(["|\'|\s|\/|>|;])', 'g'), + '$1' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '$3' ); } if (a.FileName.match(/^[a-zA-Z0-9\_\-\.]+$/)) { // some old email clients use the filename d.HTML = d.HTML.replace( - new RegExp('src=(\'|")' + a.FileName + '(\'|")', 'g'), - 'src="' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '"' + new RegExp('(=["\']?)(' + a.FileName + ')(["|\'|\s|\/|>|;])', 'g'), + '$1' + window.location.origin + window.location.pathname + 'api/v1/message/' + d.ID + '/part/' + a.PartID + '$3' ); } } } self.message = d; + // generate the prev/next links based on current message list self.messagePrev = false; self.messageNext = false; let found = false; + for (let i in self.items) { if (self.items[i].ID == self.message.ID) { found = true; From 5e00013a8d4c9cc194bb8d0fc4085ca848b09cc8 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Mon, 24 Apr 2023 22:29:35 +1200 Subject: [PATCH 2/2] Release v1.6.4 --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b6e8e89b..73d9528a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,12 @@ Notable changes to Mailpit will be documented in this file. +## [v1.6.4] + +### Bugfix +- Fix UI images not displaying when multiple cid names overlap + + ## [v1.6.3] ### Feature