From 6afa5118b49e0cbddb33ee584001ab8ad9b9f793 Mon Sep 17 00:00:00 2001 From: mohrt Date: Fri, 23 Feb 2007 15:41:56 +0000 Subject: [PATCH] fix situation when no compiled tags are present --- libs/Smarty_Compiler.class.php | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libs/Smarty_Compiler.class.php b/libs/Smarty_Compiler.class.php index 30f9ff55..a0eb968d 100644 --- a/libs/Smarty_Compiler.class.php +++ b/libs/Smarty_Compiler.class.php @@ -352,15 +352,17 @@ class Smarty_Compiler extends Smarty { } } $compiled_content = ''; - + $tmp_id = '{'.md5(uniqid(rand(), true)).'}'; /* Interleave the compiled contents and text blocks to get the final result. */ for ($i = 0, $for_max = count($compiled_tags); $i < $for_max; $i++) { + if ($compiled_tags[$i] == '') { // tag result empty, remove first newline from following text block $text_blocks[$i+1] = preg_replace('~^(\r\n|\r|\n)~', '', $text_blocks[$i+1]); } + // replace legit PHP tags with placeholder $text_blocks[$i] = str_replace('\n",$compiled_content); - // unescape legit tags - $compiled_content = str_replace($tmp_id,'0) + { + // escape created php tags + $compiled_content = str_replace('\n",$compiled_content); + // recover legit tags + $compiled_content = str_replace($tmp_id,'