v0.6.1: Code review bugfixes — 7 correctness/safety/quality fixes
- Fix http.NotFound(w, nil) → pass actual request in handlers
- Fix dashboard running/stopped counts to match displayed stacks
- Fix Secure cookie blocking HTTP login (dynamic based on request)
- Remove misleading subtle.ConstantTimeCompare in session check
- Fix cleanupSessions goroutine leak (proper ticker + done channel)
- Add http.MaxBytesReader (1MB) to API POST endpoints
- Cache time.LoadLocation("Europe/Budapest") in template funcmap
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,6 +12,11 @@ import (
|
||||
|
||||
// templateFuncMap returns the FuncMap used by all HTML templates.
|
||||
func (s *Server) templateFuncMap() template.FuncMap {
|
||||
loc, err := time.LoadLocation("Europe/Budapest")
|
||||
if err != nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
|
||||
return template.FuncMap{
|
||||
"stateColor": func(state stacks.ContainerState) string {
|
||||
switch state {
|
||||
@@ -164,10 +169,6 @@ func (s *Server) templateFuncMap() template.FuncMap {
|
||||
if t.IsZero() {
|
||||
return "–"
|
||||
}
|
||||
loc, _ := time.LoadLocation("Europe/Budapest")
|
||||
if loc == nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
now := time.Now().In(loc)
|
||||
d := now.Sub(t.In(loc))
|
||||
switch {
|
||||
@@ -187,20 +188,12 @@ func (s *Server) templateFuncMap() template.FuncMap {
|
||||
if t.IsZero() {
|
||||
return "–"
|
||||
}
|
||||
loc, _ := time.LoadLocation("Europe/Budapest")
|
||||
if loc == nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
return t.In(loc).Format("2006-01-02 15:04")
|
||||
},
|
||||
"fmtTimeShort": func(t time.Time) string {
|
||||
if t.IsZero() {
|
||||
return "–"
|
||||
}
|
||||
loc, _ := time.LoadLocation("Europe/Budapest")
|
||||
if loc == nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
lt := t.In(loc)
|
||||
now := time.Now().In(loc)
|
||||
if lt.Year() == now.Year() && lt.YearDay() == now.YearDay() {
|
||||
@@ -222,10 +215,6 @@ func (s *Server) templateFuncMap() template.FuncMap {
|
||||
if t.IsZero() {
|
||||
return "–"
|
||||
}
|
||||
loc, _ := time.LoadLocation("Europe/Budapest")
|
||||
if loc == nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
lt := t.In(loc)
|
||||
now := time.Now().In(loc)
|
||||
timeStr := lt.Format("15:04")
|
||||
@@ -250,10 +239,6 @@ func (s *Server) templateFuncMap() template.FuncMap {
|
||||
}
|
||||
},
|
||||
"nextPruneLabel": func(schedule string) string {
|
||||
loc, _ := time.LoadLocation("Europe/Budapest")
|
||||
if loc == nil {
|
||||
loc = time.UTC
|
||||
}
|
||||
now := time.Now().In(loc)
|
||||
var next time.Time
|
||||
switch strings.ToLower(schedule) {
|
||||
|
||||
Reference in New Issue
Block a user