From ad7e6c19bfc0c3bcfeb49e7c9e8aa190e006dfb3 Mon Sep 17 00:00:00 2001 From: "Achraf (abz)" Date: Mon, 19 Jul 2021 14:25:59 +0000 Subject: [PATCH] [FIX] web_editor: Allow internal users to copy/paste On windows when you copy paste text in and into Odoo (for example in the description when creating a ticket) a traceback occurs. There is an isWhitelist function which verifies that a node is indeed in the authorized items via the following instruction `item.matches (CLIPBOARD_WHITELISTS.nodes.join (','))` But on windows there is a comment node containing `<--StartFragment-->` Here is the clipboard data on linux and on windows for the same copied text (Hello): - Linux ``` Hello ``` - Windows ``` Hello ``` Except for this additional comment on Windows, the `.matches()` method does not exist. This PR uses the `Array.includes` function on the item's `nodeName`, which should work in all cases while keeping the same behavior. opw-2591597 closes odoo/odoo#74029 X-original-commit: 41802bc518b4bcd1c71d8659ac560cb748befd95 Signed-off-by: Achraf --- addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 648aacaa737..8ca902e67f9 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js +++ b/addons/web_editor/static/lib/odoo-editor/src/OdooEditor.js @@ -1552,7 +1552,7 @@ export class OdooEditor extends EventTarget { */ _cleanForPaste(node) { if (!this._isWhitelisted(node) || this._isBlacklisted(node)) { - if (node.matches(CLIPBOARD_BLACKLISTS.remove.join(','))) { + if (!node.matches || node.matches(CLIPBOARD_BLACKLISTS.remove.join(','))) { node.remove(); } else { // Unwrap the illegal node's contents.