From e8e6c86be1a86c81766b8ec4da46a1d85e8f681e Mon Sep 17 00:00:00 2001 From: mic Date: Sun, 22 Feb 2026 22:22:22 +0100 Subject: [PATCH] getMailHeader now returns always a string. sanitizeMailHeaders method added. see #672 --- js/mzta-utils.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/js/mzta-utils.js b/js/mzta-utils.js index 67ce0823..601a082c 100644 --- a/js/mzta-utils.js +++ b/js/mzta-utils.js @@ -194,7 +194,8 @@ export async function getMailHeader(curr_message, mail_header_id) { let full_message = await browser.messages.getFull(curr_message.id); // console.log(">>>>>>>>>>>> getMailHeader full_message: " + JSON.stringify(full_message)); if(full_message.hasOwnProperty("headers") && Object.keys(full_message.headers).some(header => header.toLowerCase() === mail_header_id.toLowerCase())){ - mail_header_value = full_message.headers[Object.keys(full_message.headers).find(header => header.toLowerCase() === mail_header_id.toLowerCase())]; + const raw_value = full_message.headers[Object.keys(full_message.headers).find(header => header.toLowerCase() === mail_header_id.toLowerCase())]; + mail_header_value = Array.isArray(raw_value) ? raw_value.join(", ") : raw_value; } // console.log(">>>>>>>>>>>> getMailHeader mail_header_value: " + mail_header_value) return mail_header_value; @@ -205,6 +206,12 @@ export function sanitizeHtml(input) { return input.replace(/<(?!br\s*\/?)[^>]+>/gi, ''); } +export function sanitizeMailHeaders(input){ + console.log(">>>>>>>>>>>> sanitizeMailHeaders input: " + JSON.stringify(input)); + if(!input) return ''; + return input.replace(//g, '>'); +} + export function stripHtmlKeepLines(htmlString) { // Replaces

tags with a newline at the beginning // and removes all other HTML tags