Browse Source

Merge pull request #446 from adam-vessey/7.x-FLVC-30

Avoid adding on duplicate extensions.
pull/449/head
William Panting 11 years ago
parent
commit
fa9ac96e90
  1. 12
      includes/datastream.inc

12
includes/datastream.inc

@ -53,8 +53,16 @@ function islandora_view_datastream(AbstractDatastream $datastream, $download = F
if ($download) { if ($download) {
// Browsers will not append all extensions. // Browsers will not append all extensions.
$mime_detect = new MimeDetect(); $mime_detect = new MimeDetect();
$extension = $mime_detect->getExtension($datastream->mimetype); $extension = '.' . $mime_detect->getExtension($datastream->mimetype);
$filename = $datastream->label . '.' . $extension;
// Prevent adding on a duplicate extension.
$extension_length = strlen($extension);
$duplicate_extension_position = strripos($datastream->label, $extension, -$extension_length);
$filename = $datastream->label;
if ($duplicate_extension_position === FALSE) {
$filename .= $extension;
}
header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Disposition: attachment; filename=\"$filename\"");
} }

Loading…
Cancel
Save