Repository navigation
fix(events): resolve same-scheme redirects without slashes, and send Allow on 405 - #754
Merged
Merged
Conversation
…llow on 405
- Without JavaScript, `Redirect("http:next")` on an `http:` page (and
`"https:next"` on an `https:` page) now resolves against the page, as
the browser runtime does, instead of against the handler URL.
- The ASGI and WSGI adapters send an `Allow` header with a 405; every
adapter's list names `HEAD` where the route accepts `GET`.
- Handler discovery skips the `ViewEvents` base class as it skips
`Events`, so a public helper added to it never becomes a handler.
- Tests lock the Location for URL forms that URL parsers read with
different hosts.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
httpx2 builds the follow-up request from the Location header even with follow_redirects=False, and its URL parser rejects a scheme with no host and no leading "/" (such as "http:next"). Seven redirect tests sent such values on purpose and failed in CI. They now drive the mounted ASGI app directly and compare the status and Location the server wrote. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Resolve the conflicts in CHANGELOG.md (keep the main entries and this branch's two entries under one Unreleased Fixes list) and in docs/design/trust_boundaries.md (merge the Redirect and handler-name rows: main's refreshed text plus this branch's resolver, ViewEvents framework-base facts and updated line numbers). Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
JuroOravec
added a commit
that referenced
this pull request
Nov 18, 2026
) * docs(security): add review records for #754, #755, #756, #757 and #759 Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED * docs(security): apply review findings to the 1.0.2 hardening records Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
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.
What changed
actions.Redirect("http:next")on anhttp:page (or"https:next"on anhttps:page) is a relative URL. Citry's browser code (location.assign) resolves it against the page. The no-JavaScript form path sent it on unchanged, so the browser read the 303Locationagainst the handler's URL and usually landed on a "not found" page._resolve_redirect_urlnow resolves such a URL against a same-hostReferer, like any other relative URL. A URL with a/or\right after the colon, or a page with the other scheme, still goes out unchanged, because neither depends on the page.Allowon 405. The ASGI and WSGI adapters answered a method the route does not accept with a 405 and noAllowheader, which HTTP requires. They now send one, built by a new shared helper,route_allowed_methods. Django's 405 uses the same list, so it now namesHEADwherever the route acceptsGET.ViewEvents. Handler discovery and config resolution now skip Citry'sViewEventsbase class, as they already skipEvents.ViewEventsdefines no public method today, so no behavior changes now. A public helper added to it later will not become a handler on every subclass.Locationfor URL forms that browsers and URL parsers read with different hosts: a backslash in or after the authority, credentials, a scheme without//, escaped or full-width slashes. The server does not check hosts. EachLocationkeeps the URL the app returned, with non-ASCII characters percent-encoded, or resolves it against the page when the browser would read it as relative.docs/design/trust_boundaries.mdrows (Redirect, handler name, every adapter), a sentence in the extension routes docs, and two Fixes lines under## UnreleasedinCHANGELOG.md.Checks
citry-core2.1.1 wheel: 732 passed. The files were the redirect, scheme reader, events routes, route path rules,ViewEvents, Django, host adapter and host parity suites.mainfor the expected reasons: the oldLocation, noAllowheader, noHEADin the list, and the helper becoming a handler.URLclass follows the URL standard that browsers use. Resolving eachLocationagainst the handler URL reached the same address as resolving the original URL against the page: 100 cases from the author and 500 from the reviewer, with no differences.--platform linux: clean. The trust rows validator passes.Versioning
Nothing the 1.x promise covers breaks. The redirect change makes the documented rule hold ("relative to the page the visitor is on, with or without JavaScript"). The
Allowheader is new, and Django'sAllowvalue gainsHEAD. The new helpers live in internal modules. A patch release is enough.🤖 Generated with Claude Code
https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED