Script 'mail_helper' called by obssrc
Hello community,
here is the log from the commit of package python-tornado6 for openSUSE:Factory
checked in at 2026-11-25 16:11:34
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/python-tornado6 (Old)
and /work/SRC/openSUSE:Factory/.python-tornado6.new.1340718 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "python-tornado6"
Wed Nov 25 16:11:34 2026 rev:30 rq:1400235 version:6.6.1
Changes:
--------
--- /work/SRC/openSUSE:Factory/python-tornado6/python-tornado6.changes
2026-11-05 18:20:03.034013305 +0100
+++
/work/SRC/openSUSE:Factory/.python-tornado6.new.1340718/python-tornado6.changes
2026-11-25 16:11:49.531480142 +0100
@@ -1,0 +2,25 @@
+Wed Nov 18 13:49:32 UTC 2026 - Christopher Hofmann <[email protected]>
+
+- Update to 6.6.1:
+ Security Fixes:
+ * ``StaticFileHandler`` will no longer serve NTFS alternate data streams as
if they were regular
+ files on Windows.
+ * ``SimpleAsyncHTTPClient`` no longer hangs and leaks resources when
processing a redirect to
+ URL schemes other than ``http`` and ``https``.
+ * Parsing of percent-encoded data in URLs is much more efficient, preventing
potential
+ denial-of-service attacks.
+ * Additional forms of open redirects in ``RedirectHandler`` have been fixed
(in addition to
+ the ones fixed in 6.6.0) (CVE-2026-126347)
+ * Open redirects in ``@addslash`` and ``@removeslash`` have been fixed.
+
+ Deprecation notice:
+ * HTTP header parsing currently supports both CRLF and LF-only line endings.
LF-only line endings
+ are already deprecated and slated for removal in Tornado 7.0. This change
is being rescheduled
+ to Tornado 6.7.
+
+ Bug Fixes:
+ * Certain patterns that worked with ``RedirectHandler`` in Tornado 6.5 and
before did not work
+ correctly in Tornado 6.6.0. This was an unintended regression and the
original behavior has
+ been restored.
+
+-------------------------------------------------------------------
Old:
----
tornado-6.6.tar.gz
New:
----
tornado-6.6.1.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ python-tornado6.spec ++++++
--- /var/tmp/diff_new_pack.AqKDUa/_old 2026-11-25 16:11:50.566523997 +0100
+++ /var/tmp/diff_new_pack.AqKDUa/_new 2026-11-25 16:11:50.567524039 +0100
@@ -18,7 +18,7 @@
%{?sle15_python_module_pythons}
Name: python-tornado6
-Version: 6.6
+Version: 6.6.1
Release: 0
Summary: Open source version of scalable, non-blocking web server that
power FriendFeed
License: Apache-2.0
++++++ tornado-6.6.tar.gz -> tornado-6.6.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/PKG-INFO new/tornado-6.6.1/PKG-INFO
--- old/tornado-6.6/PKG-INFO 2026-10-21 16:56:16.032111400 +0200
+++ new/tornado-6.6.1/PKG-INFO 2026-11-09 21:45:17.797140800 +0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: tornado
-Version: 6.6
+Version: 6.6.1
Summary: Tornado is a Python web framework and asynchronous networking
library, originally developed at FriendFeed.
Home-page: http://www.tornadoweb.org/
Author: Facebook
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/docs/releases/v6.6.1.rst
new/tornado-6.6.1/docs/releases/v6.6.1.rst
--- old/tornado-6.6/docs/releases/v6.6.1.rst 1970-01-01 01:00:00.000000000
+0100
+++ new/tornado-6.6.1/docs/releases/v6.6.1.rst 2026-11-09 21:45:15.761728000
+0100
@@ -0,0 +1,32 @@
+What's new in Tornado 6.6.1
+===========================
+
+Nov 9, 2026
+-----------
+
+Security Fixes
+~~~~~~~~~~~~~~
+
+- ``StaticFileHandler`` will no longer serve NTFS alternate data streams as if
they were regular
+ files on Windows.
+- ``SimpleAsyncHTTPClient`` no longer hangs and leaks resources when
processing a redirect to
+ URL schemes other than ``http`` and ``https``.
+- Parsing of percent-encoded data in URLs is much more efficient, preventing
potential
+ denial-of-service attacks.
+- Additional forms of open redirects in ``RedirectHandler`` have been fixed
(in addition to
+ the ones fixed in 6.6.0)
+- Open redirects in ``@addslash`` and ``@removeslash`` have been fixed.
+
+Deprecation notice
+~~~~~~~~~~~~~~~~~~
+
+- HTTP header parsing currently supports both CRLF and LF-only line endings.
LF-only line endings
+ are already deprecated and slated for removal in Tornado 7.0. This change is
being rescheduled
+ to Tornado 6.7.
+
+Bug Fixes
+~~~~~~~~~
+
+- Certain patterns that worked with ``RedirectHandler`` in Tornado 6.5 and
before did not work
+ correctly in Tornado 6.6.0. This was an unintended regression and the
original behavior has
+ been restored.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/docs/releases.rst
new/tornado-6.6.1/docs/releases.rst
--- old/tornado-6.6/docs/releases.rst 2026-10-21 16:56:13.385223200 +0200
+++ new/tornado-6.6.1/docs/releases.rst 2026-11-09 21:45:15.758904700 +0100
@@ -4,6 +4,7 @@
.. toctree::
:maxdepth: 2
+ releases/v6.6.1
releases/v6.6.0
releases/v6.5.10
releases/v6.5.9
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/__init__.py
new/tornado-6.6.1/tornado/__init__.py
--- old/tornado-6.6/tornado/__init__.py 2026-10-21 16:56:13.391448300 +0200
+++ new/tornado-6.6.1/tornado/__init__.py 2026-11-09 21:45:15.764544500
+0100
@@ -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.6"
-version_info = (6, 6, 0, 0)
+version = "6.6.1"
+version_info = (6, 6, 1, 0)
import importlib
import typing
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/escape.py
new/tornado-6.6.1/tornado/escape.py
--- old/tornado-6.6/tornado/escape.py 2026-10-21 16:56:13.391713900 +0200
+++ new/tornado-6.6.1/tornado/escape.py 2026-11-09 21:45:15.764787400 +0100
@@ -25,6 +25,7 @@
docstrings on each function for details.
"""
+import binascii
import html
import json
import re
@@ -168,6 +169,49 @@
return unquote(to_basestring(value), encoding=encoding)
+# Swaps % and = so that binascii.a2b_qp, which decodes =XX in C, can decode
+# percent escapes.
+_PERCENT_EQUALS_SWAP = bytes.maketrans(b"%=", b"=%")
+
+
+def _unquote_to_bytes(data: bytes) -> bytes:
+ """Equivalent to `urllib.parse.unquote_to_bytes`, but fast.
+
+ The standard library's version (as of Python 3.14) creates an object for
+ every ``%`` in its input, which makes large escaped bodies cost many
+ times their size in memory and microseconds per byte. This does the
+ work in a few passes over the data in C.
+ """
+ if b"%" not in data:
+ return data
+ # After the swap, escapes are =XX and literal = signs are %, which
+ # a2b_qp passes through. a2b_qp also passes through = that is not
+ # followed by two hex digits (an invalid escape), and the final swap
+ # turns those back into %.
+ data = data.translate(_PERCENT_EQUALS_SWAP)
+ # Escapes that decode to % or = would be swapped too, so exchange them
+ # first. Each token is three bytes with = only at the start, so these
+ # replacements can't create or break other tokens; =3d is free to use
+ # as a placeholder once it has been normalized away.
+ data = (
+ data.replace(b"=3d", b"=3D")
+ .replace(b"=25", b"=3d")
+ .replace(b"=3D", b"=25")
+ .replace(b"=3d", b"=3D")
+ )
+ # a2b_qp decodes == as =, consuming both. The first = of a pair is
+ # always an invalid escape, so make it explicit. Two passes are needed
+ # because replace() doesn't see the pair formed where two matches meet.
+ data = data.replace(b"==", b"=3D=").replace(b"==", b"=3D=")
+ # a2b_qp treats = before a line break or at the end as a soft line break
+ # and drops it (after =\r, everything up to the next \n). Those are
+ # invalid escapes too.
+ data = data.replace(b"=\n", b"=3D\n").replace(b"=\r", b"=3D\r")
+ if data.endswith(b"="):
+ data += b"3D"
+ return binascii.a2b_qp(data).translate(_PERCENT_EQUALS_SWAP)
+
+
def parse_qs_bytes(
qs: str | bytes,
keep_blank_values: bool = False,
@@ -185,22 +229,26 @@
.. versionadded:: 6.5.8
The ``max_num_fields`` argument. ValueError is raised if this limit is
exceeded.
"""
- # This is gross, but python3 doesn't give us another way.
- # Latin1 is the universal donor of character encodings.
- if isinstance(qs, bytes):
- qs = qs.decode("latin1")
- result = urllib.parse.parse_qs(
- qs,
- keep_blank_values,
- strict_parsing,
- encoding="latin1",
- errors="strict",
- max_num_fields=max_num_fields,
- )
- encoded = {}
- for k, v in result.items():
- encoded[k] = [i.encode("latin1") for i in v]
- return encoded
+ # This follows urllib.parse.parse_qsl, with a faster unquote.
+ if isinstance(qs, str):
+ qs = qs.encode("latin1")
+ result: dict[str, list[bytes]] = {}
+ if not qs:
+ return result
+ if max_num_fields is not None and 1 + qs.count(b"&") > max_num_fields:
+ raise ValueError("Max number of fields exceeded")
+ for field in qs.split(b"&"):
+ if not field and not strict_parsing:
+ continue
+ name, has_eq, value = field.partition(b"=")
+ if not has_eq and strict_parsing:
+ raise ValueError("bad query field: %r" % (field,))
+ if value or keep_blank_values:
+ key = _unquote_to_bytes(name.replace(b"+", b" ")).decode("latin1")
+ result.setdefault(key, []).append(
+ _unquote_to_bytes(value.replace(b"+", b" "))
+ )
+ return result
_UTF8_TYPES = (bytes, type(None))
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/http1connection.py
new/tornado-6.6.1/tornado/http1connection.py
--- old/tornado-6.6/tornado/http1connection.py 2026-10-21 16:56:13.392223100
+0200
+++ new/tornado-6.6.1/tornado/http1connection.py 2026-11-09
21:45:15.764787400 +0100
@@ -653,7 +653,7 @@
# Proxies sometimes cause Content-Length headers to get
# duplicated. If all the values are identical then we can
# use them but if they differ it's an error.
- pieces = re.split(r",\s*", headers["Content-Length"])
+ pieces = re.split(r",[ \t]*", headers["Content-Length"])
if any(i != pieces[0] for i in pieces):
raise httputil.HTTPInputError(
"Multiple unequal Content-Lengths: %r"
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/httputil.py
new/tornado-6.6.1/tornado/httputil.py
--- old/tornado-6.6/tornado/httputil.py 2026-10-21 16:56:13.392223100 +0200
+++ new/tornado-6.6.1/tornado/httputil.py 2026-11-09 21:45:15.764787400
+0100
@@ -252,6 +252,10 @@
Support for line folding was removed due to security/DoS concerns.
This removal
was ahead of the original removal schedule announced for Tornado
7.0.
Support for LF without CR remains until Tornado 7.0.
+
+ .. versionchanged:: 6.6.1
+ Parsing of header lines terminated by LF without CR will be removed
in Tornado 6.7
+ instead of 7.0 as previously documented.
"""
if m := re.search(r"\r?\n$", line):
# RFC 9112 section 2.2: a recipient MAY recognize a single LF as a
line
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/simple_httpclient.py
new/tornado-6.6.1/tornado/simple_httpclient.py
--- old/tornado-6.6/tornado/simple_httpclient.py 2026-10-21
16:56:13.394223200 +0200
+++ new/tornado-6.6.1/tornado/simple_httpclient.py 2026-11-09
21:45:15.766970200 +0100
@@ -14,6 +14,7 @@
from typing import Any, Optional, Type
from tornado import gen, httputil, version
+from tornado.concurrent import Future
from tornado.escape import _unicode
from tornado.http1connection import HTTP1Connection, HTTP1ConnectionParameters
from tornado.httpclient import (
@@ -700,7 +701,25 @@
self._release()
assert self.client is not None
fut = self.client.fetch(new_request, raise_error=False)
- fut.add_done_callback(lambda f: final_callback(f.result()))
+
+ def on_redirect_done(f: "Future[HTTPResponse]") -> None:
+ try:
+ response = f.result()
+ except Exception as e:
+ # Errors other than HTTP status codes (such as a
+ # Location with an unsupported scheme) are raised even
+ # with raise_error=False. Pass them on, or the original
+ # fetch would never finish.
+ response = HTTPResponse(
+ new_request,
+ 599,
+ error=e,
+ request_time=self.io_loop.time() - self.start_time,
+ start_time=self.start_wall_time,
+ )
+ final_callback(response)
+
+ fut.add_done_callback(on_redirect_done)
self._on_end_request()
return
if self.request.streaming_callback:
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/escape_test.py
new/tornado-6.6.1/tornado/test/escape_test.py
--- old/tornado-6.6/tornado/test/escape_test.py 2026-10-21 16:56:13.395223100
+0200
+++ new/tornado-6.6.1/tornado/test/escape_test.py 2026-11-09
21:45:15.767884700 +0100
@@ -1,10 +1,14 @@
from collections.abc import Callable
from typing import Any
+import urllib.parse
+
import tornado
from tornado.escape import (
+ _unquote_to_bytes,
json_decode,
json_encode,
+ parse_qs_bytes,
recursive_unicode,
squeeze,
to_unicode,
@@ -344,3 +348,51 @@
self.assertEqual(recursive_unicode(tests["list"]), ["foo", "bar"])
self.assertEqual(recursive_unicode(tests["tuple"]), ("foo", "bar"))
self.assertEqual(recursive_unicode(tests["bytes"]), "foo")
+
+ def test_unquote_to_bytes(self):
+ # Cases where binascii.a2b_qp, which _unquote_to_bytes uses, differs
+ # from percent-decoding.
+ for data in [
+ b"",
+ b"a=b",
+ b"%41%3d%3D%25",
+ b"%%41",
+ b"%%%",
+ b"%zz%4",
+ b"%",
+ b"a%",
+ b"%\r\nb",
+ b"%\rb\nc",
+ b"%\n",
+ b"=%41=",
+ b"a \r\n%20\t",
+ bytes(range(256)),
+ ]:
+ with self.subTest(data):
+ self.assertEqual(
+ _unquote_to_bytes(data),
urllib.parse.unquote_to_bytes(data)
+ )
+
+ def test_parse_qs_bytes(self):
+ self.assertEqual(
+ parse_qs_bytes(b"a=1&b=%41+%2B&a=2&&c&d=", keep_blank_values=True),
+ {"a": [b"1", b"2"], "b": [b"A +"], "c": [b""], "d": [b""]},
+ )
+ self.assertEqual(parse_qs_bytes("%E9=%E9"), {"\xe9": [b"\xe9"]})
+ self.assertEqual(parse_qs_bytes(b"c&d=", keep_blank_values=False), {})
+ with self.assertRaises(ValueError):
+ parse_qs_bytes(b"a=1&&b=2", strict_parsing=True)
+ with self.assertRaises(ValueError):
+ parse_qs_bytes(b"a=1&b=2", max_num_fields=1)
+
+ @skipNotCPython
+ def test_unquote_memory_budget(self):
+ # The standard library's unquote creates an object per %, about 20
+ # bytes per input byte (more on Python 3.11). Lone % signs are the
+ # worst case here (about 8 as of 2026-10).
+ for data in [b"%41" * 100_000, b"%" * 300_000]:
+ with self.subTest(data[:3]):
+ with assert_memory_budget(
+ len(data), max_ratio=12, msg="unquote uses too much memory"
+ ):
+ parse_qs_bytes(b"a=" + data)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/httpserver_test.py
new/tornado-6.6.1/tornado/test/httpserver_test.py
--- old/tornado-6.6/tornado/test/httpserver_test.py 2026-10-21
16:56:13.396223000 +0200
+++ new/tornado-6.6.1/tornado/test/httpserver_test.py 2026-11-09
21:45:15.768881000 +0100
@@ -601,6 +601,25 @@
self.assertEqual(400, start_line.code)
@gen_test
+ def test_content_length_list_whitespace(self):
+ # A list of identical Content-Lengths is allowed, but only HTTP
+ # whitespace (space and tab) may follow the commas, not other
+ # characters that Python considers whitespace.
+ for sep in [b"\xa0", b"\x85"]:
+ with self.subTest(sep=sep), closing(IOStream(socket.socket())) as
stream:
+ with ExpectLog(
+ gen_log, ".*Multiple unequal Content-Lengths",
level=logging.INFO
+ ):
+ yield stream.connect(("127.0.0.1", self.get_http_port()))
+ stream.write(
+ b"POST /echo HTTP/1.1\r\nHost: 127.0.0.1\r\n"
+ b"Content-Length: 5," + sep + b"5\r\n"
+ b"Connection: close\r\n\r\nhello"
+ )
+ start_line, headers, response = yield
read_stream_body(stream)
+ self.assertEqual(400, start_line.code)
+
+ @gen_test
def test_invalid_content_length(self):
# HTTP only allows decimal digits in content-length. Make sure we don't
# accept anything else, with special attention to things accepted by
the
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/httputil_test.py
new/tornado-6.6.1/tornado/test/httputil_test.py
--- old/tornado-6.6/tornado/test/httputil_test.py 2026-10-21
16:56:13.396223000 +0200
+++ new/tornado-6.6.1/tornado/test/httputil_test.py 2026-11-09
21:45:15.768881000 +0100
@@ -817,13 +817,20 @@
# escape sequences in a cookie value was quadratic. (Only the r"\\"
# case reproduces it on 6.4.1; r"\134" is here for symmetry with
# test_unquote_large.)
+ #
+ # 6.4.1 measures a ratio of about 100 on CPython and 60-100 on PyPy.
+ # The fixed version measures about 10 on CPython, but this test
+ # allocates heavily for each byte of input, and PyPy's ratio depends
+ # on how that compares to its nursery and CPU caches: as of 2026-10
+ # it measures 11-24 depending on PYPY_GC_NURSERY, so the usual limit
+ # of 20 is too tight.
for encoded in r"\\", r"\134":
with self.subTest(encoded):
assert_linear_scaling(
lambda n: parse_cookie('a="b=' + encoded * n + '"'),
1_000,
10_000,
- max_ratio=20,
+ max_ratio=40,
msg="Cookie unquoting is not linear",
)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/property_test.py
new/tornado-6.6.1/tornado/test/property_test.py
--- old/tornado-6.6/tornado/test/property_test.py 2026-10-21
16:56:13.397223200 +0200
+++ new/tornado-6.6.1/tornado/test/property_test.py 2026-11-09
21:45:15.768881000 +0100
@@ -15,6 +15,7 @@
import os
import unittest
import unittest.mock
+import urllib.parse
import zlib
from tornado.test.util import TestCase
@@ -33,6 +34,7 @@
from tornado.escape import (
+ _unquote_to_bytes,
parse_qs_bytes,
url_escape,
url_unescape,
@@ -269,6 +271,38 @@
)
self.assertEqual(parse_qs_bytes(qs, keep_blank_values=True), expected)
+ # Pieces that exercise the edge cases of _unquote_to_bytes: valid and
+ # invalid escapes, escapes of % and =, and line breaks.
+ _qs_pieces = st.sampled_from(
+ [b"%", b"=", b"&", b"+", b"a", b"2", b"5", b"3", b"D", b"d", b"f",
b"g"]
+ + [b"\r", b"\n", b" ", b"\x00", b"\xff", b"%41", b"%3d", b"%25",
b"%e9"]
+ )
+ _qs_bytes = st.lists(_qs_pieces, max_size=30).map(b"".join)
+
+ @given(_qs_bytes)
+ def test_unquote_to_bytes_matches_stdlib(self, b):
+ self.assertEqual(_unquote_to_bytes(b),
urllib.parse.unquote_to_bytes(b))
+
+ @given(_qs_bytes, st.booleans(), st.booleans())
+ def test_parse_qs_bytes_matches_stdlib(self, qs, keep_blank, strict):
+ def parse(f):
+ try:
+ return f()
+ except ValueError:
+ return "ValueError"
+
+ expected = parse(
+ lambda: {
+ k: [v.encode("latin1") for v in vs]
+ for k, vs in urllib.parse.parse_qs(
+ qs.decode("latin1"), keep_blank, strict, encoding="latin1"
+ ).items()
+ }
+ )
+ self.assertEqual(
+ parse(lambda: parse_qs_bytes(qs, keep_blank, strict)), expected
+ )
+
# Cookie names and values that browsers send unquoted: no whitespace at
# the ends, and no separators.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/simple_httpclient_test.py
new/tornado-6.6.1/tornado/test/simple_httpclient_test.py
--- old/tornado-6.6/tornado/test/simple_httpclient_test.py 2026-10-21
16:56:13.397223200 +0200
+++ new/tornado-6.6.1/tornado/test/simple_httpclient_test.py 2026-11-09
21:45:15.769728000 +0100
@@ -19,6 +19,7 @@
import ssl
import sys
import typing
+import urllib.parse
from contextlib import closing
from tornado import gen, version
@@ -277,6 +278,15 @@
self.assertTrue(response.effective_url.endswith("/countdown/2"))
self.assertTrue(response.headers["Location"].endswith("/countdown/1"))
+ def test_redirect_unsupported_scheme(self):
+ # A redirect that can't be followed fails the request instead of
+ # leaving it unfinished.
+ for location in ["ftp://example.com/", "h:5"]:
+ with self.subTest(location):
+ with self.assertRaises(ValueError) as cm:
+ self.fetch("/redirect?url=" + urllib.parse.quote(location))
+ self.assertIn("Unsupported url scheme", str(cm.exception))
+
def test_header_reuse(self):
# Apps may reuse a headers object if they are only passing in constant
# headers like user-agent. The header object should not be modified.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/util.py
new/tornado-6.6.1/tornado/test/util.py
--- old/tornado-6.6/tornado/test/util.py 2026-10-21 16:56:13.398223200
+0200
+++ new/tornado-6.6.1/tornado/test/util.py 2026-11-09 21:45:15.770728000
+0100
@@ -228,6 +228,38 @@
iterations *= 2
[email protected]
+def _gc_disabled() -> Generator[None, None, None]:
+ """Disable the garbage collector for the measurements in
+ `assert_linear_scaling`, on CPython only.
+
+ CPython's collections are triggered by allocation counts, and their cost
+ depends on the number of live objects, so leaving the collector enabled
+ charges an arbitrary and unevenly distributed cost to whichever operation
+ happens to trigger one. Reference counting still frees almost everything
+ while it is disabled.
+
+ PyPy has no reference counting, and `gc.disable` there only stops major
+ collections: minor collections keep promoting objects that survive the
+ nursery into an old generation that is never collected. Memory then
+ grows throughout the measurement (by about 1MB per call of the cookie
+ unquoting test at ``n=10_000``), and the larger input, which promotes
+ more, pays disproportionately for touching fresh memory. This has been
+ seen to inflate a linear ratio of about 10 to 20 or more, and in some
+ configurations to over 80, so on PyPy the collector is left alone.
+ """
+ if platform.python_implementation() != "CPython":
+ yield
+ return
+ gc_was_enabled = gc.isenabled()
+ gc.disable()
+ try:
+ yield
+ finally:
+ if gc_was_enabled:
+ gc.enable()
+
+
def assert_linear_scaling(
func: Callable[[int], object],
n1: int,
@@ -255,10 +287,8 @@
* Only CPU time used by this process is measured (see `_time_calls`).
* Each operation is repeated enough times to be measured reliably (see
`_MIN_MEASUREMENT_TIME`).
- * The garbage collector is disabled during the measurements. Collections
- are triggered by allocation counts, and their cost depends on the
- number of live objects, so leaving it enabled charges an arbitrary and
- unevenly distributed cost to whichever operation happens to trigger one.
+ * On CPython, the garbage collector is disabled during the measurements
+ (see `_gc_disabled`).
* Each size is measured ``rounds`` times and the lowest result is used.
Interference can only make an operation look slower, never faster, so
the minimum is a much more stable estimate of its cost than the mean.
@@ -275,23 +305,21 @@
factor larger than the margin between ``max_ratio`` and the ratio of a
real change in complexity class. Linear code often measures a little
over ``n2 / n1``, so a threshold of half of ``max_ratio`` would send
- most passing tests to the slow measurement.)
+ most passing tests to the slow measurement.) The quick measurement is
+ itself preceded by a warmup of the same length, because the first calls
+ are systematically slower, especially on PyPy before its JIT has
+ compiled the code. That inflates the time for ``n1``, which is measured
+ first, and can hide even a quadratic regression.
"""
- gc_was_enabled = gc.isenabled()
- gc.disable()
- try:
+ with _gc_disabled():
+ _calibrate(func, n1, _QUICK_MEASUREMENT_TIME)
iterations1, elapsed1 = _calibrate(func, n1, _QUICK_MEASUREMENT_TIME)
iterations2, elapsed2 = _calibrate(func, n2, _QUICK_MEASUREMENT_TIME)
- finally:
- if gc_was_enabled:
- gc.enable()
if (elapsed2 / iterations2) / (elapsed1 / iterations1) <= max_ratio * 0.75:
return
t1 = t2 = 0.0
for _ in range(attempts):
- gc_was_enabled = gc.isenabled()
- gc.disable()
- try:
+ with _gc_disabled():
iterations1, elapsed1 = _calibrate(func, n1)
iterations2, elapsed2 = _calibrate(func, n2)
t1 = elapsed1 / iterations1
@@ -299,9 +327,6 @@
for _ in range(rounds - 1):
t1 = min(t1, _time_calls(func, n1, iterations1) / iterations1)
t2 = min(t2, _time_calls(func, n2, iterations2) / iterations2)
- finally:
- if gc_was_enabled:
- gc.enable()
if t2 / t1 <= max_ratio:
return
raise AssertionError(
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/test/web_test.py
new/tornado-6.6.1/tornado/test/web_test.py
--- old/tornado-6.6/tornado/test/web_test.py 2026-10-21 16:56:13.398223200
+0200
+++ new/tornado-6.6.1/tornado/test/web_test.py 2026-11-09 21:45:15.770728000
+0100
@@ -2094,6 +2094,62 @@
self.assertEqual(response.code, 403)
[email protected](os.name != "nt", "NTFS alternate data streams are
Windows-only")
+class StaticFileAlternateDataStreamTest(WebTestCase):
+ """On Windows, ``file.txt:name`` names an NTFS alternate data stream of
+ ``file.txt``. Streams are not files in the static directory and must not
+ be served, nor read by ``get_version``.
+ """
+
+ def setUp(self):
+ self.tmpdir = tempfile.mkdtemp()
+ self.addCleanup(shutil.rmtree, self.tmpdir)
+ self.public = os.path.join(self.tmpdir, "public.txt")
+ with open(self.public, "wb") as f:
+ f.write(b"public")
+ try:
+ with open(self.public + ":secret", "wb") as f:
+ f.write(b"secret")
+ except OSError:
+ # Not every filesystem (e.g. FAT, some network shares) supports
+ # alternate data streams.
+ self.skipTest("filesystem does not support alternate data streams")
+ StaticFileHandler.reset()
+ self.addCleanup(StaticFileHandler.reset)
+ super().setUp()
+
+ def get_handlers(self):
+ return [("/static/(.*)", StaticFileHandler, dict(path=self.tmpdir))]
+
+ def get_app_kwargs(self):
+ return dict()
+
+ def test_public_file(self):
+ response = self.fetch("/static/public.txt")
+ self.assertEqual(response.code, 200)
+ self.assertEqual(response.body, b"public")
+
+ def test_alternate_data_stream(self):
+ for path in [
+ "public.txt:secret",
+ "public.txt%3Asecret",
+ "public.txt:secret:$DATA",
+ "public.txt::$DATA",
+ ]:
+ with self.subTest(path=path):
+ with ExpectLog(gen_log, ".*is not a file"):
+ response = self.fetch("/static/" + path)
+ self.assertEqual(response.code, 403)
+ self.assertNotIn(b"secret", response.body)
+
+ def test_alternate_data_stream_version(self):
+ with self.assertRaises(HTTPError) as cm:
+ StaticFileHandler.get_version(
+ dict(static_path=self.tmpdir), "public.txt:secret"
+ )
+ self.assertEqual(cm.exception.status_code, 403)
+
+
class StaticFileSymlinkedRootTest(WebTestCase):
"""The root itself may be reached through a symlink; that must not make
every request look like an escape.
@@ -4222,7 +4278,13 @@
def get(self):
pass
- return [("/removeslash/", RemoveSlashHandler), ("/addslash",
AddSlashHandler)]
+ return [
+ ("/removeslash/", RemoveSlashHandler),
+ ("/addslash", AddSlashHandler),
+ # Catch-all routes can see paths that start with two slashes.
+ (r"/+rem.*", RemoveSlashHandler),
+ (r"/+add.*", AddSlashHandler),
+ ]
def test_removeslash(self):
response = self.fetch("/removeslash/", follow_redirects=False)
@@ -4242,6 +4304,20 @@
self.assertEqual(response.code, 301)
self.assertEqual(response.headers["Location"], "/addslash/?foo=bar")
+ def test_no_protocol_relative_redirect(self):
+ # Redirecting to //example.com would be an open redirect.
+ for path in [
+ "//add.example.com",
+ "///add.example.com",
+ "//rem.example.com/",
+ "//rem.example.com//",
+ "///rem.example.com/x/",
+ ]:
+ with self.subTest(path=path):
+ with ExpectLog(gen_log, ".*cannot redirect path"):
+ response = self.fetch(path, follow_redirects=False)
+ self.assertEqual(response.code, 403)
+
class CacheTest(WebTestCase):
def get_handlers(self):
@@ -4376,6 +4452,9 @@
("/src2", WebRedirectHandler, {"url": "/dst2?foo=bar"}),
(r"/any/(.*)", WebRedirectHandler, {"url": "{0}"}),
(r"/moved(.*)", WebRedirectHandler, {"url":
"https://example.com{0}"}),
+ (r"/(.*)/target", WebRedirectHandler, {"url": "/{0}/destination"}),
+ (r"/hostless/(.*)", WebRedirectHandler, {"url": "https://{0}"}),
+ (r"/schemeonly/(.*)", WebRedirectHandler, {"url": "https:{0}"}),
(r"/(.*?)/(.*?)/(.*)", WebRedirectHandler, {"url":
"/{1}/{0}/{2}"}),
]
@@ -4414,7 +4493,81 @@
# Browsers treat backslashes like slashes and ignore tabs and newlines,
# so these variants are also protocol-relative. Path arguments are
# url-decoded, so they can be smuggled in with percent-encoding.
- for path in ["/a/%5Cexample.com/b", "/a/%09/example.com/b"]:
+ # Browsers also skip any number of slashes before the host, so three
+ # or more slashes are just as protocol-relative as two.
+ for path in [
+ "/a/%5Cexample.com/b",
+ "/a/%09/example.com/b",
+ "/a///example.com/b",
+ "/a////example.com/b",
+ "/a/%2F%2F%5Cexample.com/b",
+ ]:
+ with self.subTest(path=path):
+ with ExpectLog(
+ gen_log, ".*Redirect URL cannot change the scheme or
netloc"
+ ):
+ response = self.fetch(path, follow_redirects=False)
+ self.assertEqual(response.code, 400)
+
+ def test_substitution_after_first_slash(self):
+ # The substitution comes right after the first slash, so it can add a
+ # second slash (or more) but that must not reject ordinary values.
+ for path, location in [
+ ("/ok/target", "/ok/destination"),
+ ("/a/b/target", "/a/b/destination"),
+ ("/ok/target?x=1", "/ok/destination?x=1"),
+ ]:
+ with self.subTest(path=path):
+ response = self.fetch(path, follow_redirects=False)
+ self.assertEqual(response.code, 301)
+ self.assertEqual(response.headers["Location"], location)
+ for path in [
+ "/%2Fevil.com/target",
+ "/%2F%2Fevil.com/target",
+ "/%5C%5Cevil.com/target",
+ "/%09//evil.com/target",
+ "/%2Fevil.com/target?x=1",
+ ]:
+ with self.subTest(path=path):
+ with ExpectLog(
+ gen_log, ".*Redirect URL cannot change the scheme or
netloc"
+ ):
+ response = self.fetch(path, follow_redirects=False)
+ self.assertEqual(response.code, 400)
+
+ def test_invalid_characters(self):
+ # These would otherwise be a 500 error from set_header.
+ for path in ["/any/%0Afoo", "/any/a%00b", "/any/%2F%2F%5B?x=1"]:
+ with self.subTest(path=path):
+ with ExpectLog(gen_log, ".*Redirect URL (contains
invalid|cannot)"):
+ response = self.fetch(path, follow_redirects=False)
+ self.assertEqual(response.code, 400)
+
+ def test_non_ascii(self):
+ # Non-ASCII characters (including ones that look like slashes) are
+ # fine, and are sent as UTF-8.
+ for value in ["\u00e9", "\u4e2d\u6587", "\uff0f\uff0fexample.com"]:
+ with self.subTest(value=value):
+ response = self.fetch(
+ "/any/" + urllib.parse.quote(value), follow_redirects=False
+ )
+ self.assertEqual(response.code, 301)
+ # Header values are decoded as latin1.
+ self.assertEqual(
+ response.headers["Location"], utf8(value).decode("latin1")
+ )
+
+ def test_substitution_in_host(self):
+ # Substitutions cannot supply the host, even with extra slashes
+ # (which urlsplit and browsers disagree about) or a query string
+ # (which some versions of urlunsplit turn into extra slashes).
+ for path in [
+ "/hostless/evil.com",
+ "/hostless//evil.com",
+ "/schemeonly/evil.com",
+ "/schemeonly/evil.com?x=1",
+ "/schemeonly////evil.com",
+ ]:
with self.subTest(path=path):
with ExpectLog(
gen_log, ".*Redirect URL cannot change the scheme or
netloc"
@@ -4443,6 +4596,7 @@
for path in [
"/any/https://evil.com/",
"/any/%5C%5Cevil.com/",
+ "/any////evil.com/",
"/any/javascript:alert(1)",
]:
with self.subTest(path=path):
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado/web.py
new/tornado-6.6.1/tornado/web.py
--- old/tornado-6.6/tornado/web.py 2026-10-21 16:56:13.399223000 +0200
+++ new/tornado-6.6.1/tornado/web.py 2026-11-09 21:45:15.771728000 +0100
@@ -72,6 +72,7 @@
import re
import socket
import stat
+import string
import sys
import threading
import time
@@ -2189,6 +2190,12 @@
if self.request.path.endswith("/"):
if self.request.method in ("GET", "HEAD"):
uri = self.request.path.rstrip("/")
+ if _is_protocol_relative(uri):
+ # A path like //example.com// would otherwise redirect
+ # to another host.
+ raise HTTPError(
+ 403, "cannot redirect path with two initial slashes"
+ )
if uri: # don't try to redirect '/' to ''
if self.request.query:
uri += "?" + self.request.query
@@ -2218,6 +2225,12 @@
if not self.request.path.endswith("/"):
if self.request.method in ("GET", "HEAD"):
uri = self.request.path + "/"
+ if _is_protocol_relative(uri):
+ # A path like //example.com would otherwise redirect to
+ # another host.
+ raise HTTPError(
+ 403, "cannot redirect path with two initial slashes"
+ )
if self.request.query:
uri += "?" + self.request.query
self.redirect(uri, permanent=True)
@@ -2848,23 +2861,40 @@
def get(self, *args: Any, **kwargs: Any) -> None:
to_url = self._url.format(*args, **kwargs)
# The scheme and netloc of the redirect must come from the template,
not
- # from the request. Find out what they are by formatting the template
- # with a placeholder that cannot extend a scheme or netloc.
- expected_url = self._url.format(
- *("/" for _ in args), **{k: "/" for k in kwargs}
- )
+ # from the request. Find out what they are from the part of the
template
+ # before the first substitution. (Formatting the whole template with a
+ # placeholder doesn't work: whatever the placeholder is, it can turn
the
+ # template into a URL with a different netloc, as "/" does for
"/{0}/b".)
+ prefix = ""
+ has_substitution = False
+ for literal, field, _, _ in string.Formatter().parse(self._url):
+ prefix += literal
+ if field is not None:
+ has_substitution = True
+ break
try:
- unchanged = _scheme_and_netloc(to_url) ==
_scheme_and_netloc(expected_url)
+ if self.request.query_arguments:
+ # Query arguments are added before the check because url_concat
+ # can change the rest of the URL.
+ # TODO: figure out typing for the next line.
+ to_url = httputil.url_concat(
+ to_url,
+ list(httputil.qs_to_qsl(self.request.query_arguments)), #
type: ignore
+ )
+ scheme, netloc = _scheme_and_netloc(prefix)
+ unchanged = _scheme_and_netloc(to_url) == (scheme, netloc)
+ if has_substitution and scheme in ("http", "https") and not netloc:
+ # The host would come entirely from a substitution (or a
+ # browser would find one where urlsplit doesn't, as in
+ # "https:///host").
+ unchanged = False
except ValueError:
unchanged = False
if not unchanged:
raise HTTPError(400, "Redirect URL cannot change the scheme or
netloc")
- if self.request.query_arguments:
- # TODO: figure out typing for the next line.
- to_url = httputil.url_concat(
- to_url,
- list(httputil.qs_to_qsl(self.request.query_arguments)), #
type: ignore
- )
+ if httputil._FORBIDDEN_HEADER_CHARS_RE.search(to_url):
+ # Let this be a 400 rather than a 500 from set_header.
+ raise HTTPError(400, "Redirect URL contains invalid characters")
self.redirect(to_url, permanent=self._permanent)
@@ -3306,6 +3336,16 @@
# the requested path so a request to root/ will match.
if not (absolute_path + os.path.sep).startswith(root):
raise HTTPError(403, "%s is not in root static directory",
path_message)
+ if os.name == "nt" and ":" in absolute_path[len(root) :]:
+ # On Windows, "file.txt:name" names the NTFS alternate data
+ # stream "name" of file.txt. abspath, stat and open all accept
+ # this syntax, so without this check the stream (which may
+ # hold data such as the Zone.Identifier recorded for downloaded
+ # files) would be served as if it were a file in the static
+ # directory. A colon can never appear in an ordinary Windows
+ # file name, so rejecting it anywhere below the root (the root
+ # itself contains the drive letter's colon) loses nothing.
+ raise HTTPError(403, "%s is not a file", path_message)
return root
@staticmethod
@@ -4251,5 +4291,10 @@
Both are empty for a relative URL. Raises `ValueError` for some malformed
URLs.
"""
- parts = urllib.parse.urlsplit(_normalize_url_like_browser(url))
+ url = _normalize_url_like_browser(url)
+ # urlsplit follows RFC 3986, in which "///example.com" has an empty netloc,
+ # but browsers resolving it against an http or https URL skip any number of
+ # slashes before the host. Collapse them so urlsplit sees the same host.
+ url = re.sub(r"^//+", "//", url)
+ parts = urllib.parse.urlsplit(url)
return parts.scheme.lower(), parts.netloc.lower()
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado.egg-info/PKG-INFO
new/tornado-6.6.1/tornado.egg-info/PKG-INFO
--- old/tornado-6.6/tornado.egg-info/PKG-INFO 2026-10-21 16:56:15.984277500
+0200
+++ new/tornado-6.6.1/tornado.egg-info/PKG-INFO 2026-11-09 21:45:17.745544700
+0100
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: tornado
-Version: 6.6
+Version: 6.6.1
Summary: Tornado is a Python web framework and asynchronous networking
library, originally developed at FriendFeed.
Home-page: http://www.tornadoweb.org/
Author: Facebook
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn'
'--exclude=.svnignore' old/tornado-6.6/tornado.egg-info/SOURCES.txt
new/tornado-6.6.1/tornado.egg-info/SOURCES.txt
--- old/tornado-6.6/tornado.egg-info/SOURCES.txt 2026-10-21
16:56:15.999592800 +0200
+++ new/tornado-6.6.1/tornado.egg-info/SOURCES.txt 2026-11-09
21:45:17.760230800 +0100
@@ -128,6 +128,7 @@
docs/releases/v6.5.8.rst
docs/releases/v6.5.9.rst
docs/releases/v6.6.0.rst
+docs/releases/v6.6.1.rst
tornado/__init__.py
tornado/__init__.pyi
tornado/_locale_data.py