Repository navigation
Port 6.6.1 commits to master branch - #3878
Merged
bdarnell merged 9 commits intoNov 9, 2026
Merged
Conversation
A redirect whose Location the client couldn't fetch (such as one with a scheme other than http or https) raised inside the callback that finishes the original request, so that request never finished, whatever its request_timeout. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TuTKdWgh56FRF7yJqaX9ug (cherry picked from commit 59f9f6b)
…bjects urllib.parse.unquote_to_bytes splits its input on every %, so a large form body made of escapes cost about 20 bytes of memory per input byte (77 on Python 3.11) and 0.4-3 microseconds per byte; lone % signs were the slowest. At the default max_body_size of 100MB, one request could use about 2GB and minutes of CPU. parse_qs_bytes now does its own splitting, following parse_qsl, and decodes escapes with binascii.a2b_qp after swapping % and = (with fixups for the places where quoted-printable differs). This costs about 10ns and 3-8 bytes of memory per input byte. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012yLjEcjqs4afeSiJZhqbV5 (cherry picked from commit 62a1eb8)
…shes
The scheme/netloc check added in 6.6.0 used urlsplit, which follows RFC
3986 and sees an empty netloc in "///example.com". Browsers follow the
WHATWG URL spec, which skips any run of slashes (and backslashes) before
the host when resolving against an http or https URL, so a template like
"/{0}" or "/{0}/b" could still be used as an open redirect with a request
like "/a///example.com/". Collapse leading slash runs before comparing.
Collapsing slashes is not enough on its own, because the expected scheme
and netloc came from formatting the template with "/" as a placeholder,
which turns "/{0}/b" into "///b". Instead, take the expected scheme and
netloc from the part of the template before the first substitution. This
also fixes a regression in 6.6.0, in which templates like "/{0}.html"
rejected every request (the placeholder made "//.html").
Also reject templates whose host would come entirely from a substitution
(such as "https://{0}" or "https:{0}"), which 6.6.0 intended to reject
but which could get through with extra slashes, and run the check after
query arguments are appended, since url_concat can change the URL (on
some Python versions it turns "https:host" into "https:///host").
Redirect URLs that url_concat cannot parse, or that contain characters
not allowed in a header, now get a 400 instead of a 500.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VamvWqdwiBTCFwhDLCbBee
(cherry picked from commit c503241)
With a route that matches paths starting with two slashes (such as a catch-all route), a request for //example.com would be redirected to //example.com/ by addslash, and //example.com// to //example.com by removeslash. These are protocol-relative URLs pointing to another host, making this an open redirect. Reject such requests with a 403, as StaticFileHandler already does. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VamvWqdwiBTCFwhDLCbBee (cherry picked from commit 21e1ad0)
A Content-Length header with a list of identical values ("5, 5") is
accepted, but the split used \s, which also matches non-HTTP whitespace
such as \xa0 and \x85 (both valid obs-text in a header value). Only
allow spaces and tabs, as RFC 9110's OWS does.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VamvWqdwiBTCFwhDLCbBee
(cherry picked from commit 7e841ab)
On Windows, a path like "file.txt:stream" names an alternate data stream of file.txt, and abspath, stat and open all accept it, so the containment checks passed and the stream was served. Reject any colon below the static root on Windows, in _check_in_root so that both get_absolute_path (and therefore get_version/static_url) and validate_absolute_path are covered. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VamvWp9NTgSqGSAV89kGD1 (cherry picked from commit d0c945a)
(cherry picked from commit a4dd782)
(cherry picked from commit eb44b95)
(cherry picked from commit c1adc39)
This was referenced Nov 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.