system: deal with ACL trailing slash wildcards

This commit is contained in:
Franco Fichtner 2018-07-28 19:32:47 +02:00
parent c383d0ae61
commit c66f241df7

View File

@ -183,7 +183,13 @@ class ACL
*/
private function urlMatch($url, $urlmask)
{
$match = str_replace(array(".", "*","?"), array("\.", ".*","\?"), $urlmask);
/* "." and "?" have no effect on match, but "*" is a wildcard */
$match = str_replace(array('.', '*','?'), array('\.', '.*','\?'), $urlmask);
/* if pattern ends with '/.*' optionally match for flat URL mask */
$match = preg_replace('@/\.\*$@', '(/.*)?', $match);
/* remove client side pattern from given URL */
$url = preg_replace('@#.*$@', '', $url);
$result = preg_match("@^/{$match}$@", "{$url}");
if ($result) {
return true;
@ -285,7 +291,8 @@ class ACL
if ($pattern == "*") {
return "index.php";
} elseif (!empty($pattern)) {
return str_replace('*', '', $pattern);
/* remove wildcard and optional trailing slashes */
return preg_replace('@/?\*$@', '', $pattern);
}
break;
}