diff --git a/src/_h5ai/config.php b/src/_h5ai/config.php index 8096a5b2..8ab74296 100644 --- a/src/_h5ai/config.php +++ b/src/_h5ai/config.php @@ -7,20 +7,23 @@ */ global $H5AI_CONFIG; -$H5AI_CONFIG = array(); -/* - * This configuration assumes that h5ai is installed - * in the webroot directory of the Apache server. - */ -$H5AI_CONFIG["ROOT_ABS_PATH"] = safe_dirname(safe_dirname(__FILE__)); +$H5AI_CONFIG = array( -/* - * Files/folders that should not be listed. Specified - * by the complete filename or by a regular expression. - * http://www.php.net/manual/en/function.preg-match.php - */ -$H5AI_CONFIG["IGNORE"] = array(); -$H5AI_CONFIG["IGNORE_PATTERNS"] = array("/^\\./", "/^_h5ai/"); + /* + * This configuration assumes that h5ai is installed + * in the webroot directory of the Apache server. + */ + "ROOT_ABS_PATH" => safe_dirname(safe_dirname(__FILE__)), + + /* + * Files/folders that should not be listed. Specified + * by the complete filename or by a regular expression. + * http://www.php.net/manual/en/function.preg-match.php + */ + "IGNORE" => array(), + "IGNORE_PATTERNS" => array("/^\\./", "/^_h5ai/") + +); ?> \ No newline at end of file diff --git a/src/_h5ai/js/inc/Finder.js b/src/_h5ai/js/inc/Finder.js index 6ef9fd90..60771f7b 100644 --- a/src/_h5ai/js/inc/Finder.js +++ b/src/_h5ai/js/inc/Finder.js @@ -38,6 +38,18 @@ $filter.removeClass('current'); } }, + parseFilterSequence = function (sequence) { + + if (sequence.substr(0,3) === 're:') { + return new RegExp(sequence.substr(3)); + } + + sequence = $.map($.trim(sequence).split(/\s+/), function (part) { + + return H5AI.util.reEscape(part); + }).join('|'); + return new RegExp(sequence); + }, init = function () { if (H5AI.core.settings.showFilter) { @@ -63,7 +75,7 @@ val = $input.val(); if (val) { - filter(new RegExp(val)); + filter(parseFilterSequence(val)); } else { filter(); } diff --git a/src/_h5ai/js/inc/Util.js b/src/_h5ai/js/inc/Util.js index ed3f298e..3fa02f5d 100644 --- a/src/_h5ai/js/inc/Util.js +++ b/src/_h5ai/js/inc/Util.js @@ -100,6 +100,10 @@ return decodeURI(uri); } catch (err) {} return uri; + }, + reEscape = function (sequence) { + + return sequence.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&'); }; return { @@ -108,7 +112,8 @@ getAbsHref: getAbsHref, parseSize: parseSize, formatSize: formatSize, - checkedDecodeUri: checkedDecodeUri + checkedDecodeUri: checkedDecodeUri, + reEscape: reEscape }; }()); diff --git a/src/_h5ai/php/api.php b/src/_h5ai/php/api.php index 72330882..c2a8de1c 100644 --- a/src/_h5ai/php/api.php +++ b/src/_h5ai/php/api.php @@ -14,11 +14,6 @@ function require_h5ai($lib) { } -require_h5ai("/php/inc/H5ai.php"); -$h5ai = new H5ai(); -$options = $h5ai->getOptions(); - - function fail($code, $msg, $cond = true) { if ($cond) { echo "$code: $msg"; @@ -36,6 +31,11 @@ function checkKeys($keys) { } +require_h5ai("/php/inc/H5ai.php"); +$h5ai = new H5ai(); +$options = $h5ai->getOptions(); + + list($action) = checkKeys(array("action")); diff --git a/src/_h5ai/php/inc/H5ai.php b/src/_h5ai/php/inc/H5ai.php index 6d25807c..4a70aced 100644 --- a/src/_h5ai/php/inc/H5ai.php +++ b/src/_h5ai/php/inc/H5ai.php @@ -256,8 +256,8 @@ class H5ai { public function getHttpCode($absHref) { - return $this->cachedHttpCode($absHref); - // return $this->fetchHttpCode($absHref); + //return $this->cachedHttpCode($absHref); + return $this->fetchHttpCode($absHref); // return $this->guessHttpCode($absHref); }