From d35746dd26e0b0fd0f720307f36dd337e1e88b33 Mon Sep 17 00:00:00 2001 From: "Uwe.Tews" Date: Tue, 10 Nov 2009 16:04:32 +0000 Subject: [PATCH] - fixed preg_qoute on delimiters --- change_log.txt | 3 + .../smarty_internal_compile_include.php | 70 ++++++++++--------- .../smarty_internal_templatelexer.php | 4 +- 3 files changed, 42 insertions(+), 35 deletions(-) diff --git a/change_log.txt b/change_log.txt index dbc8e794..0df4c5e0 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,3 +1,6 @@ +11/10/2009 +- fixed preg_qoute on delimiters + 11/09/2009 - lexer/parser bugfix - new SMARTY_SPL_AUTOLOAD constant to control the autoloader option diff --git a/libs/sysplugins/smarty_internal_compile_include.php b/libs/sysplugins/smarty_internal_compile_include.php index e9277614..0acd9d7a 100644 --- a/libs/sysplugins/smarty_internal_compile_include.php +++ b/libs/sysplugins/smarty_internal_compile_include.php @@ -34,45 +34,49 @@ class Smarty_Internal_Compile_Include extends Smarty_Internal_CompileBase { // check if compiled code can be merged (contains no variable part) if (!$compiler->has_variable_string && (substr_count($include_file, '"') == 2 or substr_count($include_file, "'") == 2) and substr_count($include_file, '(') == 0) { eval("\$tmp = $include_file;"); - if ($this->compiler->template->template_resource != $tmp) { - $tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); - if ($tpl->usesCompiler() && $tpl->isExisting()) { - do { - $must_compile = false; - $prop = array(); - $compiled_tpl = $tpl->getCompiledTemplate(); - preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); - $compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); - // var_dump($matches, $compiled_tpl); - if (isset($matches[2])) { - $prop = unserialize($matches[2]); - foreach ($prop['file_dependency'] as $_file_to_check) { - If (is_file($_file_to_check[0])) { - $mtime = filemtime($_file_to_check[0]); - } else { - $tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); - $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); + if ($this->compiler->template->template_resource != $tmp) { + $tpl = $compiler->smarty->createTemplate ($tmp, $compiler->template->cache_id, $compiler->template->compile_id, $compiler->template); + if ($tpl->usesCompiler() && $tpl->isExisting()) { + do { + $must_compile = false; + $prop = array(); + $compiled_tpl = $tpl->getCompiledTemplate(); + preg_match('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>)/', $compiled_tpl, $matches); + $compiled_tpl = preg_replace(array('/(\<\?php \$_smarty_tpl-\>decodeProperties\(\')(.*)(\'.*\?\>.*\n)/', '/(\<\?php if\(\!defined\(\'SMARTY_DIR\'\)\))(.*)(\?\>.*\n)/'), '', $compiled_tpl); + // var_dump($matches, $compiled_tpl); + if (isset($matches[2])) { + $prop = unserialize($matches[2]); + foreach ($prop['file_dependency'] as $_file_to_check) { + If (is_file($_file_to_check[0])) { + $mtime = filemtime($_file_to_check[0]); + } else { + $tpl->parseResourceName($_file_to_check[0], $resource_type, $resource_name, $resource_handler); + $mtime = $resource_handler->getTemplateTimestampTypeName($resource_type, $resource_name); + } + If ($mtime != $_file_to_check[1]) { + $must_compile = true; + break; + } } - If ($mtime != $_file_to_check[1]) { - $must_compile = true; - break; + if ($must_compile) { + // recompile + $tpl->compileTemplateSource(); } } - if ($must_compile) { - // recompile - $tpl->compileTemplateSource(); + } while ($must_compile); + if (isset($prop['file_dependency'])) { + $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); + } + if (isset($prop['function'])) { + if (isset($compiler->template->properties['function'])) { + $compiler->template->properties['function'] = array_merge((array)$compiler->template->properties['function'], $prop['function']); + } else { + $compiler->template->properties['function'] = $prop['function']; } } - } while ($must_compile); - if (isset($prop['file_dependency'])) { - $compiler->template->properties['file_dependency'] = array_merge($compiler->template->properties['file_dependency'], $prop['file_dependency']); + $has_compiled_template = true; } - if (isset($prop['function'])) { - $compiler->template->properties['function'] = array_merge((array)$compiler->template->properties['function'], $prop['function']); - } - $has_compiled_template = true; - } - } + } } } diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index 01fca1d4..e236f642 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -79,8 +79,8 @@ class Smarty_Internal_Templatelexer $this->counter = 0; $this->line = 1; $this->smarty = $smarty; - $this->ldel = preg_quote($this->smarty->left_delimiter); - $this->rdel = preg_quote($this->smarty->right_delimiter); + $this->ldel = preg_quote($this->smarty->left_delimiter,'/'); + $this->rdel = preg_quote($this->smarty->right_delimiter,'/'); $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; }