From 4c1c38bb85b91c2cdd5adfdeddf40f17279a4bfc Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Mon, 18 Oct 2021 14:33:07 +0000 Subject: [PATCH] [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) --- .../static/lib/odoo-editor/src/OdooEditor.js | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js index 5fe3adaec40..32596b62fa9 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -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); }