As pointed out by https://gist.github.com/prodigysml/d07cd482214c80bfb6d3240454d2f679, this regex (introduced by 430c39e, #8) is inefficient:
|
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*:(.*)

As pointed out by https://gist.github.com/prodigysml/d07cd482214c80bfb6d3240454d2f679, this regex (introduced by 430c39e, #8) is inefficient:
knack/knack/introspection.py
Line 18 in e0c1411
It tries to match a string such as:
As shown in https://regex101.com/, a simple
:param rrequires 1214 steps to fail.:param rcauses 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: