mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-28 11:39:21 +03:00
Image whitelist shortcuts as discussed in #201
This commit is contained in:
parent
7aa5142047
commit
69064e2ad0
3 changed files with 40 additions and 15 deletions
|
|
@ -150,8 +150,19 @@ export class MessageModel extends AbstractModel {
|
|||
}
|
||||
});
|
||||
return tagOptions
|
||||
}
|
||||
},
|
||||
|
||||
whitelistOptions: () => {
|
||||
let options = [];
|
||||
if ('match' === SettingsUserStore.viewImages()) {
|
||||
let from = this.from[0],
|
||||
list = SettingsUserStore.viewImagesWhitelist();
|
||||
from && options.push(from.email);
|
||||
this.html().match(/src=["'][^"']+/g)?.forEach(m => options.push(m.replace(/^.+(:\/\/[^/]+).+$/, '$1')));
|
||||
options = options.filter(txt => !list.includes(txt));
|
||||
}
|
||||
return options.unique();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -283,18 +294,7 @@ export class MessageModel extends AbstractModel {
|
|||
this.showExternalImages();
|
||||
}
|
||||
if ('match' === SettingsUserStore.viewImages()) {
|
||||
let regex = SettingsUserStore.viewImagesWhitelist()
|
||||
.trim()
|
||||
.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
.replace(/[\s\r\n,;:]+/g, '|')
|
||||
.replace(/\|+/g, '|');
|
||||
if (regex.length) {
|
||||
console.log('whitelist images = '+regex);
|
||||
regex = new RegExp(regex);
|
||||
this.showExternalImages(
|
||||
(this.from[0]?.email.match(regex)/* || this.sender[0]?.email.match(regex)*/) ? null : regex
|
||||
);
|
||||
}
|
||||
this.showExternalImages(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +386,20 @@ export class MessageModel extends AbstractModel {
|
|||
showExternalImages(regex) {
|
||||
const body = this.body;
|
||||
if (body && this.hasImages()) {
|
||||
if (regex) {
|
||||
regex = SettingsUserStore.viewImagesWhitelist()
|
||||
.trim()
|
||||
.replace(/[/\-\\^$*+?.()|[\]{}]/g, '\\$&')
|
||||
.replace(/[\s\r\n,;:]+/g, '|')
|
||||
.replace(/\|+/g, '|');
|
||||
if (regex) {
|
||||
console.log('whitelist images = '+regex);
|
||||
regex = new RegExp(regex);
|
||||
if (this.from[0]?.email.match(regex)) {
|
||||
regex = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
let hasImages = false,
|
||||
isValid = src => {
|
||||
if (!regex || src.match(regex)) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue