diff --git a/CHANGES.md b/CHANGES.md index 65dba64d..c0d7f9fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -2,6 +2,7 @@ * Update filelock 3.14.0 (8556141) to 3.15.4 (9a979df) * Update package resource API 68.2.2 (8ad627d) to 70.1.1 (222ebf9) +* Update Tornado Web Server 6.4.1 (2a0e1d1) to 6.4.2 (27b3252) * Update urllib3 2.2.1 (54d6edf) to 2.2.2 (27e2a5c) * Change add TheTVDb v4 support * Add menu Shows/"TVDb Cards" diff --git a/lib/tornado/__init__.py b/lib/tornado/__init__.py index f542de35..91e4cdec 100644 --- a/lib/tornado/__init__.py +++ b/lib/tornado/__init__.py @@ -22,8 +22,8 @@ # is zero for an official release, positive for a development branch, # or negative for a release candidate or beta (after the base version # number has been incremented) -version = "6.4.1" -version_info = (6, 4, 0, 1) +version = "6.4.2" +version_info = (6, 4, 2, 0) import importlib import typing diff --git a/lib/tornado/httputil.py b/lib/tornado/httputil.py index 9ce992d8..ebdc8059 100644 --- a/lib/tornado/httputil.py +++ b/lib/tornado/httputil.py @@ -1057,15 +1057,20 @@ def qs_to_qsl(qs: Dict[str, List[AnyStr]]) -> Iterable[Tuple[str, AnyStr]]: yield (k, v) -_OctalPatt = re.compile(r"\\[0-3][0-7][0-7]") -_QuotePatt = re.compile(r"[\\].") -_nulljoin = "".join +_unquote_sub = re.compile(r"\\(?:([0-3][0-7][0-7])|(.))").sub + + +def _unquote_replace(m: re.Match) -> str: + if m[1]: + return chr(int(m[1], 8)) + else: + return m[2] def _unquote_cookie(s: str) -> str: """Handle double quotes and escaping in cookie values. - This method is copied verbatim from the Python 3.5 standard + This method is copied verbatim from the Python 3.13 standard library (http.cookies._unquote) so we don't have to depend on non-public interfaces. """ @@ -1086,30 +1091,7 @@ def _unquote_cookie(s: str) -> str: # \012 --> \n # \" --> " # - i = 0 - n = len(s) - res = [] - while 0 <= i < n: - o_match = _OctalPatt.search(s, i) - q_match = _QuotePatt.search(s, i) - if not o_match and not q_match: # Neither matched - res.append(s[i:]) - break - # else: - j = k = -1 - if o_match: - j = o_match.start(0) - if q_match: - k = q_match.start(0) - if q_match and (not o_match or k < j): # QuotePatt matched - res.append(s[i:k]) - res.append(s[k + 1]) - i = k + 2 - else: # OctalPatt matched - res.append(s[i:j]) - res.append(chr(int(s[j + 1 : j + 4], 8))) - i = j + 4 - return _nulljoin(res) + return _unquote_sub(_unquote_replace, s) def parse_cookie(cookie: str) -> Dict[str, str]: