Skip to content

Commit

Permalink
fix #1194: Regular expression catastrophic backtracking in bottle.Rou…
Browse files Browse the repository at this point in the history
…ter.rule_syntax

This backports the patch from aaee93a to the 0.12 release branch.

This fix can be validated with the following command from the issue:

    python -c "import bottle; list(bottle.Router.rule_syntax.finditer('<abc:def:' + '.' * 64 + '<'))"
  • Loading branch information
kujenga authored and defnull committed Mar 4, 2023
1 parent 18a3eb4 commit 248f901
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion bottle.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ def add_filter(self, name, func):
rule_syntax = re.compile('(\\\\*)'\
'(?:(?::([a-zA-Z_][a-zA-Z_0-9]*)?()(?:#(.*?)#)?)'\
'|(?:<([a-zA-Z_][a-zA-Z_0-9]*)?(?::([a-zA-Z_]*)'\
'(?::((?:\\\\.|[^\\\\>]+)+)?)?)?>))')
'(?::((?:\\\\.|[^\\\\>])+)?)?)?>))')

def _itertokens(self, rule):
offset, prefix = 0, ''
Expand Down

0 comments on commit 248f901

Please sign in to comment.