mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-09-06 16:07:03 +03:00
Bugfix for whitelist to show images directly #201
This commit is contained in:
parent
539ddcc51f
commit
b0a4fb77be
1 changed files with 17 additions and 8 deletions
|
|
@ -384,23 +384,32 @@ export class MessageModel extends AbstractModel {
|
||||||
showExternalImages(regex) {
|
showExternalImages(regex) {
|
||||||
const body = this.body;
|
const body = this.body;
|
||||||
if (body && this.hasImages()) {
|
if (body && this.hasImages()) {
|
||||||
this.hasImages(false);
|
let hasImages = false,
|
||||||
body.rlHasImages = false;
|
isValid = src => {
|
||||||
|
if (!regex || src.match(regex)) {
|
||||||
let attr = 'data-x-src',
|
return true;
|
||||||
|
}
|
||||||
|
hasImages = true;
|
||||||
|
},
|
||||||
|
attr = 'data-x-src',
|
||||||
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
|
src, useProxy = !!SettingsGet('UseLocalProxyForExternalImages');
|
||||||
body.querySelectorAll('img[' + attr + ']').forEach(node => {
|
body.querySelectorAll('img[' + attr + ']').forEach(node => {
|
||||||
src = node.getAttribute(attr);
|
src = node.getAttribute(attr);
|
||||||
if (!regex || src.match(regex)) {
|
if (isValid(src)) {
|
||||||
node.src = useProxy ? proxy(src) : src;
|
node.src = useProxy ? proxy(src) : src;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
body.querySelectorAll('[data-x-style-url]').forEach(node => {
|
body.querySelectorAll('[data-x-style-url]').forEach(node => {
|
||||||
JSON.parse(node.dataset.xStyleUrl).forEach(data =>
|
JSON.parse(node.dataset.xStyleUrl).forEach(data => {
|
||||||
node.style[data[0]] = "url('" + (useProxy ? proxy(data[1]) : data[1]) + "')"
|
if (isValid(data[1])) {
|
||||||
);
|
node.style[data[0]] = "url('" + (useProxy ? proxy(data[1]) : data[1]) + "')"
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this.hasImages(hasImages);
|
||||||
|
body.rlHasImages = hasImages;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue