[FIX] orm: performance of regex to check search `order` spec
This regex is used for a quick sanity check of the order_spec in `search(order=<order_spec>)`. Because it was build on the repetition of a group ending with a series of optional patterns, it could cause expensive backtracking when the order spec did not actually match the regex (the regex engine was trying all possible ways to split the groups) Forcing the repeating group to either end with a comma or the end of the string prevents prohibitive backtracking, while being even more restrictive with regard to the syntax of the order spec. Closes #7755
This commit is contained in:
parent
180b2e7746
commit
8b3d69a0d7
|
@ -77,7 +77,7 @@ _schema = logging.getLogger(__name__ + '.schema')
|
||||||
# List of etree._Element subclasses that we choose to ignore when parsing XML.
|
# List of etree._Element subclasses that we choose to ignore when parsing XML.
|
||||||
from openerp.tools import SKIPPED_ELEMENT_TYPES
|
from openerp.tools import SKIPPED_ELEMENT_TYPES
|
||||||
|
|
||||||
regex_order = re.compile('^( *([a-z0-9_]+|"[a-z0-9_]+")( *desc| *asc)?( *, *|))+$', re.I)
|
regex_order = re.compile('^(\s*([a-z0-9:_]+|"[a-z0-9:_]+")(\s+(desc|asc))?\s*(,|$))+(?<!,)$', re.I)
|
||||||
regex_object_name = re.compile(r'^[a-z0-9_.]+$')
|
regex_object_name = re.compile(r'^[a-z0-9_.]+$')
|
||||||
|
|
||||||
# TODO for trunk, raise the value to 1000
|
# TODO for trunk, raise the value to 1000
|
||||||
|
|
Loading…
Reference in New Issue