From 225b8268bc85e27ec7c5003a646b544d33488fdc Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Thu, 26 Jun 2008 12:10:50 -0400 Subject: [PATCH] Better handle parse errors in nested templates * Template.php: (BSTemplate::evaluate): Don't call ob_end_clean() --- CHANGES | 1 + Template.php | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index cbc06aa..de494b6 100644 --- a/CHANGES +++ b/CHANGES @@ -11,3 +11,4 @@ - New: Implement Iterator in BSDBResult - New: In the BSTemplate::$preParseHook method, the second parameter will be the BSTemplate object itself - New: Add BSTemplate::$globalVars to be substituted into every template +- Change: BSTemplate will better detect parse errors in nested templates in BSTemplate::evaluate() diff --git a/Template.php b/Template.php index 2a03747..1d90c72 100644 --- a/Template.php +++ b/Template.php @@ -197,9 +197,14 @@ class BSTemplate ob_start(); $this->template = str_replace(array('$this->', 'self::'), 'null', $this->template); // don't want internal access coming from a template $this->template = '?>' . $this->template; - eval($this->template); - $this->template = ob_get_clean(); - ob_end_clean(); + $test = eval($this->template); + $output = ob_get_clean(); + if ($output === false) + { + throw new Exception('A parse error was encountered while evaluating the template'); + } + + $this->template = $output; return $this; } -- 2.22.5