This fixes the check for values' regexes to be enclosed within parentheses
(I am contributing this patch as an employee of Optiver, ready to sign a CLA)
Issue
Define a value with the regex (boo\)hoo)
Both (boo\)hoo) and boo\)hoo are valid regexes, so this should work
However, this raises a TextFSMTemplateError instead
Background
Each value definition requires a valid regex which, as mentioned in the wiki, must be enclosed within parentheses. It is easy to check whether the regex starts with ( and ends with a non-escaped ) but the hard part is making sure that the ending ) matches the starting (.
This used to be enforced by:
Making sure the regex starts with ( and ends with )
Making sure the regex contains as many ( as )
This was not a correct check, so google#68 changed it to:
Making sure the regex starts with ( and ends with )
This fixes the check for values' regexes to be enclosed within parentheses
(I am contributing this patch as an employee of Optiver, ready to sign a CLA)
Issue
(boo\)hoo)
(boo\)hoo)
andboo\)hoo
are valid regexes, so this should workTextFSMTemplateError
insteadBackground
Each value definition requires a valid regex which, as mentioned in the wiki, must be enclosed within parentheses. It is easy to check whether the regex starts with
(
and ends with a non-escaped)
but the hard part is making sure that the ending)
matches the starting(
.This used to be enforced by:
(
and ends with)
(
as)
This was not a correct check, so google#68 changed it to:
(
and ends with)
(
as)
while ignoring any portion of the regex enclosed within non-escaped bracketsThis is still not a correct check:
(boo\)hoo)
([boo(hoo)])
Proposed fix
(
and ends with a matching, non-escaped)
is non-trivialre
library by compiling the regex