From 81075624b9d97ca38d521a0bb00a58158508366b Mon Sep 17 00:00:00 2001 From: Jesse Geens Date: Fri, 3 Oct 2025 16:00:40 +0200 Subject: [PATCH] WIP --- internal/http/services/owncloud/ocgraph/groups.go | 6 ++++++ internal/http/services/owncloud/ocgraph/users.go | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/internal/http/services/owncloud/ocgraph/groups.go b/internal/http/services/owncloud/ocgraph/groups.go index 63801a6bb77..a1ad9cf6488 100644 --- a/internal/http/services/owncloud/ocgraph/groups.go +++ b/internal/http/services/owncloud/ocgraph/groups.go @@ -81,6 +81,12 @@ func (s *svc) listGroups(w http.ResponseWriter, r *http.Request) { log.Debug().Err(err).Interface("query", r.URL.Query()).Msg("must pass a search string of at least length 3 to list groups") } queryVal := strings.Trim(req.Query.Search.RawValue, "\"") + queryVal = strings.ReplaceAll(queryVal, "*", "") + + if len(queryVal) < 3 { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("Search query must contain at least three valid characters")) + } log.Debug().Str("Query", queryVal).Str("orderBy", req.Query.OrderBy.RawValue).Any("select", getGroupSelectionFromRequest(req.Query.Select)).Msg("Listing groups in libregraph API") diff --git a/internal/http/services/owncloud/ocgraph/users.go b/internal/http/services/owncloud/ocgraph/users.go index 9c14c952f49..e7c6b903f50 100644 --- a/internal/http/services/owncloud/ocgraph/users.go +++ b/internal/http/services/owncloud/ocgraph/users.go @@ -175,8 +175,14 @@ func (s *svc) listUsers(w http.ResponseWriter, r *http.Request) { log.Debug().Err(err).Interface("query", r.URL.Query()).Msg("must pass a search string of at least length 3 to list users") } queryVal := strings.Trim(req.Query.Search.RawValue, "\"") + queryVal = strings.ReplaceAll(queryVal, "*", "") log.Debug().Str("Query", queryVal).Str("orderBy", req.Query.OrderBy.RawValue).Any("select", getUserSelectionFromRequest(req.Query.Select)).Msg("Listing users in libregraph API") + if len(queryVal) < 3 { + w.WriteHeader(http.StatusBadRequest) + w.Write([]byte("Search query must contain at least three valid characters")) + } + filters, err := generateUserFilters(req) if err != nil { handleError(ctx, err, http.StatusBadRequest, w)