getMailHeader now returns always a string. sanitizeMailHeaders method added. see #672
This commit is contained in:
parent
bcc7a5f62b
commit
e8e6c86be1
1 changed files with 8 additions and 1 deletions
|
|
@ -194,7 +194,8 @@ export async function getMailHeader(curr_message, mail_header_id) {
|
||||||
let full_message = await browser.messages.getFull(curr_message.id);
|
let full_message = await browser.messages.getFull(curr_message.id);
|
||||||
// console.log(">>>>>>>>>>>> getMailHeader full_message: " + JSON.stringify(full_message));
|
// 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())){
|
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)
|
// console.log(">>>>>>>>>>>> getMailHeader mail_header_value: " + mail_header_value)
|
||||||
return mail_header_value;
|
return mail_header_value;
|
||||||
|
|
@ -205,6 +206,12 @@ export function sanitizeHtml(input) {
|
||||||
return input.replace(/<(?!br\s*\/?)[^>]+>/gi, '');
|
return input.replace(/<(?!br\s*\/?)[^>]+>/gi, '');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function sanitizeMailHeaders(input){
|
||||||
|
console.log(">>>>>>>>>>>> sanitizeMailHeaders input: " + JSON.stringify(input));
|
||||||
|
if(!input) return '';
|
||||||
|
return input.replace(/</g, '<').replace(/>/g, '>');
|
||||||
|
}
|
||||||
|
|
||||||
export function stripHtmlKeepLines(htmlString) {
|
export function stripHtmlKeepLines(htmlString) {
|
||||||
// Replaces <p> tags with a newline at the beginning
|
// Replaces <p> tags with a newline at the beginning
|
||||||
// and removes all other HTML tags
|
// and removes all other HTML tags
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue