allow perl regular expression as mime-type filter

This commit is contained in:
Ralf Becker 2015-01-19 16:09:16 +00:00
parent 94ea53a688
commit b6a83398a4

View File

@ -417,7 +417,7 @@ class egw_vfs extends vfs_stream_wrapper
* - name,path => pattern with *,? wildcards, eg. "*.php" * - name,path => pattern with *,? wildcards, eg. "*.php"
* - name_preg,path_preg => preg regular expresion, eg. "/(vfs|wrapper)/" * - name_preg,path_preg => preg regular expresion, eg. "/(vfs|wrapper)/"
* - uid,user,gid,group,nouser,nogroup file belongs to user/group with given name or (numerical) id * - uid,user,gid,group,nouser,nogroup file belongs to user/group with given name or (numerical) id
* - mime => type[/subtype] * - mime => type[/subtype] or perl regular expression starting with a "/" eg. "/^(image|video)\\//i"
* - empty,size => (+|-|)N * - empty,size => (+|-|)N
* - cmin/mmin => (+|-|)N file/dir create/modified in the last N minutes * - cmin/mmin => (+|-|)N file/dir create/modified in the last N minutes
* - ctime/mtime => (+|-|)N file/dir created/modified in the last N days * - ctime/mtime => (+|-|)N file/dir created/modified in the last N days
@ -667,11 +667,21 @@ class egw_vfs extends vfs_stream_wrapper
} }
if (isset($options['mime']) && $options['mime'] != $stat['mime']) if (isset($options['mime']) && $options['mime'] != $stat['mime'])
{ {
list($type,$subtype) = explode('/',$options['mime']); if ($options['mime'][0] == '/') // perl regular expression given
// no subtype (eg. 'image') --> check only the main type
if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
{ {
return; // wrong mime-type if (!preg_match($options['mime'], $stat['mime']))
{
return; // wrong mime-type
}
}
else
{
list($type,$subtype) = explode('/',$options['mime']);
// no subtype (eg. 'image') --> check only the main type
if ($subtype || substr($stat['mime'],0,strlen($type)+1) != $type.'/')
{
return; // wrong mime-type
}
} }
} }
if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) || if (isset($options['size']) && !self::_check_num($stat['size'],$options['size']) ||