mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-21 07:46:06 +08:00
Completely remove sanitized tags with non-text contents
This commit is contained in:
parent
3c336c9f88
commit
d2fc8172af
|
@ -42,6 +42,8 @@ const AttributesContainingLinks = [
|
|||
'classid',
|
||||
];
|
||||
|
||||
const NodesWithNonTextContent = asMap(['script', 'style', 'iframe', 'object', 'meta']);
|
||||
|
||||
const Preset = {
|
||||
PasteFragment: {
|
||||
fragment: true,
|
||||
|
@ -443,7 +445,14 @@ class SanitizeTransformer {
|
|||
}
|
||||
|
||||
if (!settings.allowedTags.hasOwnProperty(nodeName)) {
|
||||
// this node isn't allowed, replace it with a `span` with the same children.
|
||||
// this node isn't allowed - what should we do with it?
|
||||
|
||||
// Nodes with non-text contents: completely remove them
|
||||
if (NodesWithNonTextContent.hasOwnProperty(nodeName)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// Nodes with text contents / no contents: replace with a `span` with the same children.
|
||||
// This allows us to ignore things like tables / table cells and still get their contents.
|
||||
let replacementNode = document.createElement('span');
|
||||
for (const child of Array.from(node.childNodes)) {
|
||||
|
|
Loading…
Reference in a new issue