mirror of
https://github.com/smarty-php/smarty.git
synced 2026-04-28 18:02:07 +02:00
- make the date_format modifier work also on objects of the DateTime class
- implementation of parsetrees in the parser to close security holes and remove unwanted empty line in HTML output
This commit is contained in:
@@ -26,7 +26,7 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
$this->optional_attributes = array('_any');
|
||||
// check and get attributes
|
||||
$_attr = $this->_get_attributes($args);
|
||||
$save = array($_attr, $compiler->template->extracted_compiled_code, $compiler->template->extract_code,
|
||||
$save = array($_attr, $compiler->parser->current_buffer,
|
||||
$compiler->template->has_nocache_code, $compiler->template->required_plugins);
|
||||
$this->_open_tag('function', $save);
|
||||
$_name = trim($_attr['name'], "'\"");
|
||||
@@ -46,8 +46,8 @@ class Smarty_Internal_Compile_Function extends Smarty_Internal_CompileBase {
|
||||
}
|
||||
// Init temporay context
|
||||
$compiler->template->required_plugins = array('compiled' => array(), 'nocache' => array());
|
||||
$compiler->template->extract_code = true;
|
||||
$compiler->template->extracted_compiled_code = $output;
|
||||
$compiler->parser->current_buffer = new _smarty_template_buffer($compiler->parser);
|
||||
$compiler->parser->current_buffer->append_subtree(new _smarty_tag($compiler->parser, $output));
|
||||
$compiler->template->has_nocache_code = false;
|
||||
$compiler->has_code = false;
|
||||
$compiler->template->properties['function'][$_name]['compiled'] = '';
|
||||
@@ -95,20 +95,19 @@ class Smarty_Internal_Compile_Functionclose extends Smarty_Internal_CompileBase
|
||||
// if caching save template function for possible nocache call
|
||||
if ($compiler->template->caching) {
|
||||
$compiler->template->properties['function'][$_name]['compiled'] .= $plugins_string
|
||||
. $compiler->template->extracted_compiled_code;
|
||||
. $compiler->parser->current_buffer->to_smarty_php();
|
||||
$compiler->template->properties['function'][$_name]['nocache_hash'] = $compiler->template->properties['nocache_hash'];
|
||||
$compiler->template->properties['function'][$_name]['has_nocache_code'] = $compiler->template->has_nocache_code;
|
||||
$compiler->smarty->template_functions[$_name] = $compiler->template->properties['function'][$_name];
|
||||
$compiler->has_code = false;
|
||||
$output = true;
|
||||
} else {
|
||||
$output = $plugins_string . $compiler->template->extracted_compiled_code . "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}}?>\n";
|
||||
$output = $plugins_string . $compiler->parser->current_buffer->to_smarty_php() . "<?php \$_smarty_tpl->tpl_vars = \$saved_tpl_vars;}}?>\n";
|
||||
}
|
||||
// restore old compiler status
|
||||
$compiler->template->extracted_compiled_code = $saved_data[1];
|
||||
$compiler->template->extract_code = $saved_data[2];
|
||||
$compiler->template->has_nocache_code = $compiler->template->has_nocache_code | $saved_data[3];
|
||||
$compiler->template->required_plugins = $saved_data[4];
|
||||
$compiler->parser->current_buffer = $saved_data[1];
|
||||
$compiler->template->has_nocache_code = $compiler->template->has_nocache_code | $saved_data[2];
|
||||
$compiler->template->required_plugins = $saved_data[3];
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user