From 00e75df45bd7838340447426c496301b1b0112c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Friedrich=20Dreyer?= Date: Mon, 11 Jul 2022 14:18:28 +0000 Subject: [PATCH] test valid filename on spaces tus upload MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Jörn Friedrich Dreyer --- changelog/unreleased/test-valid-filename-on-spaces-tus.md | 6 ++++++ internal/http/services/owncloud/ocdav/tus.go | 8 +++++--- tests/acceptance/expected-failures-on-OCIS-storage.md | 5 ----- tests/acceptance/expected-failures-on-S3NG-storage.md | 5 ----- 4 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 changelog/unreleased/test-valid-filename-on-spaces-tus.md diff --git a/changelog/unreleased/test-valid-filename-on-spaces-tus.md b/changelog/unreleased/test-valid-filename-on-spaces-tus.md new file mode 100644 index 0000000000..64fb2d8575 --- /dev/null +++ b/changelog/unreleased/test-valid-filename-on-spaces-tus.md @@ -0,0 +1,6 @@ +Bugfix: test valid filename on spaces tus upload + +Tus uploads in spaces now also test valid filenames. + +https://github.com/cs3org/reva/pull/2977 +https://github.com/owncloud/ocis/issues/3050 \ No newline at end of file diff --git a/internal/http/services/owncloud/ocdav/tus.go b/internal/http/services/owncloud/ocdav/tus.go index 1fafc69e0c..f5bd80feb4 100644 --- a/internal/http/services/owncloud/ocdav/tus.go +++ b/internal/http/services/owncloud/ocdav/tus.go @@ -75,9 +75,11 @@ func (s *svc) handleSpacesTusPost(w http.ResponseWriter, r *http.Request, spaceI // read filename from metadata meta := tusd.ParseMetadataHeader(r.Header.Get(net.HeaderUploadMetadata)) - if meta["filename"] == "" { - w.WriteHeader(http.StatusPreconditionFailed) - return + for _, r := range nameRules { + if !r.Test(meta["filename"]) { + w.WriteHeader(http.StatusPreconditionFailed) + return + } } sublog := appctx.GetLogger(ctx).With().Str("spaceid", spaceID).Str("path", r.URL.Path).Logger() diff --git a/tests/acceptance/expected-failures-on-OCIS-storage.md b/tests/acceptance/expected-failures-on-OCIS-storage.md index 1f361564c9..200cd42b93 100644 --- a/tests/acceptance/expected-failures-on-OCIS-storage.md +++ b/tests/acceptance/expected-failures-on-OCIS-storage.md @@ -1362,11 +1362,6 @@ moving outside of the Shares folder gives 501 Not Implemented. - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:86](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L86) - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:100](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L100) -#### [TUS upload file with invalid name sends false response](https://github.com/owncloud/ocis/issues/3050) -- [apiWebdavUploadTUS/uploadFile.feature:215](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L215) -- [apiWebdavUploadTUS/uploadFile.feature:216](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L216) -- [apiWebdavUploadTUS/uploadFile.feature:218](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L218) - #### [unable to create resource using TUS inside Shares dir](https://github.com/owncloud/ocis/issues/3048) - [apiWebdavUploadTUS/uploadFileMtimeShares.feature:33](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFileMtimeShares.feature#L33) - [apiWebdavUploadTUS/uploadFileMtimeShares.feature:52](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFileMtimeShares.feature#L52) diff --git a/tests/acceptance/expected-failures-on-S3NG-storage.md b/tests/acceptance/expected-failures-on-S3NG-storage.md index 6b53ac9c6b..efcaa96208 100644 --- a/tests/acceptance/expected-failures-on-S3NG-storage.md +++ b/tests/acceptance/expected-failures-on-S3NG-storage.md @@ -1365,11 +1365,6 @@ _ocs: api compatibility, return correct status code_ - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:86](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L86) - [apiShareManagementToShares/moveShareInsideAnotherShare.feature:100](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiShareManagementToShares/moveShareInsideAnotherShare.feature#L100) -#### [TUS upload file with invalid name sends false response](https://github.com/owncloud/ocis/issues/3050) -- [apiWebdavUploadTUS/uploadFile.feature:215](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L215) -- [apiWebdavUploadTUS/uploadFile.feature:216](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L216) -- [apiWebdavUploadTUS/uploadFile.feature:218](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFile.feature#L218) - #### [unable to create resource using TUS inside Shares dir](https://github.com/owncloud/ocis/issues/3048) - [apiWebdavUploadTUS/uploadFileMtimeShares.feature:33](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFileMtimeShares.feature#L33) - [apiWebdavUploadTUS/uploadFileMtimeShares.feature:52](https://github.com/owncloud/core/blob/master/tests/acceptance/features/apiWebdavUploadTUS/uploadFileMtimeShares.feature#L52)