[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) <ges@odoo.com>
This commit is contained in:
@@ -402,7 +402,7 @@ IMPORT_BASIC_RE = re.compile(r"""
|
||||
^
|
||||
(?P<space>\s*) # space and empty line
|
||||
import\s+ # import
|
||||
(?P<object>{(\s*\w+\s*,?\s*)+})\s* # { a, b, c as x, ... }
|
||||
(?P<object>{[\s\w,]+})\s* # { a, b, c as x, ... }
|
||||
from\s* # from
|
||||
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path")
|
||||
""", re.MULTILINE | re.VERBOSE)
|
||||
@@ -484,7 +484,7 @@ IMPORT_DEFAULT_AND_NAMED_RE = re.compile(r"""
|
||||
(?P<space>\s*) # space and empty line
|
||||
import\s+ # import
|
||||
(?P<default_export>\w+)\s*,\s* # default variable name,
|
||||
(?P<named_exports>{(\s*\w+\s*,?\s*)+})\s* # { a, b, c as x, ... }
|
||||
(?P<named_exports>{[\s\w,]+})\s* # { a, b, c as x, ... }
|
||||
from\s* # from
|
||||
(?P<path>(?P<quote>["'`])([^"'`]+)(?P=quote)) # "file path" ("some/path")
|
||||
""", re.MULTILINE | re.VERBOSE)
|
||||
|
||||
Reference in New Issue
Block a user