mirror of
https://github.com/smarty-php/smarty.git
synced 2025-08-05 10:54:27 +02:00
added a more robust implementation when removing of the trailing
'<?php '-token after toke_get_all() . this is also a workaround for http://bugs.php.net/bug.php?id=29761
This commit is contained in:
@@ -43,7 +43,19 @@ function smarty_core_write_compiled_include($params, &$smarty)
|
|||||||
if ($this_varname == '_smarty') {
|
if ($this_varname == '_smarty') {
|
||||||
/* rename $this to $_smarty in the sourcecode */
|
/* rename $this to $_smarty in the sourcecode */
|
||||||
$tokens = token_get_all('<?php ' . $_match[4]);
|
$tokens = token_get_all('<?php ' . $_match[4]);
|
||||||
array_shift($tokens); /* remove the opening <.?.php */
|
|
||||||
|
/* remove trailing <?php */
|
||||||
|
$open_tag = '';
|
||||||
|
while ($tokens) {
|
||||||
|
$token = array_shift($tokens);
|
||||||
|
if (is_array($token)) {
|
||||||
|
$open_tag .= $token[1];
|
||||||
|
} else {
|
||||||
|
$open_tag .= $token;
|
||||||
|
}
|
||||||
|
if ($open_tag == '<?php ') break;
|
||||||
|
}
|
||||||
|
|
||||||
for ($i=0, $count = count($tokens); $i < $count; $i++) {
|
for ($i=0, $count = count($tokens); $i < $count; $i++) {
|
||||||
if (is_array($tokens[$i])) {
|
if (is_array($tokens[$i])) {
|
||||||
if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
|
if ($tokens[$i][0] == T_VARIABLE && $tokens[$i][1] == '$this') {
|
||||||
|
Reference in New Issue
Block a user