Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

[chore] upload fix for storages on sub pathes (#11990)

Eric Schubert7c26f5ef60a7
diff --git a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
index 3a35973282b..3e1f0cdfccd 100644
--- a/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
+++ b/modules/storages/app/common/storages/peripherals/storage_interaction/nextcloud/upload_link_query.rb
@@ -68,7 +68,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
end
def build_upload_link(response)
- destination = @base_uri.merge(File.join(URI_UPLOAD_BASE_PATH, response.token))
+ destination = URI.parse(File.join(@base_uri.to_s, URI_UPLOAD_BASE_PATH, response.token))
ServiceResult.success(result: Storages::UploadLink.new(destination))
end
@@ -79,7 +79,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
response = ServiceResult.success(
result: RestClient::Request.execute(
method:,
- url: @base_uri.merge(relative_path).to_s,
+ url: File.join(@base_uri.to_s, relative_path),
payload: payload.to_json,
headers: {
'Authorization' => "Bearer #{token.access_token}",
diff --git a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
index 42580a6379d..e7d4a81d4e9 100644
--- a/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
+++ b/modules/storages/lib/open_project/storages/append_storages_hosts_to_csp_hook.rb
@@ -48,6 +48,7 @@ class ::OpenProject::Storages::AppendStoragesHostsToCspHook < OpenProject::Hook:
.select(:storage_id)
hosts = ::Storages::Storage.where(id: projects_with_permission)
.pluck(:host)
+ .map(&method(:remove_uri_path))
return if hosts.empty?
@@ -55,4 +56,11 @@ class ::OpenProject::Storages::AppendStoragesHostsToCspHook < OpenProject::Hook:
controller = context[:controller]
controller.append_content_security_policy_directives({ connect_src: hosts })
end
+
+ private
+
+ def remove_uri_path(url)
+ uri = URI.parse(url)
+ "#{uri.scheme}://#{uri.host}"
+ end
end