From 63ecdf30a278abac4517153df712cbbae1e98d6b Mon Sep 17 00:00:00 2001 From: Varun Patil Date: Thu, 23 Feb 2023 21:19:09 -0800 Subject: [PATCH] exif: ignore invalid values (fix #420) --- lib/Exif.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/Exif.php b/lib/Exif.php index 01e9dab8..ce6fb22c 100644 --- a/lib/Exif.php +++ b/lib/Exif.php @@ -115,6 +115,17 @@ class Exif // We need to remove blacklisted fields to prevent leaking info unset($exif['SourceFile'], $exif['FileName'], $exif['ExifToolVersion'], $exif['Directory'], $exif['FileSize'], $exif['FileModifyDate'], $exif['FileAccessDate'], $exif['FileInodeChangeDate'], $exif['FilePermissions'], $exif['ThumbnailImage']); + // Ignore zero date + if (\array_key_exists('DateTimeOriginal', $exif) && '0000:00:00 00:00:00' === $exif['DateTimeOriginal']) { + unset($exif['DateTimeOriginal']); + } + + // Ignore zero lat lng + if (\array_key_exists('GPSLatitude', $exif) && abs((float) $exif['GPSLatitude']) < 0.0001 + && \array_key_exists('GPSLongitude', $exif) && abs((float) $exif['GPSLongitude']) < 0.0001) { + unset($exif['GPSLatitude'], $exif['GPSLongitude']); + } + return $exif; }