From 0e5f058af9ac08f240acf78acbd7c8c6f1e28a95 Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Wed, 19 Apr 2023 17:37:35 -0700 Subject: [PATCH] exif: blacklist invalid date (fix #539) Signed-off-by: Varun Patil --- lib/Exif.php | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Exif.php b/lib/Exif.php index b2ed103c..ce6bc86e 100644 --- a/lib/Exif.php +++ b/lib/Exif.php @@ -159,11 +159,21 @@ class Exif throw new \Exception("Invalid date: {$exifDate}"); } + // Epoch timestamp + $timestamp = $parsedDate->getTimestamp(); + // Filter out dates before 1800 A.D. - if ($parsedDate->getTimestamp() < -5364662400) { // 1800 A.D. + if ($timestamp < -5364662400) { // 1800 A.D. throw new \Exception("Date too old: {$exifDate}"); } + // Filter out January 1, 1904 12:00:00 AM UTC + // Exiftool returns this as the date when QuickTimeUTC is set and + // the date is set to 0000:00:00 00:00:00 + if ($timestamp === -2082844800) { + throw new \Exception("Blacklisted date: {$exifDate}"); + } + // Force the timezone to be the same as parseTz if ($exifTz) { $parsedDate->setTimezone($exifTz);