-
Notifications
You must be signed in to change notification settings - Fork 98
Description
As pointed out by https://gist.github.com/prodigysml/d07cd482214c80bfb6d3240454d2f679, this regex (introduced by 430c39e, #8) is inefficient:
Line 18 in e0c1411
| regex = r'\s*(:param)\s+(.+?)\s*:(.*)' |
It tries to match a string such as:
:param command_loader: The command loader that commands will be registered into
As shown in https://regex101.com/, a simple :param r requires 1214 steps to fail.
:param r causes catastrophic backtracking:
This is because \s+, .+? and \s* all match consecutive spaces, thus can trigger many backtrackings.
A better solution is to replace .+? with \w+ to match the parameter name so that backtrackings can be greatly reduced:
\s*(:param)\s+(\w+)\s*:(.*)

