0
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2024-09-19 19:22:14 +02:00

bump Smarty to v3.1.35

This commit is contained in:
David Goodwin 2020-04-17 09:13:00 +01:00
parent b3e5514709
commit 1b517a72ff
16 changed files with 1560 additions and 1379 deletions

View File

@ -90,7 +90,7 @@ class Smarty_Autoloader
*/
public static function autoload($class)
{
if ($class[ 0 ] !== 'S' && strpos($class, 'Smarty') !== 0) {
if ($class[ 0 ] !== 'S' || strpos($class, 'Smarty') !== 0) {
return;
}
$_class = strtolower($class);

View File

@ -27,7 +27,7 @@
* @author Uwe Tews <uwe dot tews at gmail dot com>
* @author Rodney Rehm
* @package Smarty
* @version 3.1.33
* @version 3.1.34-dev
*/
/**
* set SMARTY_DIR to absolute path to Smarty library files.
@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.33';
const SMARTY_VERSION = '3.1.34-dev-7';
/**
* define variable scopes
*/

View File

@ -41,9 +41,9 @@ function smarty_modifier_date_format($string, $format = null, $default_date = ''
}
$is_loaded = true;
}
if ($string !== '' && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
if (!empty($string) && $string !== '0000-00-00' && $string !== '0000-00-00 00:00:00') {
$timestamp = smarty_make_timestamp($string);
} elseif ($default_date !== '') {
} elseif (!empty($default_date)) {
$timestamp = smarty_make_timestamp($default_date);
} else {
return;

View File

@ -83,7 +83,7 @@ class Smarty_Internal_Compile_Assign extends Smarty_Internal_CompileBase
if (isset($parameter[ 'smarty_internal_index' ])) {
$output =
"<?php \$_tmp_array = isset(\$_smarty_tpl->tpl_vars[{$_var}]) ? \$_smarty_tpl->tpl_vars[{$_var}]->value : array();\n";
$output .= "if (!is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess) {\n";
$output .= "if (!(is_array(\$_tmp_array) || \$_tmp_array instanceof ArrayAccess)) {\n";
$output .= "settype(\$_tmp_array, 'array');\n";
$output .= "}\n";
$output .= "\$_tmp_array{$parameter['smarty_internal_index']} = {$_attr['value']};\n";

View File

@ -219,8 +219,9 @@ class Smarty_Internal_Compile_Foreach extends Smarty_Internal_Compile_Private_Fo
if (isset($itemAttr[ 'index' ])) {
$output .= "{$itemVar}->index = -1;\n";
}
$output .= "if (\$_from !== null) {\n";
$output .= "foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
$output .= "{$itemVar}->do_else = true;\n";
$output .= "if (\$_from !== null) foreach (\$_from as {$keyTerm}{$itemVar}->value) {\n";
$output .= "{$itemVar}->do_else = false;\n";
if (isset($attributes[ 'key' ]) && isset($itemAttr[ 'key' ])) {
$output .= "\$_smarty_tpl->tpl_vars['{$key}']->value = {$itemVar}->key;\n";
}
@ -296,7 +297,7 @@ class Smarty_Internal_Compile_Foreachelse extends Smarty_Internal_CompileBase
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
$output .= "}\n} else {\n?>";
$output .= "}\nif ({$itemVar}->do_else) {\n?>";
return $output;
}
}
@ -332,9 +333,6 @@ class Smarty_Internal_Compile_Foreachclose extends Smarty_Internal_CompileBase
if ($restore === 2) {
$output .= "{$itemVar} = {$local}saved;\n";
}
if ($restore > 0) {
$output .= "}\n";
}
$output .= "}\n";
/* @var Smarty_Internal_Compile_Foreach $foreachCompiler */
$foreachCompiler = $compiler->getTagCompiler('foreach');

View File

@ -151,6 +151,7 @@ class Smarty_Internal_Compile_Insert extends Smarty_Internal_CompileBase
$_output .= "echo {$_function}({$_params},\$_smarty_tpl);?>";
}
}
$compiler->template->compiled->has_nocache_code = true;
return $_output;
}
}

View File

@ -47,7 +47,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>",
"<?php echo '{$output}';?>\n",
true
)
)
@ -77,7 +77,7 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
new Smarty_Internal_ParseTree_Tag(
$compiler->parser,
$compiler->processNocacheCode(
"<?php echo '{$output}';?>",
"<?php echo '{$output}';?>\n",
true
)
)

View File

@ -48,6 +48,8 @@ class Smarty_Internal_Method_RegisterPlugin
throw new SmartyException("Plugin tag '{$name}' already registered");
} elseif (!is_callable($callback)) {
throw new SmartyException("Plugin '{$name}' not callable");
} elseif ($cacheable && $cache_attr) {
throw new SmartyException("Cannot set caching attributes for plugin '{$name}' when it is cacheable.");
} else {
$smarty->registered_plugins[ $type ][ $name ] = array($callback, (bool)$cacheable, (array)$cache_attr);
}

View File

@ -85,45 +85,85 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
public function to_smarty_php(Smarty_Internal_Templateparser $parser)
{
$code = '';
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
$subtree = $this->subtrees[ $key ]->to_smarty_php($parser);
while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Text ||
$this->subtrees[ $key + 1 ]->data === '')) {
$key++;
if ($this->subtrees[ $key ]->data === '') {
continue;
}
$subtree .= $this->subtrees[ $key ]->to_smarty_php($parser);
}
if ($subtree === '') {
continue;
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$subtree
);
continue;
}
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
$subtree = $this->subtrees[ $key ]->to_smarty_php($parser);
while ($key + 1 < $cnt && ($this->subtrees[ $key + 1 ] instanceof Smarty_Internal_ParseTree_Tag ||
$this->subtrees[ $key + 1 ]->data === '')) {
$key++;
if ($this->subtrees[ $key ]->data === '') {
continue;
}
$subtree = $parser->compiler->appendCode($subtree, $this->subtrees[ $key ]->to_smarty_php($parser));
}
if ($subtree === '') {
continue;
}
$code .= $subtree;
continue;
}
$code .= $this->subtrees[ $key ]->to_smarty_php($parser);
foreach ($this->getChunkedSubtrees() as $chunk) {
$text = '';
switch ($chunk['mode']) {
case 'textstripped':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$parser->compiler->processText($text)
);
break;
case 'text':
foreach ($chunk['subtrees'] as $subtree) {
$text .= $subtree->to_smarty_php($parser);
}
$code .= preg_replace(
'/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/',
"<?php echo '\$1'; ?>\n",
$text
);
break;
case 'tag':
foreach ($chunk['subtrees'] as $subtree) {
$text = $parser->compiler->appendCode($text, $subtree->to_smarty_php($parser));
}
$code .= $text;
break;
default:
foreach ($chunk['subtrees'] as $subtree) {
$text = $subtree->to_smarty_php($parser);
}
$code .= $text;
}
}
return $code;
}
private function getChunkedSubtrees() {
$chunks = [];
$currentMode = null;
$currentChunk = [];
for ($key = 0, $cnt = count($this->subtrees); $key < $cnt; $key++) {
if ($this->subtrees[ $key ]->data === '' && in_array($currentMode, ['textstripped', 'text', 'tag'])) {
continue;
}
if ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text
&& $this->subtrees[ $key ]->isToBeStripped()) {
$newMode = 'textstripped';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Text) {
$newMode = 'text';
} elseif ($this->subtrees[ $key ] instanceof Smarty_Internal_ParseTree_Tag) {
$newMode = 'tag';
} else {
$newMode = 'other';
}
if ($newMode == $currentMode) {
$currentChunk[] = $this->subtrees[ $key ];
} else {
$chunks[] = [
'mode' => $currentMode,
'subtrees' => $currentChunk
];
$currentMode = $newMode;
$currentChunk = [$this->subtrees[ $key ]];
}
}
if ($currentMode && $currentChunk) {
$chunks[] = [
'mode' => $currentMode,
'subtrees' => $currentChunk
];
}
return $chunks;
}
}

View File

@ -16,14 +16,31 @@
*/
class Smarty_Internal_ParseTree_Text extends Smarty_Internal_ParseTree
{
/**
* Create template text buffer
*
* @param string $data text
*/
public function __construct($data)
/**
* Wether this section should be stripped on output to smarty php
* @var bool
*/
private $toBeStripped = false;
/**
* Create template text buffer
*
* @param string $data text
* @param bool $toBeStripped wether this section should be stripped on output to smarty php
*/
public function __construct($data, $toBeStripped = false)
{
$this->data = $data;
$this->toBeStripped = $toBeStripped;
}
/**
* Wether this section should be stripped on output to smarty php
* @return bool
*/
public function isToBeStripped() {
return $this->toBeStripped;
}
/**

View File

@ -150,7 +150,7 @@ class Smarty_Internal_Runtime_Inheritance
return;
}
// make sure we got child block of child template of current block
while ($block->child && $block->tplIndex <= $block->child->tplIndex) {
while ($block->child && $block->child->child && $block->tplIndex <= $block->child->tplIndex) {
$block->child = $block->child->child;
}
$this->process($tpl, $block);

View File

@ -265,7 +265,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
*
* @param string $type plugin type
* @param string $name name of template tag
* @param callback $callback PHP callback to register
* @param callable $callback PHP callback to register
* @param bool $cacheable if true (default) this function is cache able
* @param mixed $cache_attr caching attributes if any
*
@ -301,7 +301,7 @@ abstract class Smarty_Internal_TemplateBase extends Smarty_Internal_Data
* @link http://www.smarty.net/docs/en/api.register.filter.tpl
*
* @param string $type filter type
* @param callback $callback
* @param callable $callback
* @param string|null $name optional filter name
*
* @return \Smarty|\Smarty_Internal_Template

View File

@ -621,22 +621,18 @@ abstract class Smarty_Internal_TemplateCompilerBase
|| strcasecmp($name, 'array') === 0 || is_callable($name)
) {
$func_name = strtolower($name);
$par = implode(',', $parameter);
$parHasFuction = strpos($par, '(') !== false;
if ($func_name === 'isset') {
if (count($parameter) === 0) {
$this->trigger_template_error('Illegal number of parameter in "isset()"');
}
if ($parHasFuction) {
$pa = array();
foreach ($parameter as $p) {
$pa[] = (strpos($p, '(') === false) ? ('isset(' . $p . ')') : ('(' . $p . ' !== null )');
}
return '(' . implode(' && ', $pa) . ')';
} else {
$isset_par = str_replace("')->value", "',null,true,false)->value", $par);
}
return $name . '(' . $isset_par . ')';
$pa = array();
foreach ($parameter as $p) {
$pa[] = $this->syntaxMatchesVariable($p) ? 'isset(' . $p . ')' : '(' . $p . ' !== null )';
}
return '(' . implode(' && ', $pa) . ')';
} elseif (in_array(
$func_name,
array(
@ -653,7 +649,7 @@ abstract class Smarty_Internal_TemplateCompilerBase
$this->trigger_template_error("Illegal number of parameter in '{$func_name()}'");
}
if ($func_name === 'empty') {
if ($parHasFuction && version_compare(PHP_VERSION, '5.5.0', '<')) {
if (!$this->syntaxMatchesVariable($parameter[0]) && version_compare(PHP_VERSION, '5.5.0', '<')) {
return '(' . $parameter[ 0 ] . ' === false )';
} else {
return $func_name . '(' .
@ -671,74 +667,82 @@ abstract class Smarty_Internal_TemplateCompilerBase
}
}
/**
* Determines whether the passed string represents a valid (PHP) variable.
* This is important, because `isset()` only works on variables and `empty()` can only be passed
* a variable prior to php5.5
* @param $string
* @return bool
*/
private function syntaxMatchesVariable($string) {
static $regex_pattern = '/^\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*((->)[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*|\[.*]*\])*$/';
return 1 === preg_match($regex_pattern, trim($string));
}
/**
* This method is called from parser to process a text content section
* This method is called from parser to process a text content section if strip is enabled
* - remove text from inheritance child templates as they may generate output
* - strip text if strip is enabled
*
* @param string $text
*
* @return null|\Smarty_Internal_ParseTree_Text
* @return string
*/
public function processText($text)
{
if ((string)$text != '') {
$store = array();
$_store = 0;
if ($this->parser->strip) {
if (strpos($text, '<') !== false) {
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all(
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
$text,
$matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$store[] = $match[ 0 ][ 0 ];
$_length = strlen($match[ 0 ][ 0 ]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store++;
}
}
$expressions = array(// replace multiple spaces between tags by a single space
'#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove newline between tags
'#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
// remove multiple spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
'#>[\040\011]+$#Ss' => '> ',
'#>[\040\011]*[\n]\s*$#Ss' => '>',
$this->stripRegEx => '',
);
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
$_offset = 0;
if (preg_match_all(
'#@!@SMARTY:([0-9]+):SMARTY@!@#is',
$text,
$matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$_length = strlen($match[ 0 ][ 0 ]);
$replace = $store[ $match[ 1 ][ 0 ] ];
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
$_offset += strlen($replace) - $_length;
$_store++;
}
}
} else {
$text = preg_replace($this->stripRegEx, '', $text);
}
}
return new Smarty_Internal_ParseTree_Text($text);
if (strpos($text, '<') === false) {
return preg_replace($this->stripRegEx, '', $text);
}
return null;
$store = array();
$_store = 0;
// capture html elements not to be messed with
$_offset = 0;
if (preg_match_all(
'#(<script[^>]*>.*?</script[^>]*>)|(<textarea[^>]*>.*?</textarea[^>]*>)|(<pre[^>]*>.*?</pre[^>]*>)#is',
$text,
$matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$store[] = $match[ 0 ][ 0 ];
$_length = strlen($match[ 0 ][ 0 ]);
$replace = '@!@SMARTY:' . $_store . ':SMARTY@!@';
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] - $_offset, $_length);
$_offset += $_length - strlen($replace);
$_store++;
}
}
$expressions = array(// replace multiple spaces between tags by a single space
'#(:SMARTY@!@|>)[\040\011]+(?=@!@SMARTY:|<)#s' => '\1 \2',
// remove newline between tags
'#(:SMARTY@!@|>)[\040\011]*[\n]\s*(?=@!@SMARTY:|<)#s' => '\1\2',
// remove multiple spaces between attributes (but not in attribute values!)
'#(([a-z0-9]\s*=\s*("[^"]*?")|(\'[^\']*?\'))|<[a-z0-9_]+)\s+([a-z/>])#is' => '\1 \5',
'#>[\040\011]+$#Ss' => '> ',
'#>[\040\011]*[\n]\s*$#Ss' => '>',
$this->stripRegEx => '',
);
$text = preg_replace(array_keys($expressions), array_values($expressions), $text);
$_offset = 0;
if (preg_match_all(
'#@!@SMARTY:([0-9]+):SMARTY@!@#is',
$text,
$matches,
PREG_OFFSET_CAPTURE | PREG_SET_ORDER
)
) {
foreach ($matches as $match) {
$_length = strlen($match[ 0 ][ 0 ]);
$replace = $store[ $match[ 1 ][ 0 ] ];
$text = substr_replace($text, $replace, $match[ 0 ][ 1 ] + $_offset, $_length);
$_offset += strlen($replace) - $_length;
$_store++;
}
}
return $text;
}
/**

View File

@ -215,9 +215,23 @@ class Smarty_Internal_Templatelexer
*/
private $yy_global_pattern5 = null;
private $_yy_state = 1;
/**
* preg token pattern for text
*
* @var null
*/
private $yy_global_text = null;
private $_yy_stack = array();
/**
* preg token pattern for literal
*
* @var null
*/
private $yy_global_literal = null;
private $_yy_state = 1;
private $_yy_stack = array();
/**
* constructor
@ -319,7 +333,7 @@ class Smarty_Internal_Templatelexer
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
$this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[\/]phpSMARTYrdel)|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>])|\G((.*?)(?=((SMARTYldel)SMARTYal|[<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>]SMARTYliteral))|[\s\S]+)/isS");
$this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[\/]phpSMARTYrdel)|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>])|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@ -336,11 +350,8 @@ class Smarty_Internal_Templatelexer
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5
) . '... state TEXT');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TEXT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@ -365,7 +376,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line .
throw new Exception('Unexpected input at line ' . $this->line .
': ' . $this->data[ $this->counter ]);
}
break;
@ -379,6 +390,7 @@ class Smarty_Internal_Templatelexer
public function yy_r1_2()
{
$to = $this->dataLength;
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", $this->data, $match, PREG_OFFSET_CAPTURE,
$this->counter);
if (isset($match[ 0 ][ 1 ])) {
@ -425,6 +437,16 @@ class Smarty_Internal_Templatelexer
public function yy_r1_19()
{
if (!isset($this->yy_global_text)) {
$this->yy_global_text =
$this->replace('/(SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*[>]|[?][>]|[%][>]SMARTYliteral/isS');
}
$to = $this->dataLength;
preg_match($this->yy_global_text, $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ];
}
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
@ -449,11 +471,8 @@ class Smarty_Internal_Templatelexer
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5
) . '... state TAG');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TAG');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@ -478,7 +497,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line .
throw new Exception('Unexpected input at line ' . $this->line .
': ' . $this->data[ $this->counter ]);
}
break;
@ -573,7 +592,7 @@ class Smarty_Internal_Templatelexer
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 =
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@ -590,11 +609,8 @@ class Smarty_Internal_Templatelexer
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5
) . '... state TAGBODY');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TAGBODY');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@ -619,7 +635,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line .
throw new Exception('Unexpected input at line ' . $this->line .
': ' . $this->data[ $this->counter ]);
}
break;
@ -772,10 +788,15 @@ class Smarty_Internal_Templatelexer
public function yy_r3_42()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
$this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN;
}
public function yy_r3_43()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
public function yy_r3_44()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
@ -788,73 +809,73 @@ class Smarty_Internal_Templatelexer
}
}
public function yy_r3_44()
public function yy_r3_45()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}
public function yy_r3_47()
public function yy_r3_48()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
public function yy_r3_48()
public function yy_r3_49()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
public function yy_r3_49()
public function yy_r3_50()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
public function yy_r3_50()
public function yy_r3_51()
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
public function yy_r3_51()
public function yy_r3_52()
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
public function yy_r3_52()
public function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
public function yy_r3_53()
public function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
public function yy_r3_54()
public function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
public function yy_r3_55()
public function yy_r3_56()
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
public function yy_r3_56()
public function yy_r3_57()
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
public function yy_r3_57()
public function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
public function yy_r3_58()
public function yy_r3_59()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function
public function yy_r3_59()
public function yy_r3_60()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
@ -863,7 +884,7 @@ class Smarty_Internal_Templatelexer
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 =
$this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((.*?)(?=(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel))/isS");
$this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@ -880,11 +901,8 @@ class Smarty_Internal_Templatelexer
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5
) . '... state LITERAL');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state LITERAL');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@ -909,7 +927,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line .
throw new Exception('Unexpected input at line ' . $this->line .
': ' . $this->data[ $this->counter ]);
}
break;
@ -935,6 +953,17 @@ class Smarty_Internal_Templatelexer
public function yy_r4_5()
{
if (!isset($this->yy_global_literal)) {
$this->yy_global_literal = $this->replace('/(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel/isS');
}
$to = $this->dataLength;
preg_match($this->yy_global_literal, $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ];
} else {
$this->compiler->trigger_template_error("missing or misspelled literal closing tag");
}
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function
@ -942,7 +971,7 @@ class Smarty_Internal_Templatelexer
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 =
$this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))/isS");
$this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@ -959,11 +988,8 @@ class Smarty_Internal_Templatelexer
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr(
$this->data,
$this->counter,
5
) . '... state DOUBLEQUOTEDSTRING');
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@ -988,7 +1014,7 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line .
throw new Exception('Unexpected input at line ' . $this->line .
': ' . $this->data[ $this->counter ]);
}
break;
@ -1057,4 +1083,13 @@ class Smarty_Internal_Templatelexer
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yy_r5_22()
{
$to = $this->dataLength;
$this->value = substr($this->data, $this->counter, $to - $this->counter);
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
$Id$
Smarty version: 3.1.33
( https://github.com/smarty-php/smarty/archive/v3.1.33.tar.gz )
Smarty version: 3.1.35
( https://github.com/smarty-php/smarty/archive/v3.1.35.tar.gz )