mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-07-13 03:27:39 +03:00
Resolve #439
This commit is contained in:
parent
5609a39dd4
commit
28d4a018fd
2 changed files with 15 additions and 14 deletions
|
|
@ -181,6 +181,7 @@ export const
|
||||||
let value;
|
let value;
|
||||||
|
|
||||||
// if ('TABLE' === name || 'TD' === name || 'TH' === name) {
|
// if ('TABLE' === name || 'TD' === name || 'TH' === name) {
|
||||||
|
if (!oStyle.backgroundImage) {
|
||||||
if (hasAttribute('width')) {
|
if (hasAttribute('width')) {
|
||||||
value = getAttribute('width');
|
value = getAttribute('width');
|
||||||
oStyle.width = value.includes('%') ? value : value + 'px';
|
oStyle.width = value.includes('%') ? value : value + 'px';
|
||||||
|
|
@ -202,6 +203,7 @@ export const
|
||||||
if (value && !value.includes('%')) {
|
if (value && !value.includes('%')) {
|
||||||
oStyle.maxHeight = value;
|
oStyle.maxHeight = value;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
// } else
|
// } else
|
||||||
if ('A' === name) {
|
if ('A' === name) {
|
||||||
value = oElement.href;
|
value = oElement.href;
|
||||||
|
|
@ -302,17 +304,16 @@ export const
|
||||||
oStyle.removeProperty('cursor');
|
oStyle.removeProperty('cursor');
|
||||||
oStyle.removeProperty('min-width');
|
oStyle.removeProperty('min-width');
|
||||||
|
|
||||||
const urls = {
|
const
|
||||||
remote: [], // 'data-x-style-url'
|
urls_remote = [], // 'data-x-style-url'
|
||||||
broken: [] // 'data-x-broken-style-src'
|
urls_broken = []; // 'data-x-broken-style-src'
|
||||||
};
|
|
||||||
['backgroundImage', 'listStyleImage', 'content'].forEach(property => {
|
['backgroundImage', 'listStyleImage', 'content'].forEach(property => {
|
||||||
if (oStyle[property]) {
|
if (oStyle[property]) {
|
||||||
let value = oStyle[property],
|
let value = oStyle[property],
|
||||||
found = value.match(/url\s*\(([^)]+)\)/gi);
|
found = value.match(/url\s*\(([^)]+)\)/i);
|
||||||
if (found) {
|
if (found) {
|
||||||
oStyle[property] = null;
|
oStyle[property] = null;
|
||||||
found = found[0].replace(/^["'\s]+|["'\s]+$/g, '');
|
found = found[1].replace(/^["'\s]+|["'\s]+$/g, '');
|
||||||
let lowerUrl = found.toLowerCase();
|
let lowerUrl = found.toLowerCase();
|
||||||
if ('cid:' === lowerUrl.slice(0, 4)) {
|
if ('cid:' === lowerUrl.slice(0, 4)) {
|
||||||
const attachment = findAttachmentByCid(found);
|
const attachment = findAttachmentByCid(found);
|
||||||
|
|
@ -321,13 +322,13 @@ export const
|
||||||
attachment.isInline(true);
|
attachment.isInline(true);
|
||||||
attachment.isLinked(true);
|
attachment.isLinked(true);
|
||||||
}
|
}
|
||||||
} else if (/http[s]?:\/\//.test(lowerUrl) || '//' === found.slice(0, 2)) {
|
} else if (/^(https?:)?\/\//.test(lowerUrl)) {
|
||||||
result.hasExternals = true;
|
result.hasExternals = true;
|
||||||
urls.remote[property] = useProxy ? proxy(found) : found;
|
urls_remote.push([property, useProxy ? proxy(found) : value]);
|
||||||
} else if ('data:image/' === lowerUrl.slice(0, 11)) {
|
} else if ('data:image/' === lowerUrl.slice(0, 11)) {
|
||||||
oStyle[property] = value;
|
oStyle[property] = value;
|
||||||
} else {
|
} else {
|
||||||
urls.broken[property] = found;
|
urls_broken.push([property, found]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -335,11 +336,11 @@ export const
|
||||||
// oStyle.removeProperty('background-image');
|
// oStyle.removeProperty('background-image');
|
||||||
// oStyle.removeProperty('list-style-image');
|
// oStyle.removeProperty('list-style-image');
|
||||||
|
|
||||||
if (urls.remote.length) {
|
if (urls_remote.length) {
|
||||||
setAttribute('data-x-style-url', JSON.stringify(urls.remote));
|
setAttribute('data-x-style-url', JSON.stringify(urls_remote));
|
||||||
}
|
}
|
||||||
if (urls.broken.length) {
|
if (urls_broken.length) {
|
||||||
setAttribute('data-x-style-broken-urls', JSON.stringify(urls.broken));
|
setAttribute('data-x-style-broken-urls', JSON.stringify(urls_broken));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (11 > pInt(oStyle.fontSize)) {
|
if (11 > pInt(oStyle.fontSize)) {
|
||||||
|
|
|
||||||
|
|
@ -626,7 +626,7 @@ export class MessageModel extends AbstractModel {
|
||||||
});
|
});
|
||||||
|
|
||||||
body.querySelectorAll('[data-x-style-url]').forEach(node => {
|
body.querySelectorAll('[data-x-style-url]').forEach(node => {
|
||||||
forEachObjectEntry(JSON.parse(node.dataset.xStyleUrl), (name, url) => node.style[name] = "url('" + url + "')");
|
JSON.parse(node.dataset.xStyleUrl).forEach(data => node.style[data[0]] = "url('" + data[1] + "')");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue