Security
- Redirect middleware:
HTTPSRedirect,HTTPSWWWRedirect,HTTPSNonWWWRedirect,WWWRedirectandNonWWWRedirectnow return400 Bad Requestinstead of redirecting when the host is empty, starts with:or., contains%, or is empty after removingwww.. Before this change, such hosts could produce an open redirect. The middleware no longer redirectsOPTIONS *requests, mapswsandwsstohttpandhttpsin redirect targets, and matches thewww.prefix case-insensitively. Fixes GHSA-3f6j-cw5h-qw9c (#3217) in #3220.
Fixes
- Trailing slash middleware:
AddTrailingSlashandRemoveTrailingSlashkeep escaped path segments such as%2Fin redirect and forward targets, so the request still matches its original route. Fixes #3206 in #3221. - IPv6 zones:
ExtractIPFromXFFHeaderandExtractIPFromRealIPHeadertrust zoned link-local proxy peers such as[fe80::1%eth0]:8080, with or without a port. Fixes #3179 in #3222. - Header binding:
BindHeadersno longer panics on nil or empty header value slices. Fixes #3169 in #3223.
Behavior change
Context.RealIP() and ExtractIPDirect() now return a zoned link-local peer without its zone: fe80::1, not fe80::1%eth0. Update logs, allowlists or rate-limit keys that store the zoned form.
No public API, dependency or minimum Go-version changes.