From a3dabf0a1ab447440c80d4032dbca0cf05db6f7d Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@unibe.ch> Date: Mon, 28 Aug 2023 14:36:36 +0200 Subject: [PATCH] fix loop over config with missing regex section. --- public_html/classes/redirect.class.php | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public_html/classes/redirect.class.php b/public_html/classes/redirect.class.php index 7d9231d..c04108a 100644 --- a/public_html/classes/redirect.class.php +++ b/public_html/classes/redirect.class.php @@ -23,6 +23,7 @@ * 2019-04-25 v1.2 ah use REQUEST_URI (works on Win and Linux) * 2020-05-06 v1.3 ah added aliases for multiple domains with the same config * 2020-05-06 v1.4 ah rewrite as class + * 2023-08-28 v1.5 ah fix loop over config with missing regex section. */ /** @@ -229,13 +230,14 @@ class redirect { $aRedirect = $this->aConfig['direct'][$this->sRequest]; } else { $this->_wd("no direct match ... scanning regex"); - foreach (array_keys($this->aConfig['regex']) as $sRegex) { - - $this->_wd("check if regex [$sRegex] matches $this->sRequest"); - if (preg_match('#' . $sRegex . '#', $this->sRequest)) { - $this->_wd("REGEX MATCH! aborting tests"); - $aRedirect = $this->aConfig['regex'][$sRegex]; - break; + if(isset($this->aConfig['regex']) && is_array($this->aConfig['regex'])){ + foreach (array_keys($this->aConfig['regex']) as $sRegex) { + $this->_wd("check if regex [$sRegex] matches $this->sRequest"); + if (preg_match('#' . $sRegex . '#', $this->sRequest)) { + $this->_wd("REGEX MATCH! aborting tests"); + $aRedirect = $this->aConfig['regex'][$sRegex]; + break; + } } } } -- GitLab