From 9bd642de7ffd7c29b34ea1ac6b2090ed782138c3 Mon Sep 17 00:00:00 2001 From: Olivier Dony Date: Thu, 24 Nov 2022 14:29:32 +0000 Subject: [PATCH] [FIX] tools/transpiler: avoid nested quantifiers It made the regex much slower in case of non-match, due to backtracking. closes odoo/odoo#108046 X-original-commit: 56b1b17d6fdf493368ce219f981f94d9efdc9b7f Signed-off-by: Simon Genin (ges@odoo) --- odoo/tools/js_transpiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/odoo/tools/js_transpiler.py b/odoo/tools/js_transpiler.py index 19d26a62333..f494853380e 100644 --- a/odoo/tools/js_transpiler.py +++ b/odoo/tools/js_transpiler.py @@ -402,7 +402,7 @@ IMPORT_BASIC_RE = re.compile(r""" ^ (?P\s*) # space and empty line import\s+ # import - (?P{(\s*\w+\s*,?\s*)+})\s* # { a, b, c as x, ... } + (?P{[\s\w,]+})\s* # { a, b, c as x, ... } from\s* # from (?P(?P["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path") """, re.MULTILINE | re.VERBOSE) @@ -484,7 +484,7 @@ IMPORT_DEFAULT_AND_NAMED_RE = re.compile(r""" (?P\s*) # space and empty line import\s+ # import (?P\w+)\s*,\s* # default variable name, - (?P{(\s*\w+\s*,?\s*)+})\s* # { a, b, c as x, ... } + (?P{[\s\w,]+})\s* # { a, b, c as x, ... } from\s* # from (?P(?P["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path") """, re.MULTILINE | re.VERBOSE)