Skip to content

Commit

Permalink
Do not panic if TZ parsing of iCal feed fails (#47)
Browse files Browse the repository at this point in the history
If parsing the time zone from the calendar feed fails, `loc` would be `nil` and therefore the subsequent call `checkEvents()` would fail with a panic, because the availability check requires the time.Location to be not `nil`.
  • Loading branch information
chaudum authored Aug 22, 2024
2 parents 082d0d9 + 134509a commit 647e7ca
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/icassigner/calendar/ical.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func CheckAvailability(icalUrl string, name string, now time.Time, unavailabilit
if tzString := cal.Props.Get("X-WR-TIMEZONE"); tzString != nil {
loc, err = time.LoadLocation(tzString.Value)
if err != nil {
log.Printf("Unable to parse timezone %q, due %v", tzString.Value, err)
return true, fmt.Errorf("unable to parse timezone %q, due %w", tzString.Value, err)
}
}

Expand Down

0 comments on commit 647e7ca

Please sign in to comment.