fix(caldav): don't try to parse a list url as task when it does not end in .ics

This commit is contained in:
kolaente 2023-02-14 12:00:22 +01:00
parent 57084b40c3
commit b71c74867e
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 8 additions and 0 deletions

View File

@ -130,12 +130,20 @@ func (vcls *VikunjaCaldavListStorage) GetResourcesByList(rpaths []string) ([]dat
// So we split the url in parts, take the last one and strip the ".ics" at the end
var uids []string
for _, path := range rpaths {
if !strings.HasSuffix(path, ".ics") {
// Looks like this is not a task url
continue
}
parts := strings.Split(path, "/")
uid := []rune(parts[4]) // The 4th part is the id with ".ics" suffix
endlen := len(uid) - len(".ics") // ".ics" are 4 bytes
uids = append(uids, string(uid[:endlen]))
}
if len(uids) == 0 {
return []data.Resource{}, nil
}
s := db.NewSession()
defer s.Close()