This commit is contained in:
the-djmaze 2023-01-31 14:45:50 +01:00
parent 6129fb4233
commit 07079b519a
44 changed files with 287 additions and 102 deletions

View file

@ -286,8 +286,22 @@ export class MessageModel extends AbstractModel {
body.classList.toggle('html', 1);
body.classList.toggle('plain', 0);
if (SettingsUserStore.showImages() && !this.isSpam() && FolderUserStore.spamFolder() != this.folder) {
this.showExternalImages();
if (!this.isSpam() && FolderUserStore.spamFolder() != this.folder) {
if ('always' === SettingsUserStore.viewImages()) {
this.showExternalImages();
}
if ('match' === SettingsUserStore.viewImages()) {
let regex = SettingsUserStore.viewImagesWhitelist()
.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
.replace(/[\s\S,;:]+/g, '|')
.replace(/\|+/g, '|');
if (regex.length) {
regex = new RegExp(regex);
this.showExternalImages(
(this.from[0]?.email.match(regex)/* || this.sender[0]?.email.match(regex)*/) ? null : regex
);
}
}
}
this.isHtml(true);
@ -391,7 +405,7 @@ export class MessageModel extends AbstractModel {
return self;
}
showExternalImages() {
showExternalImages(regex) {
const body = this.body;
if (body && this.hasImages()) {
this.hasImages(false);
@ -401,7 +415,9 @@ export class MessageModel extends AbstractModel {
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
body.querySelectorAll('img[' + attr + ']').forEach(node => {
src = node.getAttribute(attr);
node.src = useProxy ? proxy(src) : src;
if (!regex || src.match(regex)) {
node.src = useProxy ? proxy(src) : src;
}
});
body.querySelectorAll('[data-x-style-url]').forEach(node => {

View file

@ -43,7 +43,8 @@ export class UserSettingsGeneral extends AbstractViewSettings {
['layout', 'messageReadDelay', 'messagesPerPage',
'editorDefaultType', 'requestReadReceipt', 'requestDsn', 'requireTLS', 'pgpSign', 'pgpEncrypt',
'viewHTML', 'showImages', 'removeColors', 'hideDeleted', 'listInlineAttachments', 'simpleAttachmentsList',
'viewHTML', 'viewImages', 'viewImagesWhitelist', 'removeColors',
'hideDeleted', 'listInlineAttachments', 'simpleAttachmentsList',
'useCheckboxesInList', 'listGrouped', 'useThreads', 'replySameFolder', 'msgDefaultAction', 'allowSpellcheck'
].forEach(name => this[name] = SettingsUserStore[name]);
@ -98,8 +99,8 @@ export class UserSettingsGeneral extends AbstractViewSettings {
this.addSetting('MessagesPerPage');
this.addSetting('Layout');
this.addSettings(['ViewHTML', 'ShowImages', 'HideDeleted', 'ListInlineAttachments', 'simpleAttachmentsList',
'UseCheckboxesInList', 'listGrouped', 'ReplySameFolder',
this.addSettings(['ViewHTML', 'ViewImages', 'ViewImagesWhitelist', 'HideDeleted',
'ListInlineAttachments', 'simpleAttachmentsList', 'UseCheckboxesInList', 'listGrouped', 'ReplySameFolder',
'requestReadReceipt', 'requestDsn', 'requireTLS', 'pgpSign', 'pgpEncrypt', 'allowSpellcheck',
'DesktopNotifications', 'SoundNotification']);

View file

@ -16,7 +16,8 @@ export const SettingsUserStore = new class {
addObservablesTo(self, {
viewHTML: 1,
showImages: 0,
viewImages: 0,
viewImagesWhitelist: '',
removeColors: 0,
listInlineAttachments: 0,
simpleAttachmentsList: 0,
@ -81,7 +82,8 @@ export const SettingsUserStore = new class {
self.msgDefaultAction(SettingsGet('MsgDefaultAction'));
self.viewHTML(SettingsGet('ViewHTML'));
self.showImages(SettingsGet('ShowImages'));
self.viewImages(SettingsGet('ViewImages'));
self.viewImagesWhitelist(SettingsGet('ViewImagesWhitelist'));
self.removeColors(SettingsGet('RemoveColors'));
self.listInlineAttachments(SettingsGet('ListInlineAttachments'));
self.simpleAttachmentsList(SettingsGet('simpleAttachmentsList'));