Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
2b303fe569 |
@@ -2932,12 +2932,6 @@ local record instead of nothing. What that placement gives up is
|
|||||||
recovery of a panic in the six entries above it, none of which does
|
recovery of a panic in the six entries above it, none of which does
|
||||||
more than set a header or start a timer.
|
more than set a header or start a timer.
|
||||||
|
|
||||||
Each admin page route group (`/pages`, `/user/*`, `/sources`,
|
|
||||||
`/source/*`) starts with its own **Recoverer** and, if `SENTRY_DSN` is
|
|
||||||
set, its own **Sentry** error reporting. That Recoverer answers a panic
|
|
||||||
with the `500` error page in the normal layout; the global one keeps
|
|
||||||
the plain-text `500` for every other route.
|
|
||||||
|
|
||||||
Additionally, form endpoints (`/pages`, `/user/*`, `/sources`,
|
Additionally, form endpoints (`/pages`, `/user/*`, `/sources`,
|
||||||
`/source/*`) apply a **MaxBodySize** middleware that limits
|
`/source/*`) apply a **MaxBodySize** middleware that limits
|
||||||
POST/PUT/PATCH request bodies to 1 MB. It is registered ahead of the
|
POST/PUT/PATCH request bodies to 1 MB. It is registered ahead of the
|
||||||
|
|||||||
@@ -148,9 +148,8 @@ func New(
|
|||||||
}
|
}
|
||||||
|
|
||||||
// HandleErrorPage returns a handler that answers every request with
|
// HandleErrorPage returns a handler that answers every request with
|
||||||
// the error page for status. The router uses it for unknown paths, the
|
// the error page for status. The router uses it for unknown paths and
|
||||||
// CSRF middleware for a refused form, and each admin page route
|
// the CSRF middleware for a refused form.
|
||||||
// group's recoverer for a panic.
|
|
||||||
func (s *Handlers) HandleErrorPage(status int) http.HandlerFunc {
|
func (s *Handlers) HandleErrorPage(status int) http.HandlerFunc {
|
||||||
return func(w http.ResponseWriter, r *http.Request) {
|
return func(w http.ResponseWriter, r *http.Request) {
|
||||||
s.renderError(w, r, status)
|
s.renderError(w, r, status)
|
||||||
|
|||||||
@@ -137,9 +137,7 @@ func (w *recoverResponseWriter) Unwrap() http.ResponseWriter {
|
|||||||
//
|
//
|
||||||
// Unlike http.Error on its own, it deletes any Set-Cookie the handler
|
// Unlike http.Error on its own, it deletes any Set-Cookie the handler
|
||||||
// set before panicking, because a request that failed must not hand
|
// set before panicking, because a request that failed must not hand
|
||||||
// the client a credential. It touches no other header: when page
|
// the client a credential; every other header is left to http.Error.
|
||||||
// answers, every other header the handler set goes out with it, apart
|
|
||||||
// from any page sets itself; otherwise they are left to http.Error.
|
|
||||||
// See https://git.eeqj.de/sneak/webhooker/issues/193.
|
// See https://git.eeqj.de/sneak/webhooker/issues/193.
|
||||||
func (s *Middleware) Recoverer(
|
func (s *Middleware) Recoverer(
|
||||||
page http.Handler,
|
page http.Handler,
|
||||||
|
|||||||
@@ -15,10 +15,9 @@ import (
|
|||||||
// bytes) for form POST endpoints. 1 MB is generous for any form
|
// bytes) for form POST endpoints. 1 MB is generous for any form
|
||||||
// submission while preventing abuse from oversized payloads.
|
// submission while preventing abuse from oversized payloads.
|
||||||
//
|
//
|
||||||
// The four admin page route groups below (/pages, /user/{username},
|
// Every route group below installs MaxBodySize(maxFormBodySize) as
|
||||||
// /sources and /source/{sourceID}) install MaxBodySize(maxFormBodySize)
|
// its first middleware after the recoverer, ahead of both CSRF and
|
||||||
// right after their recoverer and error reporting, ahead of both CSRF
|
// RequireAuth. Both orderings are deliberate.
|
||||||
// and RequireAuth. Both orderings are deliberate.
|
|
||||||
//
|
//
|
||||||
// Ahead of CSRF because gorilla/csrf parses the form. The cap has to
|
// Ahead of CSRF because gorilla/csrf parses the form. The cap has to
|
||||||
// be installed before anything reads the body, or the parse runs
|
// be installed before anything reads the body, or the parse runs
|
||||||
|
|||||||
Reference in New Issue
Block a user