[FIX] web_editor: allow iframe on website builder

On website, if an iframe was in the page, the iframe was removed
when calling the redo command of the insertion of the iframe (and
also other cases).
 The reason is because of a sanitization process that is usefull only
 in a collaborative context.

 This commit disable the sanitization when the collaboration is not
 active.

task-2670597

closes odoo/odoo#79056

X-original-commit: 2b9595a1f2d8ee1c019751d4cb080fe9b9f4c05c
Signed-off-by: David Monjoie (dmo) <dmo@odoo.com>
This commit is contained in:
Nicolas Bayet
2021-10-27 11:56:10 +00:00
parent c06f4ff321
commit 4c1c38bb85
@@ -678,7 +678,11 @@ export class OdooEditor extends EventTarget {
} else if (record.type === 'attributes') {
const node = this.idFind(record.id);
if (node) {
this._safeSetAttribute(node, record.attributeName, record.value);
if (this._collabClientId) {
this._safeSetAttribute(node, record.attributeName, record.value);
} else {
node.setAttribute(record.attributeName, record.value);
}
}
} else if (record.type === 'remove') {
const toremove = this.idFind(record.id);
@@ -687,13 +691,16 @@ export class OdooEditor extends EventTarget {
}
} else if (record.type === 'add') {
let node = this.idFind(record.oid) || this.unserializeNode(record.node);
const fakeNode = document.createElement('fake-el');
fakeNode.appendChild(node);
DOMPurify.sanitize(fakeNode, { IN_PLACE: true });
node = fakeNode.childNodes[0];
if (!node) {
continue;
if (this._collabClientId) {
const fakeNode = document.createElement('fake-el');
fakeNode.appendChild(node);
DOMPurify.sanitize(fakeNode, { IN_PLACE: true });
node = fakeNode.childNodes[0];
if (!node) {
continue;
}
}
this.idSet(node, true);
if (record.append && this.idFind(record.append)) {
@@ -797,7 +804,11 @@ export class OdooEditor extends EventTarget {
const node = this.idFind(mutation.id);
if (node) {
if (mutation.oldValue) {
this._safeSetAttribute(node, mutation.attributeName, mutation.oldValue);
if (this._collabClientId) {
this._safeSetAttribute(node, mutation.attributeName, mutation.oldValue);
} else {
node.setAttribute(mutation.attributeName, mutation.oldValue);
}
} else {
node.removeAttribute(mutation.attributeName);
}