From 06071f2f5fd63b49552cc0c531db64a4cbedb0b9 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 25 Oct 2021 17:48:58 +0200 Subject: [PATCH] LStemplate: detect and stop template displaying loop --- src/includes/class/class.LStemplate.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/includes/class/class.LStemplate.php b/src/includes/class/class.LStemplate.php index c77732be..cb8d0a01 100644 --- a/src/includes/class/class.LStemplate.php +++ b/src/includes/class/class.LStemplate.php @@ -90,6 +90,9 @@ class LStemplate extends LSlog_staticLoggerClass { 'top.tpl', 'bottom.tpl', ); + // Keep trace of last displayed template (for loop detection) + private static $last_displayed_template = null; + /** * Start LStemplate * @@ -419,6 +422,12 @@ class LStemplate extends LSlog_staticLoggerClass { // Trigger displaying event self :: fireEvent('displaying'); + // Handle loop detection + if (self :: $last_displayed_template == $template) { + self :: log_error("display($template): loop detected, stop"); + return; + } + try { self :: assignCommonVars(); self :: $_smarty -> display("ls:$template");