diff --git a/lib/Listener/ExifMetadataProvider.php b/lib/Listener/ExifMetadataProvider.php index a10b8e1a6..77508e0c0 100644 --- a/lib/Listener/ExifMetadataProvider.php +++ b/lib/Listener/ExifMetadataProvider.php @@ -88,11 +88,11 @@ public function handle(Event $event): void { } if ($rawExifData && array_key_exists('EXIF', $rawExifData)) { - $event->getMetadata()->setArray('photos-exif', $this->sanitizeEntries($rawExifData['EXIF'])); + $event->getMetadata()->setArray('photos-exif', $this->sanitizeEntries($rawExifData['EXIF'], $node)); } if ($rawExifData && array_key_exists('IFD0', $rawExifData)) { - $event->getMetadata()->setArray('photos-ifd0', $this->sanitizeEntries($rawExifData['IFD0'])); + $event->getMetadata()->setArray('photos-ifd0', $this->sanitizeEntries($rawExifData['IFD0'], $node)); } if ( @@ -154,7 +154,7 @@ private function parseGPSData(string $rawData): float { * * @param array $data */ - private function sanitizeEntries(array $data): array { + private function sanitizeEntries(array $data, File $node): array { $cleanData = []; foreach ($data as $key => $value) { @@ -169,7 +169,19 @@ private function sanitizeEntries(array $data): array { $key = preg_replace('/[^a-zA-Z]/', '_', $key); } - $cleanData[$key] = $value; + // Arbitrary limit to filter out large EXIF entries. + if (is_string($value) && strlen($value) > 1000) { + $this->logger->info( + "EXIF entry ignored as it is too large", + [ + 'key' => $key, + 'value' => $value, + 'fileId' => $node->getId(), + ] + ); + } else { + $cleanData[$key] = $value; + } } return $cleanData;