Fixes ported from v3.8.5.
This commit is contained in:
parent
d95bd37fbf
commit
4f84da4256
2 changed files with 16 additions and 6 deletions
|
|
@ -17,7 +17,10 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { prefs_default } from '../options/mzta-options-default.js';
|
import { prefs_default } from '../options/mzta-options-default.js';
|
||||||
import { getMailHeader } from './mzta-utils.js';
|
import {
|
||||||
|
getMailHeader,
|
||||||
|
sanitizeMailHeaders
|
||||||
|
} from './mzta-utils.js';
|
||||||
|
|
||||||
/* ================= PLACEHOLDERS PROPERTIES ========================================
|
/* ================= PLACEHOLDERS PROPERTIES ========================================
|
||||||
|
|
||||||
|
|
@ -545,7 +548,7 @@ export const placeholdersUtils = {
|
||||||
finalSubs['mail_folder_path'] = placeholdersUtils.failSafePlaceholders(curr_message.folder?.path);
|
finalSubs['mail_folder_path'] = placeholdersUtils.failSafePlaceholders(curr_message.folder?.path);
|
||||||
break;
|
break;
|
||||||
case 'mail_headers':
|
case 'mail_headers':
|
||||||
finalSubs['mail_headers:' + currPH.custom_value] = placeholdersUtils.failSafePlaceholders(await getMailHeader(curr_message, currPH.custom_value));
|
finalSubs['mail_headers:' + currPH.custom_value] = placeholdersUtils.failSafePlaceholders(sanitizeMailHeaders(await getMailHeader(curr_message, currPH.custom_value)));
|
||||||
break;
|
break;
|
||||||
case 'selected_text':
|
case 'selected_text':
|
||||||
finalSubs['selected_text'] = placeholdersUtils.failSafePlaceholders(selection_text);
|
finalSubs['selected_text'] = placeholdersUtils.failSafePlaceholders(selection_text);
|
||||||
|
|
@ -560,13 +563,13 @@ export const placeholdersUtils = {
|
||||||
finalSubs['mail_html_body_or_selected'] = placeholdersUtils.failSafePlaceholders(selection_html || msg_text?.html);
|
finalSubs['mail_html_body_or_selected'] = placeholdersUtils.failSafePlaceholders(selection_html || msg_text?.html);
|
||||||
break;
|
break;
|
||||||
case 'author':
|
case 'author':
|
||||||
finalSubs['author'] = placeholdersUtils.failSafePlaceholders(curr_message.author);
|
finalSubs['author'] = placeholdersUtils.failSafePlaceholders(sanitizeMailHeaders(curr_message.author));
|
||||||
break;
|
break;
|
||||||
case 'recipients':
|
case 'recipients':
|
||||||
finalSubs['recipients'] = placeholdersUtils.failSafePlaceholders(curr_message.recipients?.join(", "));
|
finalSubs['recipients'] = placeholdersUtils.failSafePlaceholders(sanitizeMailHeaders(curr_message.recipients?.join(", ")));
|
||||||
break;
|
break;
|
||||||
case 'cc_list':
|
case 'cc_list':
|
||||||
finalSubs['cc_list'] = placeholdersUtils.failSafePlaceholders(curr_message.ccList?.join(", "));
|
finalSubs['cc_list'] = placeholdersUtils.failSafePlaceholders(sanitizeMailHeaders(curr_message.ccList?.join(", ")));
|
||||||
break;
|
break;
|
||||||
case 'junk_score':
|
case 'junk_score':
|
||||||
finalSubs['junk_score'] = placeholdersUtils.failSafePlaceholders(curr_message.junkScore);
|
finalSubs['junk_score'] = placeholdersUtils.failSafePlaceholders(curr_message.junkScore);
|
||||||
|
|
|
||||||
|
|
@ -207,7 +207,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;
|
||||||
|
|
@ -218,6 +219,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