- bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834)

This commit is contained in:
uwetews
2015-12-17 21:51:19 +01:00
parent 919861014a
commit 9a8bcb93b1
3 changed files with 127 additions and 123 deletions

View File

@@ -2,6 +2,8 @@
17.12.2015 17.12.2015
- bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135 - bugfix {$smarty.capture.nameFail} did lowercase capture name https://github.com/smarty-php/smarty/issues/135
- bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827) - bugfix using {block append/prepend} on same block in multiple levels of inheritance templates could fail (forum topic 25827)
- bugfix text content consisting of just a single '0' like in {if true}0{/if} was suppressed (forum topic 25834)
16.12.2015 16.12.2015
- bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128 - bugfix {foreach} did fail if from atrribute is a Generator class https://github.com/smarty-php/smarty/issues/128
- bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121 - bugfix direct access $smarty->template_dir = 'foo'; should call Smarty::setTemplateDir() https://github.com/smarty-php/smarty/issues/121

View File

@@ -118,7 +118,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/** /**
* smarty version * smarty version
*/ */
const SMARTY_VERSION = '3.1.29-dev/9'; const SMARTY_VERSION = '3.1.29-dev/10';
/** /**
* define variable scopes * define variable scopes

View File

@@ -328,7 +328,8 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->compileTemplateSource($template, $nocache, $this->compileTemplateSource($template, $nocache,
$parent_compiler), $parent_compiler),
$this->postFilter($this->blockOrFunctionCode) . $this->postFilter($this->blockOrFunctionCode) .
join('', $this->mergedSubTemplatesCode), false, $this); join('', $this->mergedSubTemplatesCode), false,
$this);
return $_compiled_code; return $_compiled_code;
} }
@@ -657,7 +658,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!is_array($function)) { if (!is_array($function)) {
return $function($new_args, $this); return $function($new_args, $this);
} elseif (is_object($function[ 0 ])) { } elseif (is_object($function[ 0 ])) {
return $this->default_handler_plugins[$plugin_type][$tag][0][0]->{$function[1]}($new_args, return $this->default_handler_plugins[ $plugin_type ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($new_args,
$this); $this);
} else { } else {
return call_user_func_array($function, array($new_args, $this)); return call_user_func_array($function, array($new_args, $this));
@@ -716,7 +717,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
if (!is_array($function)) { if (!is_array($function)) {
return $function($args, $this); return $function($args, $this);
} elseif (is_object($function[ 0 ])) { } elseif (is_object($function[ 0 ])) {
return $this->smarty->registered_plugins[Smarty::PLUGIN_COMPILER][$tag][0][0]->{$function[1]}($args, return $this->smarty->registered_plugins[ Smarty::PLUGIN_COMPILER ][ $tag ][ 0 ][ 0 ]->$function[ 1 ]($args,
$this); $this);
} else { } else {
return call_user_func_array($function, array($args, $this)); return call_user_func_array($function, array($args, $this));
@@ -783,6 +784,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
*/ */
public function processText($text) public function processText($text)
{ {
if ((string) $text != '') {
$store = array(); $store = array();
$_store = 0; $_store = 0;
$_offset = 0; $_offset = 0;
@@ -810,8 +812,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5', '#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
'#^\s+<#Ss' => '<', '#^\s+<#Ss' => '<',
'#>\s+$#Ss' => '>', '#>\s+$#Ss' => '>',
$this->stripRegEx => '' $this->stripRegEx => '');
);
$text = preg_replace(array_keys($expressions), array_values($expressions), $text); $text = preg_replace(array_keys($expressions), array_values($expressions), $text);
$_offset = 0; $_offset = 0;
@@ -830,7 +831,6 @@ abstract class Smarty_Internal_TemplateCompilerBase
$text = preg_replace($this->stripRegEx, '', $text); $text = preg_replace($this->stripRegEx, '', $text);
} }
} }
if ($text) {
return new Smarty_Internal_ParseTree_Text($text); return new Smarty_Internal_ParseTree_Text($text);
} }
return null; return null;
@@ -976,7 +976,9 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found"); $this->trigger_template_error("Default plugin handler: Returned script file \"{$script}\" for \"{$tag}\" not found");
} }
} }
if (!is_string($callback) && !(is_array($callback) && is_string($callback[0]) && is_string($callback[1]))) { if (!is_string($callback) &&
!(is_array($callback) && is_string($callback[ 0 ]) && is_string($callback[ 1 ]))
) {
$this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" must be a static function name or array of class and function name"); $this->trigger_template_error("Default plugin handler: Returned callback for \"{$tag}\" must be a static function name or array of class and function name");
} }
if (is_callable($callback)) { if (is_callable($callback)) {