mirror of
https://github.com/smarty-php/smarty.git
synced 2025-12-16 02:28:31 +01:00
--- this is a major update with a couple of internal changes ---
- new config file lexer/parser (thanks to Thue Jnaus Kristensen)
- template lexer/parser fixes for PHP and {literal} handing (thanks to Thue Jnaus Kristensen)
- fix on registered plugins with different type but same name
- rewrite of plugin handling (optimized execution speed)
- closed a security hole regarding PHP code injection into cache files
- fixed bug in clear cache handling
- Renamed a couple of internal classes
- code cleanup for merging compiled templates
- couple of runtime optimizations (still not all done)
This commit is contained in:
@@ -29,6 +29,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code);
|
||||
$this->_open_tag('function', $save);
|
||||
$_name = trim($_attr['name'], "'");
|
||||
unset($_attr['name']);
|
||||
foreach ($_attr as $_key => $_data) {
|
||||
$compiler->template->properties['function'][$_name]['parameter'][$_key] = $_data;
|
||||
}
|
||||
@@ -56,20 +57,13 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
{
|
||||
$this->compiler = $compiler;
|
||||
$this->compiler->has_code = false;
|
||||
// turn off block code extraction
|
||||
$compiler->template->extract_code = false;
|
||||
// check and get attributes
|
||||
$this->optional_attributes = array('name');
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$saved_data = $this->_close_tag(array('function'));
|
||||
// if name does match to opening tag
|
||||
if (isset($_attr['name']) && $saved_data[0]['name'] != $_attr['name']) {
|
||||
$this->compiler->trigger_template_error('mismatching name attributes "' . $saved_data[0]['name'] . '" and "' . $_attr['name'] . '"');
|
||||
}
|
||||
$_name = trim($saved_data[0]['name'], "'");
|
||||
$compiler->template->properties['function'][$_name]['compiled'] = str_replace("\n",'_%n',$compiler->template->extracted_compiled_code);
|
||||
$compiler->template->properties['function'][$_name]['compiled'] = $compiler->template->extracted_compiled_code;
|
||||
$this->compiler->smarty->template_functions[$_name]['compiled'] = $compiler->template->extracted_compiled_code;
|
||||
$this->compiler->smarty->template_functions[$_name]['parameter'] = $compiler->template->properties['function'][$_name]['parameter'];
|
||||
// restore old code extraction status
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
return true;
|
||||
|
||||
Reference in New Issue
Block a user