You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
gitea/routers/web
Giteabot 5b670d83e1
Fix panic in storageHandler (#27446) (#27479)
Backport #27446 by @sryze

storageHandler() is written as a middleware but is used as an endpoint
handler, and thus `next` is actually `nil`, which causes a null pointer
dereference when a request URL does not match the pattern (where it
calls `next.ServerHTTP()`).

Example CURL command to trigger the panic:

```
curl -I "http://yourhost/gitea//avatars/a"
```

Fixes #27409

---

Note: the diff looks big but it's actually a small change - all I did
was to remove the outer closure (and one level of indentation) ~and
removed the HTTP method and pattern checks as they seem redundant
because go-chi already does those checks~. You might want to check "Hide
whitespace" when reviewing it.

Alternative solution (a bit simpler): append `, misc.DummyOK` to the
route declarations that utilize `storageHandler()` - this makes it
return an empty response when the URL is invalid. I've tested this one
and it works too. Or maybe it would be better to return a 400 error in
that case (?)

Co-authored-by: Sergey Zolotarev <sryze@outlook.com>
1 year ago
..
admin Refactor system setting (#27000) (#27452) 1 year ago
auth Another round of `db.DefaultContext` refactor (#27103) (#27262) 1 year ago
devtest Make "cancel" buttons have proper type in modal forms (#25618) 2 years ago
events
explore Next round of `db.DefaultContext` refactor (#27089) 1 year ago
feed More `db.DefaultContext` refactor (#27265) (#27347) 1 year ago
healthcheck Remove `db.DefaultContext` in `routers/` and `cmd/` (#26076) 2 years ago
misc Serve pre-defined files in "public", add "security.txt", add CORS header for ".well-known" (#25974) 2 years ago
org More `db.DefaultContext` refactor (#27265) (#27347) 1 year ago
repo When comparing with an non-exist repository, return 404 but 500 (#27437) (#27442) 1 year ago
shared Introduce fixes and more rigorous tests for 'Show on a map' feature (#26803) (#27365) 1 year ago
user Refactor system setting (#27000) (#27452) 1 year ago
base.go Fix panic in storageHandler (#27446) (#27479) 1 year ago
goget.go Support SSH for go get (#24664) 2 years ago
home.go Reduce usage of `db.DefaultContext` (#27073) 1 year ago
metrics.go
nodeinfo.go
swagger_json.go Start using template context function (#26254) 2 years ago
web.go Allow get release download files and lfs files with oauth2 token format (#26430) (#27379) 1 year ago
webfinger.go Add a link to OpenID Issuer URL in WebFinger response (#26000) 2 years ago