diff --git a/etemplate/js/et2_widget_link.js b/etemplate/js/et2_widget_link.js index b25bf5ce71..fb63f724e8 100644 --- a/etemplate/js/et2_widget_link.js +++ b/etemplate/js/et2_widget_link.js @@ -1360,7 +1360,7 @@ var et2_link_string = expose(et2_valueWidget.extend([et2_IDetachedDOM], { var base_url = egw.webserverUrl.match(/^\//,'ig')?egw(window).window.location.origin + egw.webserverUrl : egw.webserverUrl; var mediaContent = []; - if (_value && typeof _value.type !='undefined' && _value.type.match(/video\/|audio\//,'ig')) + if (_value && typeof _value.type !='undefined' && _value.type.match(/video\//,'ig')) { mediaContent = [{ title: _value.id, diff --git a/etemplate/js/et2_widget_vfs.js b/etemplate/js/et2_widget_vfs.js index f9e1cc2fc0..b4f20ca145 100644 --- a/etemplate/js/et2_widget_vfs.js +++ b/etemplate/js/et2_widget_vfs.js @@ -341,7 +341,7 @@ var et2_vfsMime = expose(et2_valueWidget.extend([et2_IDetachedDOM], mediaContent[0].download_href = mediaContent[0].href + '?download'; } } - if (_value && _value.mime && _value.mime.match(/video\/|audio\//,'ig')) + if (_value && _value.mime && _value.mime.match(/video\//,'ig')) { mediaContent[0].thumbnail = this.egw().mime_icon(_value.mime, _value.path, undefined, _value.mtime); } diff --git a/etemplate/js/expose.js b/etemplate/js/expose.js index 2f5d7b599b..914042b35e 100644 --- a/etemplate/js/expose.js +++ b/etemplate/js/expose.js @@ -48,7 +48,10 @@ function expose (widget) }; // For filtering to only show things we can handle - var mime_regex = new RegExp(/(video\/)|(image\/:*(?!tif|x-xcf))|(audio\/)/); + var mime_regex = new RegExp(/(video\/(mp4|ogg|webm))|(image\/:*(?!tif|x-xcf|pdf))/); + + // IE only supports video/mp4 mime type + if (navigator.userAgent.match(/(MSIE|Trident)/)) mime_regex.compile(/(video\/mp4)|(image\/:*(?!tif|x-xcf|pdf))/); // Only one gallery var gallery = null; diff --git a/phpgwapi/inc/class.html.inc.php b/phpgwapi/inc/class.html.inc.php index 586d5fe8f5..7704c18947 100644 --- a/phpgwapi/inc/class.html.inc.php +++ b/phpgwapi/inc/class.html.inc.php @@ -1515,6 +1515,9 @@ egw_LAB.wait(function() { */ public static function safe_content_header(&$content, $path, &$mime='', &$length=0, $nocache=true, $force_download=true, $no_content_type=false) { + // change old/aliased mime-types to new one, eg. image/pdf to application/pdf + $mime = mime_magic::fix_mime_type($mime); + // mitigate risk of serving javascript or css via webdav from our domain, // which will get around same origin policy and CSP list($type, $subtype) = explode('/', strtolower($mime)); diff --git a/phpgwapi/inc/class.mime_magic.inc.php b/phpgwapi/inc/class.mime_magic.inc.php index 945d6c12c3..127f0ee645 100644 --- a/phpgwapi/inc/class.mime_magic.inc.php +++ b/phpgwapi/inc/class.mime_magic.inc.php @@ -123,6 +123,23 @@ class mime_magic return $key; } + /** + * Fix old / aliased mime-types by returning valid/default mime-type + * + * @param string $_alias + * @return string new type, of $alias, if there is no alias defined for it + */ + public static function fix_mime_type($_alias) + { + $alias = strtolower($_alias); + + if (isset(self::$mime_alias_map[$alias])) + { + return self::$mime_alias_map[$alias]; + } + return $alias; + } + /** * Uses variants of the UNIX "file" command to attempt to determine the * MIME type of an unknown file. @@ -1671,6 +1688,7 @@ class mime_magic 'application/x-javascript' => 'application/javascript', 'application/x-troff' => 'text/troff', 'application/x-egroupware-etemplate' => 'application/xml', + 'image/pdf' => 'application/pdf', ); /**