getMailHeader now returns always a string. sanitizeMailHeaders method added. see #672

This commit is contained in:
mic 2026-02-22 22:22:22 +01:00
parent bcc7a5f62b
commit e8e6c86be1

View file

@ -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, '&lt;').replace(/>/g, '&gt;');
}
export function stripHtmlKeepLines(htmlString) {
// Replaces <p> tags with a newline at the beginning
// and removes all other HTML tags