mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
- bugfix template inheritace did fail if mbstring.func_overload != 0 (issue 70) (Forum Topic 20680)
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
===== trunk =====
|
===== trunk =====
|
||||||
22.12.2011
|
22.12.2011
|
||||||
- bugfix the new lexer of 17.12.2011 did fail if mbstring.func_overload != 0 (issue 70) (Forum Topic 20680)
|
- bugfix the new lexer of 17.12.2011 did fail if mbstring.func_overload != 0 (issue 70) (Forum Topic 20680)
|
||||||
|
- bugfix template inheritace did fail if mbstring.func_overload != 0 (issue 70) (Forum Topic 20680)
|
||||||
|
|
||||||
20.12.2011
|
20.12.2011
|
||||||
- bugfix template inheritance: {$smarty.block.child} in nested child {block} tags did not return
|
- bugfix template inheritance: {$smarty.block.child} in nested child {block} tags did not return
|
||||||
|
@@ -32,6 +32,12 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
|||||||
* @see Smarty_Internal_CompileBase
|
* @see Smarty_Internal_CompileBase
|
||||||
*/
|
*/
|
||||||
public $shorttag_order = array('file');
|
public $shorttag_order = array('file');
|
||||||
|
/**
|
||||||
|
* mbstring.overload flag
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $mbstring_overload = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compiles code for the {extends} tag
|
* Compiles code for the {extends} tag
|
||||||
@@ -46,6 +52,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
|||||||
$this->_rdl = preg_quote($compiler->smarty->right_delimiter);
|
$this->_rdl = preg_quote($compiler->smarty->right_delimiter);
|
||||||
$this->_ldl = preg_quote($compiler->smarty->left_delimiter);
|
$this->_ldl = preg_quote($compiler->smarty->left_delimiter);
|
||||||
$filepath = $compiler->template->source->filepath;
|
$filepath = $compiler->template->source->filepath;
|
||||||
|
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||||
// check and get attributes
|
// check and get attributes
|
||||||
$_attr = $this->getAttributes($compiler, $args);
|
$_attr = $this->getAttributes($compiler, $args);
|
||||||
if ($_attr['nocache'] === true) {
|
if ($_attr['nocache'] === true) {
|
||||||
@@ -70,7 +77,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
|||||||
$compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
|
$compiler->trigger_template_error("illegal recursive call of \"{$include_file}\"", $compiler->lex->line - 1);
|
||||||
}
|
}
|
||||||
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
|
$compiler->template->properties['file_dependency'][$template_sha1] = array($_template->source->filepath, $_template->source->timestamp, $_template->source->type);
|
||||||
$_content = substr($compiler->template->source->content, $compiler->lex->counter - 1);
|
$_content = ($this->mbstring_overload ? mb_substr($compiler->template->source->content, $compiler->lex->counter - 1, 20000000, 'latin1') : substr($compiler->template->source->content, $compiler->lex->counter - 1));
|
||||||
if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
|
if (preg_match_all("!({$this->_ldl}block\s(.+?){$this->_rdl})!", $_content, $s) !=
|
||||||
preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
|
preg_match_all("!({$this->_ldl}/block{$this->_rdl})!", $_content, $c)) {
|
||||||
$compiler->trigger_template_error('unmatched {block} {/block} pairs');
|
$compiler->trigger_template_error('unmatched {block} {/block} pairs');
|
||||||
@@ -81,13 +88,13 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
|||||||
while ($_start+1 < $_result_count) {
|
while ($_start+1 < $_result_count) {
|
||||||
$_end = 0;
|
$_end = 0;
|
||||||
$_level = 1;
|
$_level = 1;
|
||||||
if (substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
|
if (($this->mbstring_overload ? mb_substr($_result[0][$_start][0],0,mb_strlen($compiler->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.'*') {
|
||||||
$_start++;
|
$_start++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while ($_level != 0) {
|
while ($_level != 0) {
|
||||||
$_end++;
|
$_end++;
|
||||||
if (substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1) == $compiler->smarty->left_delimiter.'*') {
|
if (($this->mbstring_overload ? mb_substr($_result[0][$_start + $_end][0],0,mb_strlen($compiler->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start + $_end][0],0,strlen($compiler->smarty->left_delimiter)+1)) == $compiler->smarty->left_delimiter.'*') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strpos($_result[0][$_start + $_end][0], '/')) {
|
if (!strpos($_result[0][$_start + $_end][0], '/')) {
|
||||||
@@ -97,7 +104,7 @@ class Smarty_Internal_Compile_Extends extends Smarty_Internal_CompileBase {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_block_content = str_replace($compiler->smarty->left_delimiter . '$smarty.block.parent' . $compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
|
$_block_content = str_replace($compiler->smarty->left_delimiter . '$smarty.block.parent' . $compiler->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
|
||||||
substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0])));
|
($this->mbstring_overload ? mb_substr($_content, $_result[0][$_start][1] + mb_strlen($_result[0][$_start][0], 'latin1'), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + mb_strlen($_result[0][$_start][0], 'latin1'), 'latin1') : substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))));
|
||||||
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
|
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $compiler->template, $filepath);
|
||||||
$_start = $_start + $_end + 1;
|
$_start = $_start + $_end + 1;
|
||||||
}
|
}
|
||||||
|
@@ -18,6 +18,13 @@
|
|||||||
*/
|
*/
|
||||||
class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* mbstring.overload flag
|
||||||
|
*
|
||||||
|
* @var int
|
||||||
|
*/
|
||||||
|
public $mbstring_overload = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* populate Source Object with meta data from Resource
|
* populate Source Object with meta data from Resource
|
||||||
*
|
*
|
||||||
@@ -79,6 +86,7 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
|||||||
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
throw new SmartyException("Unable to read template {$source->type} '{$source->name}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->mbstring_overload = ini_get('mbstring.func_overload') & 2;
|
||||||
$_rdl = preg_quote($source->smarty->right_delimiter);
|
$_rdl = preg_quote($source->smarty->right_delimiter);
|
||||||
$_ldl = preg_quote($source->smarty->left_delimiter);
|
$_ldl = preg_quote($source->smarty->left_delimiter);
|
||||||
$_components = array_reverse($source->components);
|
$_components = array_reverse($source->components);
|
||||||
@@ -107,13 +115,13 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
|||||||
while ($_start+1 < $_result_count) {
|
while ($_start+1 < $_result_count) {
|
||||||
$_end = 0;
|
$_end = 0;
|
||||||
$_level = 1;
|
$_level = 1;
|
||||||
if (substr($_result[0][$_start][0],0,strlen($source->smarty->left_delimiter)+1) == $source->smarty->left_delimiter.'*') {
|
if (($this->mbstring_overload ? mb_substr($_result[0][$_start][0],0,mb_strlen($source->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start][0],0,strlen($source->smarty->left_delimiter)+1)) == $source->smarty->left_delimiter.'*') {
|
||||||
$_start++;
|
$_start++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
while ($_level != 0) {
|
while ($_level != 0) {
|
||||||
$_end++;
|
$_end++;
|
||||||
if (substr($_result[0][$_start + $_end][0],0,strlen($source->smarty->left_delimiter)+1) == $source->smarty->left_delimiter.'*') {
|
if (($this->mbstring_overload ? mb_substr($_result[0][$_start + $_end][0],0,mb_strlen($source->smarty->left_delimiter,'latin1')+1, 'latin1') : substr($_result[0][$_start + $_end][0],0,strlen($source->smarty->left_delimiter)+1)) == $source->smarty->left_delimiter.'*') {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strpos($_result[0][$_start + $_end][0], '/')) {
|
if (!strpos($_result[0][$_start + $_end][0], '/')) {
|
||||||
@@ -122,7 +130,8 @@ class Smarty_Internal_Resource_Extends extends Smarty_Resource {
|
|||||||
$_level--;
|
$_level--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$_block_content = str_replace($source->smarty->left_delimiter . '$smarty.block.parent' . $source->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%', substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0])));
|
$_block_content = str_replace($source->smarty->left_delimiter . '$smarty.block.parent' . $source->smarty->right_delimiter, '%%%%SMARTY_PARENT%%%%',
|
||||||
|
($this->mbstring_overload ? mb_substr($_content, $_result[0][$_start][1] + mb_strlen($_result[0][$_start][0], 'latin1'), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + mb_strlen($_result[0][$_start][0], 'latin1'), 'latin1') : substr($_content, $_result[0][$_start][1] + strlen($_result[0][$_start][0]), $_result[0][$_start + $_end][1] - $_result[0][$_start][1] - + strlen($_result[0][$_start][0]))));
|
||||||
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $source->template, $_component->filepath);
|
Smarty_Internal_Compile_Block::saveBlockData($_block_content, $_result[0][$_start][0], $source->template, $_component->filepath);
|
||||||
$_start = $_start + $_end + 1;
|
$_start = $_start + $_end + 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user