From 1caba78b4df6b9fcec8a99c8d10010c0596da0d8 Mon Sep 17 00:00:00 2001 From: Yura Bondarenko Date: Thu, 3 Jun 2021 16:33:58 +0200 Subject: [PATCH] 79768: Check against list of allowed mimetypes --- src/app/core/metadata/metadata.service.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/app/core/metadata/metadata.service.ts b/src/app/core/metadata/metadata.service.ts index fa4e81a5d7..0b63e13976 100644 --- a/src/app/core/metadata/metadata.service.ts +++ b/src/app/core/metadata/metadata.service.ts @@ -40,6 +40,15 @@ export class MetadataService { private currentObject: BehaviorSubject; + private readonly ALLOWED_MIMETYPES = [ + 'application/pdf', // .pdf + 'application/postscript', // .ps + 'application/msword', // .doc + 'application/vnd.openxmlformats-officedocument.wordprocessingml.document ', // .docx + 'application/rtf', // .rtf + 'application/epub+zip', // .epub + ]; + constructor( private router: Router, private translate: TranslateService, @@ -383,7 +392,7 @@ export class MetadataService { )), // Filter out only pairs with whitelisted formats filter(([, format]: [Bitstream, BitstreamFormat]) => - hasValue(format) && format.mimetype === 'application/pdf'), // TODO change to check map of mimetypes + hasValue(format) && this.ALLOWED_MIMETYPES.includes(format.mimetype)), // We only need 1 take(1), // Emit the link of the match