diff --git a/changelog/unreleased/fix-filename-validation.md b/changelog/unreleased/fix-filename-validation.md new file mode 100644 index 0000000000..8725e44f0c --- /dev/null +++ b/changelog/unreleased/fix-filename-validation.md @@ -0,0 +1,6 @@ +Bugfix: Fixed the file name validation if nodeid is used + +We have fixed the file name validation if nodeid is used + +https://github.com/cs3org/reva/pull/4767 +https://github.com/owncloud/ocis/issues/9568 diff --git a/internal/http/services/owncloud/ocdav/put.go b/internal/http/services/owncloud/ocdav/put.go index 9811efd385..7cd60abed1 100644 --- a/internal/http/services/owncloud/ocdav/put.go +++ b/internal/http/services/owncloud/ocdav/put.go @@ -412,13 +412,16 @@ func (s *svc) handleSpacesPut(w http.ResponseWriter, r *http.Request, spaceID st return } - if r.URL.Path != "/" { - if err := ValidateName(filepath.Base(ref.Path), s.nameValidators); err != nil { - w.WriteHeader(http.StatusBadRequest) - b, err := errors.Marshal(http.StatusBadRequest, err.Error(), "", "") - errors.HandleWebdavError(&sublog, w, b, err) - return - } + if ref.GetResourceId().GetOpaqueId() != "" && ref.GetResourceId().GetSpaceId() != ref.GetResourceId().OpaqueId && r.URL.Path == "/" { + s.handlePut(ctx, w, r, &ref, sublog) + return + } + + if err := ValidateName(filename(ref.Path), s.nameValidators); err != nil { + w.WriteHeader(http.StatusBadRequest) + b, err := errors.Marshal(http.StatusBadRequest, err.Error(), "", "") + errors.HandleWebdavError(&sublog, w, b, err) + return } s.handlePut(ctx, w, r, &ref, sublog)