diff --git a/conf/default.php b/conf/default.php index 5515176..09fdf9e 100644 --- a/conf/default.php +++ b/conf/default.php @@ -7,3 +7,4 @@ $conf['allow_in_comments'] = 0; $conf['allowed_absolute_paths'] = DOKU_INC; $conf['web_paths'] = DOKU_URL; $conf['defaults'] = ''; +$conf['extensions'] = ''; diff --git a/conf/metadata.php b/conf/metadata.php index b746aaa..15ca6c8 100644 --- a/conf/metadata.php +++ b/conf/metadata.php @@ -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'); diff --git a/lang/en/settings.php b/lang/en/settings.php index c47a5b1..741a1ac 100644 --- a/lang/en/settings.php +++ b/lang/en/settings.php @@ -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'; diff --git a/syntax.php b/syntax.php index e1b2745..0231803 100644 --- a/syntax.php +++ b/syntax.php @@ -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)));