From 40b86b66903c99844084edc3723e65e5631622e6 Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sun, 25 Aug 2019 10:02:06 +0200 Subject: [PATCH 1/2] Correctly balance parenthesis in regex --- base.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/base.php b/base.php index f3c0b69c..950c7082 100644 --- a/base.php +++ b/base.php @@ -1449,7 +1449,7 @@ function reroute($url=NULL,$permanent=FALSE,$die=TRUE) { $url=$this->hive['REALM']; if (is_array($url)) $url=call_user_func_array([$this,'alias'],$url); - elseif (preg_match('/^(?:@?([^\/()?]+)(?:(\(.+?)\))*(\?.+)*)/', + elseif (preg_match('/^(?:@?([^\/()?]+)(?:\((.+?)\))*(\?.+)*)/', $url,$parts) && isset($this->hive['ALIASES'][$parts[1]])) $url=$this->hive['ALIASES'][$parts[1]]; From 6d775546df6b15e429851fe15746a12ac382cedf Mon Sep 17 00:00:00 2001 From: Mathieu Date: Sun, 25 Aug 2019 10:04:44 +0200 Subject: [PATCH 2/2] Fix #1156: Allow adding fragment to reroute --- base.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/base.php b/base.php index 950c7082..2dbc7ba0 100644 --- a/base.php +++ b/base.php @@ -1449,12 +1449,12 @@ function reroute($url=NULL,$permanent=FALSE,$die=TRUE) { $url=$this->hive['REALM']; if (is_array($url)) $url=call_user_func_array([$this,'alias'],$url); - elseif (preg_match('/^(?:@?([^\/()?]+)(?:\((.+?)\))*(\?.+)*)/', + elseif (preg_match('/^(?:@?([^\/()?]+)(?:\((.+?)\))*(\?[^#]+)*(#.+)*)/', $url,$parts) && isset($this->hive['ALIASES'][$parts[1]])) $url=$this->hive['ALIASES'][$parts[1]]; $url=$this->build($url,isset($parts[2])?$this->parse($parts[2]):[]). - (isset($parts[3])?$parts[3]:''); + (isset($parts[3])?$parts[3]:'').(isset($parts[4])?$parts[4]:''); if (($handler=$this->hive['ONREROUTE']) && $this->call($handler,[$url,$permanent,$die])!==FALSE) return;