From ca7bb3f8a72dda778025817215b220ff81d3d45c Mon Sep 17 00:00:00 2001 From: Stanislas Gueniffey Date: Mon, 17 Apr 2023 16:18:42 +0000 Subject: [PATCH] [FIX] web_editor: fix powerbox search term split Before this commit, the term used to filter the powerbox commands was split with a simple .split('') call, separating each character. This was erroneous as it disregarded the fact that special characters are first escaped with a leading backslash (e.g. '\['), the combination actually representing a single character '['. Separating those pairs would render the constructed regex invalid when using such characters, resulting in a traceback. This commit replaces the use of split with a match, regognizing the use of backslashes for escaping. closes odoo/odoo#118922 X-original-commit: e34e908a06c18ecee5d762f6fca785b23977f47d Signed-off-by: David Monjoie (dmo) --- .../static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js index d50c4197303..34a501c6ad5 100644 --- a/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js +++ b/addons/web_editor/static/src/js/editor/odoo-editor/src/powerbox/Powerbox.js @@ -340,7 +340,7 @@ export class Powerbox { .replace(REGEX_RESERVED_CHARS, '\\$&'); if (term.length) { const exactRegex = new RegExp(term, 'i'); - const fuzzyRegex = new RegExp(term.split('').join('.*'), 'i'); + const fuzzyRegex = new RegExp(term.match(/\\.|./g).join('.*'), 'i'); this._context.filteredCommands = this._context.commands.filter(command => { const commandText = (command.category + ' ' + command.name); const commandDescription = command.description.replace(/\s/g, '');