From: Remi Rampin Date: Fri, 4 Oct 2019 01:32:04 +0000 (-0400) Subject: Fix unescaping of regex routes X-Git-Tag: v6.1.0b1~52^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F2745%2Fhead;p=thirdparty%2Ftornado.git Fix unescaping of regex routes Previously, only the part before the first '(' would be correctly unescaped. --- diff --git a/tornado/routing.py b/tornado/routing.py index a35ac3483..e137a7284 100644 --- a/tornado/routing.py +++ b/tornado/routing.py @@ -627,7 +627,13 @@ class PathMatches(Matcher): if ")" in fragment: paren_loc = fragment.index(")") if paren_loc >= 0: - pieces.append("%s" + fragment[paren_loc + 1 :]) + try: + unescaped_fragment = re_unescape(fragment[paren_loc + 1 :]) + except ValueError: + # If we can't unescape part of it, we can't + # reverse this url. + return (None, None) + pieces.append("%s" + unescaped_fragment) else: try: unescaped_fragment = re_unescape(fragment)