From 1f412bd1d487ad7e22041ed75a3b2778b7eb0b24 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Mon, 19 Feb 2018 22:10:15 +0100 Subject: [PATCH] Fix infinite redirects --- htdocs/core/lib/website.lib.php | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/htdocs/core/lib/website.lib.php b/htdocs/core/lib/website.lib.php index dbd3acd794a..c8e59c4e6af 100644 --- a/htdocs/core/lib/website.lib.php +++ b/htdocs/core/lib/website.lib.php @@ -184,7 +184,23 @@ function redirectToContainer($containeralias) unset($tmpwebsitepage); if ($result > 0) { - $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $_SERVER["REQUEST_URI"]); + $currenturi = $_SERVER["REQUEST_URI"]; + if (preg_match('/&pageref=([^&]+)/', $currenturi, $regtmp)) + { + if ($regtmp[0] == $containeralias) + { + print "Error, page with uri '.$currenturi.' try a redirect to the same alias page '".$containeralias."' in web site '".$website->ref."'"; + exit; + } + else + { + $newurl = preg_replace('/&pageref=([^&]+)/', '&pageref='.$containeralias, $currenturi); + } + } + else + { + $newurl = $currenturi.'&pageref='.urlencode($containeralias); + } } } else // When page called from virtual host server @@ -199,7 +215,7 @@ function redirectToContainer($containeralias) } else { - print "Error, page contains a reditect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; + print "Error, page contains a redirect to the alias page '".$containeralias."' that does not exists in web site '".$website->ref."'"; exit; } }