added option to limit listings to certain file extensions
This commit is contained in:
committed by
Adrian Lang
parent
30f6a886d8
commit
a269b44c6a
@@ -7,3 +7,4 @@ $conf['allow_in_comments'] = 0;
|
||||
$conf['allowed_absolute_paths'] = DOKU_INC;
|
||||
$conf['web_paths'] = DOKU_URL;
|
||||
$conf['defaults'] = '';
|
||||
$conf['extensions'] = '';
|
||||
|
||||
@@ -10,4 +10,5 @@ $meta['allow_in_comments'] = array('onoff');
|
||||
$meta['allowed_absolute_paths'] = array('');
|
||||
$meta['web_paths'] = array('');
|
||||
$meta['defaults'] = array('string');
|
||||
$meta['extensions'] = array('string');
|
||||
|
||||
|
||||
@@ -4,3 +4,4 @@ $lang['allow_in_comments'] = 'Whether to allow the filelist syntax to be used in
|
||||
$lang['allowed_absolute_paths'] = 'Comma-separated list of absolute paths allowed for globbing.';
|
||||
$lang['web_paths'] = 'Comma-separated list of urls by which to reach the corresponding absolute path from the previous list. MUST have the exact same number of entries as allowed_absolute_paths.';
|
||||
$lang['defaults'] = 'Default options. Use the same syntax as in inline configuration';
|
||||
$lang['extensions'] = 'Comma-separated listof allowed file extensions to list';
|
||||
|
||||
@@ -582,6 +582,11 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
$ext = explode(',',$this->getConf('extensions'));
|
||||
$ext = array_map('trim',$ext);
|
||||
$ext = array_map('preg_quote_cb',$ext);
|
||||
$ext = join('|',$ext);
|
||||
|
||||
if (($dir = opendir($path)) !== false) {
|
||||
$result = array();
|
||||
while (($file = readdir($dir)) !== false) {
|
||||
@@ -600,6 +605,10 @@ class syntax_plugin_filelist extends DokuWiki_Syntax_Plugin {
|
||||
$filepath = $path . '/' . $file;
|
||||
|
||||
if ($this->_fnmatch($match, $file) || (is_dir($filepath) && $params['recursive'])) {
|
||||
if(!is_dir($filepath) && !preg_match('/('.$ext.')$/i',$file)){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$params['direct']) {
|
||||
// exclude prohibited media files via ACLs
|
||||
$mid = str_replace('/', ':', substr($filepath, strlen($this->mediadir)));
|
||||
|
||||
Reference in New Issue
Block a user