1
0
mirror of https://github.com/postfixadmin/postfixadmin.git synced 2025-08-09 05:02:44 +03:00

update Smarty to v3.1.33 - "This release does cover security issue CVE-2018-16831, other bug fixes (see changelog.txt) and adds a new feature of the {capture} tag (see NEW_FEATURES.txt)."

This commit is contained in:
David Goodwin
2019-09-25 13:55:07 +01:00
parent 7360407b73
commit 907bd7ee46
199 changed files with 5335 additions and 4857 deletions

View File

@@ -18,101 +18,117 @@
*/
class Smarty_Internal_Templatelexer
{
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const DOUBLEQUOTEDSTRING = 5;
/**
* Source
*
* @var string
*/
public $data;
/**
* Source length
*
* @var int
*/
public $dataLength = null;
/**
* byte counter
*
* @var int
*/
public $counter;
/**
* token number
*
* @var int
*/
public $token;
/**
* token value
*
* @var string
*/
public $value;
/**
* current line
*
* @var int
*/
public $line;
/**
* tag start line
*
* @var
*/
public $taglineno;
/**
* php code type
*
* @var string
*/
public $phpType = '';
/**
* state number
*
* @var int
*/
public $state = 1;
/**
* Smarty object
*
* @var Smarty
*/
public $smarty = null;
/**
* compiler object
*
* @var Smarty_Internal_TemplateCompilerBase
*/
public $compiler = null;
/**
* trace file
*
* @var resource
*/
public $yyTraceFILE;
/**
* trace prompt
*
* @var string
*/
public $yyTracePrompt;
/**
* XML flag true while processing xml
*
* @var bool
*/
public $is_xml = false;
/**
* state names
*
* @var array
*/
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
/**
* token names
*
@@ -156,44 +172,52 @@ class Smarty_Internal_Templatelexer
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
'SCOND' => '"is even" ... if condition',
);
/**
* literal tag nesting level
*
* @var int
*/
private $literal_cnt = 0;
/**
* preg token pattern for state TEXT
*
* @var string
*/
private $yy_global_pattern1 = null;
/**
* preg token pattern for state TAG
*
* @var string
*/
private $yy_global_pattern2 = null;
/**
* preg token pattern for state TAGBODY
*
* @var string
*/
private $yy_global_pattern3 = null;
/**
* preg token pattern for state LITERAL
*
* @var string
*/
private $yy_global_pattern4 = null;
/**
* preg token pattern for state DOUBLEQUOTEDSTRING
*
* @var null
*/
private $yy_global_pattern5 = null;
private $_yy_state = 1;
private $_yy_stack = array();
private $_yy_state = 1;
private $_yy_stack = array();
/**
* constructor
@@ -201,7 +225,7 @@ class Smarty_Internal_Templatelexer
* @param string $source template source
* @param Smarty_Internal_TemplateCompilerBase $compiler
*/
function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
public function __construct($source, Smarty_Internal_TemplateCompilerBase $compiler)
{
$this->data = $source;
$this->dataLength = strlen($this->data);
@@ -239,7 +263,7 @@ class Smarty_Internal_Templatelexer
return $this->compiler->replaceDelimiter($preg);
}
/**
/**
* check if current value is an autoliteral left delimiter
*
* @return bool
@@ -258,39 +282,27 @@ class Smarty_Internal_Templatelexer
public function yypushstate($state)
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState push %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
fprintf($this->yyTraceFILE, "%sState push %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
array_push($this->_yy_stack, $this->_yy_state);
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
public function yypopstate()
{
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState pop %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
fprintf($this->yyTraceFILE, "%sState pop %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
$this->_yy_state = array_pop($this->_yy_stack);
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%snew State %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
fprintf($this->yyTraceFILE, "%snew State %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
@@ -298,15 +310,12 @@ class Smarty_Internal_Templatelexer
{
$this->_yy_state = $state;
if ($this->yyTraceFILE) {
fprintf($this->yyTraceFILE,
"%sState set %s\n",
$this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] :
$this->_yy_state);
fprintf($this->yyTraceFILE, "%sState set %s\n", $this->yyTracePrompt,
isset($this->state_name[ $this->_yy_state ]) ? $this->state_name[ $this->_yy_state ] : $this->_yy_state);
}
}
public function yylex1()
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
@@ -327,9 +336,11 @@ public function yylex1()
}
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
@@ -340,11 +351,11 @@ public function yylex1()
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} else if ($r === true) {
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} else if ($r === false) {
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) {
@@ -361,18 +372,15 @@ public function yylex1()
} while (true);
}
function yy_r1_1()
public function yy_r1_1()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r1_2()
public function yy_r1_2()
{
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/",
$this->data,
$match,
PREG_OFFSET_CAPTURE,
$this->counter);
preg_match("/[*]{$this->compiler->getRdelPreg()}[\n]?/", $this->data, $match, PREG_OFFSET_CAPTURE,
$this->counter);
if (isset($match[ 0 ][ 1 ])) {
$to = $match[ 0 ][ 1 ] + strlen($match[ 0 ][ 0 ]);
} else {
@@ -382,45 +390,45 @@ public function yylex1()
return false;
}
function yy_r1_4()
public function yy_r1_4()
{
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
function yy_r1_8()
public function yy_r1_8()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r1_10()
public function yy_r1_10()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL);
}
function yy_r1_12()
public function yy_r1_12()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL);
} // end function
function yy_r1_14()
public function yy_r1_14()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r1_16()
public function yy_r1_16()
{
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
}
function yy_r1_19()
public function yy_r1_19()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex2()
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 =
@@ -441,9 +449,11 @@ public function yylex2()
}
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
@@ -454,11 +464,11 @@ public function yylex2()
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} else if ($r === true) {
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} else if ($r === false) {
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) {
@@ -475,63 +485,63 @@ public function yylex2()
} while (true);
}
function yy_r2_1()
public function yy_r2_1()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELIF;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_4()
public function yy_r2_4()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_6()
public function yy_r2_6()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_8()
public function yy_r2_8()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_10()
public function yy_r2_10()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_12()
public function yy_r2_12()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
$this->taglineno = $this->line;
}
function yy_r2_15()
public function yy_r2_15()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SMARTYBLOCKCHILDPARENT;
$this->taglineno = $this->line;
}
function yy_r2_18()
public function yy_r2_18()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line;
}
function yy_r2_20()
public function yy_r2_20()
{
if ($this->_yy_stack[ count($this->_yy_stack) - 1 ] === self::TEXT) {
$this->yypopstate();
@@ -545,21 +555,21 @@ public function yylex2()
}
} // end function
function yy_r2_23()
public function yy_r2_23()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
function yy_r2_25()
public function yy_r2_25()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
public function yylex3()
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 =
@@ -580,9 +590,11 @@ public function yylex3()
}
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
@@ -593,11 +605,11 @@ public function yylex3()
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} else if ($r === true) {
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} else if ($r === false) {
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) {
@@ -614,156 +626,156 @@ public function yylex3()
} while (true);
}
function yy_r3_1()
public function yy_r3_1()
{
$this->token = Smarty_Internal_Templateparser::TP_RDEL;
$this->yypopstate();
}
function yy_r3_2()
public function yy_r3_2()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r3_4()
public function yy_r3_4()
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote();
}
function yy_r3_5()
public function yy_r3_5()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
}
function yy_r3_6()
public function yy_r3_6()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
function yy_r3_7()
public function yy_r3_7()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
}
function yy_r3_8()
public function yy_r3_8()
{
$this->token = Smarty_Internal_Templateparser::TP_ISIN;
}
function yy_r3_9()
public function yy_r3_9()
{
$this->token = Smarty_Internal_Templateparser::TP_AS;
}
function yy_r3_10()
public function yy_r3_10()
{
$this->token = Smarty_Internal_Templateparser::TP_TO;
}
function yy_r3_11()
public function yy_r3_11()
{
$this->token = Smarty_Internal_Templateparser::TP_STEP;
}
function yy_r3_12()
public function yy_r3_12()
{
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
}
function yy_r3_13()
public function yy_r3_13()
{
$this->token = Smarty_Internal_Templateparser::TP_LOGOP;
}
function yy_r3_15()
public function yy_r3_15()
{
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
}
function yy_r3_17()
public function yy_r3_17()
{
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
}
function yy_r3_20()
public function yy_r3_20()
{
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
}
function yy_r3_23()
public function yy_r3_23()
{
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
function yy_r3_24()
public function yy_r3_24()
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
function yy_r3_28()
public function yy_r3_28()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
function yy_r3_29()
public function yy_r3_29()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
function yy_r3_30()
public function yy_r3_30()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
function yy_r3_31()
public function yy_r3_31()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
function yy_r3_32()
public function yy_r3_32()
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
function yy_r3_33()
public function yy_r3_33()
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
function yy_r3_34()
public function yy_r3_34()
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
function yy_r3_35()
public function yy_r3_35()
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
function yy_r3_37()
public function yy_r3_37()
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
function yy_r3_39()
public function yy_r3_39()
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
function yy_r3_41()
public function yy_r3_41()
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
function yy_r3_42()
public function yy_r3_42()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
function yy_r3_43()
public function yy_r3_43()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
@@ -776,78 +788,78 @@ public function yylex3()
}
}
function yy_r3_44()
public function yy_r3_44()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}
function yy_r3_47()
public function yy_r3_47()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
function yy_r3_48()
public function yy_r3_48()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
function yy_r3_49()
public function yy_r3_49()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
function yy_r3_50()
public function yy_r3_50()
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r3_51()
public function yy_r3_51()
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r3_52()
public function yy_r3_52()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r3_53()
public function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r3_54()
public function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r3_55()
public function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r3_56()
public function yy_r3_56()
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r3_57()
public function yy_r3_57()
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r3_58()
public function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function
function yy_r3_59()
public function yy_r3_59()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex4()
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 =
@@ -868,9 +880,11 @@ public function yylex4()
}
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
@@ -881,11 +895,11 @@ public function yylex4()
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} else if ($r === true) {
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} else if ($r === false) {
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) {
@@ -902,13 +916,13 @@ public function yylex4()
} while (true);
}
function yy_r4_1()
public function yy_r4_1()
{
$this->literal_cnt++;
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
function yy_r4_3()
public function yy_r4_3()
{
if ($this->literal_cnt) {
$this->literal_cnt--;
@@ -919,12 +933,12 @@ public function yylex4()
}
}
function yy_r4_5()
public function yy_r4_5()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} // end function
public function yylex5()
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 =
@@ -945,9 +959,11 @@ public function yylex5()
}
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
@@ -958,11 +974,11 @@ public function yylex5()
$this->line += substr_count($this->value, "\n");
// accept this token
return true;
} else if ($r === true) {
} elseif ($r === true) {
// we have changed state
// process this token in the new state
return $this->yylex();
} else if ($r === false) {
} elseif ($r === false) {
$this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) {
@@ -979,47 +995,47 @@ public function yylex5()
} while (true);
}
function yy_r5_1()
public function yy_r5_1()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_3()
public function yy_r5_3()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_5()
public function yy_r5_5()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_7()
public function yy_r5_7()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_9()
public function yy_r5_9()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_11()
public function yy_r5_11()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->taglineno = $this->line;
$this->yypushstate(self::TAGBODY);
}
function yy_r5_13()
public function yy_r5_13()
{
$this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate();
}
function yy_r5_14()
public function yy_r5_14()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->value = substr($this->value, 0, -1);
@@ -1027,20 +1043,18 @@ public function yylex5()
$this->taglineno = $this->line;
}
function yy_r5_15()
public function yy_r5_15()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
function yy_r5_16()
public function yy_r5_16()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_17()
public function yy_r5_17()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
}