[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) <dmo@odoo.com>
This commit is contained in:
@@ -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, '');
|
||||
|
||||
Reference in New Issue
Block a user