diff --git a/includes/datastream.inc b/includes/datastream.inc index 26a7a8d5..ba2872c2 100644 --- a/includes/datastream.inc +++ b/includes/datastream.inc @@ -56,9 +56,12 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F $extension = '.' . $mime_detect->getExtension($datastream->mimetype); // Prevent adding on a duplicate extension. + $label = $datastream->label; $extension_length = strlen($extension); - $duplicate_extension_position = strripos($datastream->label, $extension, -$extension_length); - $filename = $datastream->label; + $duplicate_extension_position = strlen($label) > $extension_length ? + strripos($label, $extension, -$extension_length) : + FALSE; + $filename = $label; if ($duplicate_extension_position === FALSE) { $filename .= $extension; }