Skip to content

Commit 069685f

Browse files
authored
fix(caldav): return 404 when trying to access a project that cannot exist with CalDAV (#2796)
1 parent 50bece8 commit 069685f

2 files changed

Lines changed: 8 additions & 1 deletion

File tree

pkg/routes/caldav/handler.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ func getProjectFromParam(c *echo.Context) (project *models.ProjectWithTasksAndBu
185185

186186
intParam, err := strconv.ParseInt(param, 10, 64)
187187
if err != nil {
188-
return nil, err
188+
// The project ID given is not an integer, it cannot exist
189+
return nil, models.ErrProjectDoesNotExist{}
189190
}
190191

191192
if intParam == models.FavoritesPseudoProjectID {

pkg/webtests/caldav_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,12 @@ func TestCaldav(t *testing.T) {
4444
assert.Contains(t, rec.Body.String(), "END:VTODO")
4545
assert.Contains(t, rec.Body.String(), "END:VCALENDAR")
4646
})
47+
t.Run("Returns 404 for non-integer project param", func(t *testing.T) {
48+
e, _ := setupTestEnv()
49+
rec, err := newCaldavTestRequestWithUser(t, e, http.MethodGet, caldav.ProjectHandler, &testuser15, ``, nil, map[string]string{"project": "E6948AA3-86CC-40A1-874D-3B0A02FAA781"})
50+
require.NoError(t, err)
51+
assert.Equal(t, http.StatusNotFound, rec.Result().StatusCode)
52+
})
4753
t.Run("Import VTODO", func(t *testing.T) {
4854
const vtodo = `BEGIN:VCALENDAR
4955
VERSION:2.0

0 commit comments

Comments
 (0)