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

[#44856] fixed file name encoding

Eric Schuberte343a9458a29
diff --git a/frontend/src/app/shared/components/storages/services/upload-storage-files.service.ts b/frontend/src/app/shared/components/storages/services/upload-storage-files.service.ts
index 594e1b59542..208f5b2bd9d 100644
--- a/frontend/src/app/shared/components/storages/services/upload-storage-files.service.ts
+++ b/frontend/src/app/shared/components/storages/services/upload-storage-files.service.ts
@@ -83,8 +83,14 @@ export class UploadStorageFilesService {
const size = /<oc:size>(.*)<\/oc:size>/.exec(xml)?.pop();
if (!size) { throw error; }
- const location = /<d:href>(.*)<\/d:href>/.exec(xml)?.pop();
- if (!location) { throw error; }
+ const href = /<d:href>(.*)<\/d:href>/.exec(xml)?.pop();
+ const parts = href?.split('/');
+ if (!parts || parts.length < 1) { throw error; }
+
+ const name = parts.pop();
+ if (!name) { throw error; }
+
+ const location = `/${parts.slice(parts.indexOf('webdav') + 1).join('/')}`;
const date = /<d:getlastmodified>(.*)<\/d:getlastmodified>/.exec(xml)?.pop();
if (!date) { throw error; }
@@ -96,10 +102,10 @@ export class UploadStorageFilesService {
return {
id,
- name: location.split('/').pop() || '',
+ name: decodeURIComponent(name),
+ location,
mimeType,
size: parseInt(size, 10),
- location,
createdAt,
createdByName: creator,
lastModifiedAt,
@@ -113,20 +119,9 @@ export class UploadStorageFilesService {
+ ' <d:prop>\n'
+ ' <oc:fileid />\n'
+ ' <d:getlastmodified />\n'
- + ' <d:getetag />\n'
+ ' <d:getcontenttype />\n'
- + ' <d:resourcetype />\n'
- + ' <oc:fileid />\n'
- + ' <oc:permissions />\n'
+ ' <oc:size />\n'
- + ' <d:getcontentlength />\n'
- + ' <nc:has-preview />\n'
- + ' <oc:favorite />\n'
- + ' <oc:comments-unread />\n'
+ ' <oc:owner-display-name />\n'
- + ' <oc:share-types />\n'
- + ' <nc:contained-folder-count />\n'
- + ' <nc:contained-file-count />\n'
+ ' </d:prop>\n'
+ '</d:propfind>';
}
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 2a80ab88966..2139240fad7 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
@@ -91,7 +91,7 @@ module Storages::Peripherals::StorageInteraction::Nextcloud
end
def build_upload_link(share)
- destination = @base_uri.merge("#{UPLOAD_LINK_BASE}/#{share.file_name}")
+ destination = @base_uri.merge("#{UPLOAD_LINK_BASE}/#{ERB::Util.url_encode(share.file_name)}")
destination.user = share.token
destination.password = share.password