mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-25 17:33:49 +01:00
* Etemplate: Fix issue expose view gets opened for not supported mime-type (eg. image/pdf)
This commit is contained in:
parent
524c16e536
commit
9a4ba7b781
@ -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,
|
||||
|
@ -345,7 +345,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);
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -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));
|
||||
|
@ -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',
|
||||
);
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user