diff --git a/frontend/.eslintrc.js b/frontend/.eslintrc.js index 030ea66b76..dbbec2e87b 100644 --- a/frontend/.eslintrc.js +++ b/frontend/.eslintrc.js @@ -125,6 +125,9 @@ module.exports = { }, ], + // Allow writing type union and type intersections without space + "@typescript-eslint/space-infix-ops": "off", + // Allow empty interfaces for naming purposes (HAL resources) "@typescript-eslint/no-empty-interface": "off", 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 dd6f4f2d99..e5cd0abbfe 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 @@ -72,18 +72,19 @@ export class UploadStorageFilesService { } private parseXmlResponse(xml:string):IStorageFile { + const response = new DOMParser().parseFromString(xml, 'application/xml'); const error = new Error(`Invalid response for uploaded file: ${xml}`); - const id = /(.*)<\/oc:fileid>/.exec(xml)?.pop(); + const id = response.getElementsByTagName('oc:fileid')[0].textContent; if (!id) { throw error; } - const mimeType = /(.*)<\/d:getcontenttype>/.exec(xml)?.pop(); + const mimeType = response.getElementsByTagName('d:getcontenttype')[0].textContent; if (!mimeType) { throw error; } - const size = /(.*)<\/oc:size>/.exec(xml)?.pop(); + const size = response.getElementsByTagName('oc:size')[0].textContent; if (!size) { throw error; } - const href = /(.*)<\/d:href>/.exec(xml)?.pop(); + const href = response.getElementsByTagName('d:href')[0].textContent; const parts = href?.split('/'); if (!parts || parts.length < 1) { throw error; } @@ -92,12 +93,12 @@ export class UploadStorageFilesService { const location = `/${parts.slice(parts.indexOf('webdav') + 1).join('/')}`; - const date = /(.*)<\/d:getlastmodified>/.exec(xml)?.pop(); + const date = response.getElementsByTagName('d:getlastmodified')[0].textContent; if (!date) { throw error; } const createdAt = this.timezoneService.parseDatetime(date).toISOString(); const lastModifiedAt = createdAt; - const creator = /(.*)<\/oc:owner-display-name>/.exec(xml)?.pop(); + const creator = response.getElementsByTagName('oc:owner-display-name')[0].textContent; if (!creator) { throw error; } return { @@ -114,16 +115,15 @@ export class UploadStorageFilesService { } private get propfindBody() { - return ` - - - - - - - - - - `; + return ` + + + + + + + + + `; } } diff --git a/frontend/src/app/shared/components/storages/storage/storage.component.ts b/frontend/src/app/shared/components/storages/storage/storage.component.ts index 8e454536ee..01086a7fdb 100644 --- a/frontend/src/app/shared/components/storages/storage/storage.component.ts +++ b/frontend/src/app/shared/components/storages/storage/storage.component.ts @@ -142,7 +142,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD } private get addFileLinksHref() { - return (this.resource.$links as unknown & { addFileLink:IHalResourceLink }).addFileLink.href; + return (this.resource.$links as unknown&{ addFileLink:IHalResourceLink }).addFileLink.href; } constructor( @@ -185,7 +185,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD this.allowEditing$ = this .currentUserService - .hasCapabilities$('file_links/manage', (this.resource.project as unknown & { id:string }).id); + .hasCapabilities$('file_links/manage', (this.resource.project as unknown&{ id:string }).id); document.body.addEventListener('dragover', this.onGlobalDragOver.bind(this)); document.body.addEventListener('dragleave', this.afterGlobalDragEnd.bind(this)); @@ -231,7 +231,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD this.openSelectLocationDialog(fileList); } - private openSelectLocationDialog(files:FileList | null):void { + private openSelectLocationDialog(files:FileList|null):void { const locals = { storageType: this.storage._links.type.href, storageTypeName: this.storageType, @@ -284,7 +284,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD } private uploadResourceLink(fileName:string, location:string):IPrepareUploadLink { - const project = (this.resource.project as unknown & { id:string }).id; + const project = (this.resource.project as unknown&{ id:string }).id; const link = this.storage._links.prepareUpload.filter((value) => project === value.payload.projectId.toString()); if (link.length === 0) { throw new Error('Cannot upload to this storage. Missing permissions in project.'); @@ -369,7 +369,7 @@ export class StorageComponent extends UntilDestroyedMixin implements OnInit, OnD } private get fileLinkSelfLink():string { - const fileLinks = this.resource.fileLinks as unknown & { href:string }; + const fileLinks = this.resource.fileLinks as unknown&{ href:string }; return `${fileLinks.href}?filters=[{"storage":{"operator":"=","values":["${this.storage.id}"]}}]`; }