From e41e0df27ea3e0266e248f56d320a733ba6bbb1d Mon Sep 17 00:00:00 2001 From: Jason Rasmussen Date: Fri, 26 May 2023 22:13:09 -0400 Subject: [PATCH] fix(server): invalid exif date string (#2580) --- .../src/processors/metadata-extraction.processor.ts | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/server/apps/microservices/src/processors/metadata-extraction.processor.ts b/server/apps/microservices/src/processors/metadata-extraction.processor.ts index 40f8a03dce..6f2f8ec5e9 100644 --- a/server/apps/microservices/src/processors/metadata-extraction.processor.ts +++ b/server/apps/microservices/src/processors/metadata-extraction.processor.ts @@ -116,13 +116,16 @@ export class MetadataExtractionProcessor { : {}; const exifToDate = (exifDate: string | ExifDateTime | undefined) => { - if (!exifDate) return null; - - if (typeof exifDate === 'string') { - return new Date(exifDate); + if (!exifDate) { + return null; } - return exifDate.toDate(); + const date = typeof exifDate === 'string' ? new Date(exifDate) : exifDate.toDate(); + if (isNaN(date.valueOf())) { + return null; + } + + return date; }; const exifTimeZone = (exifDate: string | ExifDateTime | undefined) => {