From c077249181f497e30d08b09fa5423da94582b735 Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Thu, 19 Sep 2024 09:40:29 +0200 Subject: [PATCH] Fixed an issue when the collaboration service registers apps also for binary and unknown mime types. --- changelog/unreleased/fix-registers-app.md | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- services/collaboration/pkg/helpers/registration.go | 4 ++++ .../http/services/appprovider/appprovider.go | 12 ++++++++++-- vendor/github.com/cs3org/reva/v2/pkg/mime/mime.go | 1 + vendor/modules.txt | 2 +- 7 files changed, 25 insertions(+), 6 deletions(-) create mode 100644 changelog/unreleased/fix-registers-app.md diff --git a/changelog/unreleased/fix-registers-app.md b/changelog/unreleased/fix-registers-app.md new file mode 100644 index 00000000000..8f281b3b757 --- /dev/null +++ b/changelog/unreleased/fix-registers-app.md @@ -0,0 +1,6 @@ +Bugfix: Fixed the collaboration service registration + +Fixed an issue when the collaboration service registers apps also for binary and unknown mime types. + +https://github.com/owncloud/ocis/pull/10107 +https://github.com/owncloud/ocis/issues/10086 diff --git a/go.mod b/go.mod index e7687ebb191..38b87a2fab9 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( github.com/cenkalti/backoff v2.2.1+incompatible github.com/coreos/go-oidc/v3 v3.11.0 github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb - github.com/cs3org/reva/v2 v2.24.2-0.20240919151635-556263192484 + github.com/cs3org/reva/v2 v2.24.2-0.20240924063152-104b905ebb19 github.com/dhowden/tag v0.0.0-20230630033851-978a0926ee25 github.com/dutchcoders/go-clamd v0.0.0-20170520113014-b970184f4d9e github.com/egirna/icap-client v0.1.1 diff --git a/go.sum b/go.sum index fa6b0f215dd..c62219a03e2 100644 --- a/go.sum +++ b/go.sum @@ -255,8 +255,8 @@ github.com/crewjam/saml v0.4.14 h1:g9FBNx62osKusnFzs3QTN5L9CVA/Egfgm+stJShzw/c= github.com/crewjam/saml v0.4.14/go.mod h1:UVSZCf18jJkk6GpWNVqcyQJMD5HsRugBPf4I1nl2mME= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb h1:KmYZDReplv/yfwc1LNYpDcVhVujC3Pasv6WjXx1haSU= github.com/cs3org/go-cs3apis v0.0.0-20240724121416-062c4e3046cb/go.mod h1:yyP8PRo0EZou3nSH7H4qjlzQwaydPeIRNgX50npQHpE= -github.com/cs3org/reva/v2 v2.24.2-0.20240919151635-556263192484 h1:MeHzCFCh5WttP2hz7UTCHgV6WQXrucQXSyQs5+aIrcY= -github.com/cs3org/reva/v2 v2.24.2-0.20240919151635-556263192484/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI= +github.com/cs3org/reva/v2 v2.24.2-0.20240924063152-104b905ebb19 h1:uqn7tyej+v8tlmUtXqJTaUqjzz0U2n3BohR+cHJZrCA= +github.com/cs3org/reva/v2 v2.24.2-0.20240924063152-104b905ebb19/go.mod h1:p7CHBXcg6sSqB+0JMNDfC1S7TSh9FghXkw1kTV3KcJI= github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4= github.com/cyphar/filepath-securejoin v0.2.4 h1:Ugdm7cg7i6ZK6x3xDF1oEu1nfkyfH53EtKeQYTC3kyg= github.com/cyphar/filepath-securejoin v0.2.4/go.mod h1:aPGpWjXOXUn2NCNjFvBE6aRxGGx79pTxQpKOJNYHHl4= diff --git a/services/collaboration/pkg/helpers/registration.go b/services/collaboration/pkg/helpers/registration.go index 85a15fadea2..0fa416bd4be 100644 --- a/services/collaboration/pkg/helpers/registration.go +++ b/services/collaboration/pkg/helpers/registration.go @@ -40,6 +40,10 @@ func RegisterAppProvider( for _, extensions := range appUrls { for ext := range extensions { m := mime.Detect(false, ext) + // skip the default + if m == "application/octet-stream" { + continue + } mimeTypesMap[m] = true } } diff --git a/vendor/github.com/cs3org/reva/v2/internal/http/services/appprovider/appprovider.go b/vendor/github.com/cs3org/reva/v2/internal/http/services/appprovider/appprovider.go index bf7154e5866..cf017503a1c 100644 --- a/vendor/github.com/cs3org/reva/v2/internal/http/services/appprovider/appprovider.go +++ b/vendor/github.com/cs3org/reva/v2/internal/http/services/appprovider/appprovider.go @@ -251,8 +251,16 @@ func (s *svc) handleNew(w http.ResponseWriter, r *http.Request) { return } if createRes.Status.Code != rpc.Code_CODE_OK { - writeError(w, r, appErrorServerError, "error calling InitiateFileUpload", nil) - return + switch createRes.Status.Code { + case rpc.Code_CODE_PERMISSION_DENIED: + writeError(w, r, appErrorPermissionDenied, "permission denied to create the file", nil) + case rpc.Code_CODE_NOT_FOUND: + writeError(w, r, appErrorNotFound, "parent container does not exist", nil) + return + default: + writeError(w, r, appErrorServerError, "error calling InitiateFileUpload", nil) + return + } } // Do a HTTP PUT with an empty body diff --git a/vendor/github.com/cs3org/reva/v2/pkg/mime/mime.go b/vendor/github.com/cs3org/reva/v2/pkg/mime/mime.go index a6feda944fd..74207c01371 100644 --- a/vendor/github.com/cs3org/reva/v2/pkg/mime/mime.go +++ b/vendor/github.com/cs3org/reva/v2/pkg/mime/mime.go @@ -1054,6 +1054,7 @@ var mimeTypes = map[string]string{ "wmz": "application/x-msmetafile", "woff": "font/woff", "woff2": "font/woff2", + "wopitest": "text/plain", // The dummy extension for the WOPI validator https://learn.microsoft.com/en-us/microsoft-365/cloud-storage-partner-program/online/build-test-ship/validator "wpd": "application/vnd.wordperfect", "wpl": "application/vnd.ms-wpl", "wps": "application/vnd.ms-works", diff --git a/vendor/modules.txt b/vendor/modules.txt index e065f58bbe6..3c173df4b6c 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -367,7 +367,7 @@ github.com/cs3org/go-cs3apis/cs3/storage/provider/v1beta1 github.com/cs3org/go-cs3apis/cs3/storage/registry/v1beta1 github.com/cs3org/go-cs3apis/cs3/tx/v1beta1 github.com/cs3org/go-cs3apis/cs3/types/v1beta1 -# github.com/cs3org/reva/v2 v2.24.2-0.20240919151635-556263192484 +# github.com/cs3org/reva/v2 v2.24.2-0.20240924063152-104b905ebb19 ## explicit; go 1.21 github.com/cs3org/reva/v2/cmd/revad/internal/grace github.com/cs3org/reva/v2/cmd/revad/runtime