From 444fb09d1ee72261f716ac8302afb09d1bbbc1f2 Mon Sep 17 00:00:00 2001 From: Nicolas Bayet Date: Wed, 27 Apr 2022 10:57:42 +0000 Subject: [PATCH] [FIX] web_editor: prevent crash when inserting empty string Before this commit, when unsing the function `insert()` with data being an empty string, the function crashed but shouldn't. task-2833740 X-original-commit: d44302550ddc027d4891ad04bf16c364e171e5ad Part-of: odoo/odoo#89932 --- .../web_editor/static/lib/odoo-editor/src/commands/commands.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js b/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js index a58a311b660..a8a279c218c 100644 --- a/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js +++ b/addons/web_editor/static/lib/odoo-editor/src/commands/commands.js @@ -46,6 +46,9 @@ const TEXT_CLASSES_REGEX = /\btext-[^\s]*\b/g; const BG_CLASSES_REGEX = /\bbg-[^\s]*\b/g; function insert(editor, data, isText = true) { + if (!data) { + return; + } const selection = editor.document.getSelection(); const range = selection.getRangeAt(0); let currentNode;