- bugfix solve preg_match() hhvm parameter problem https://github.com/smarty-php/smarty/pull/372

This commit is contained in:
Uwe Tews
2017-07-21 08:12:33 +02:00
parent f3325c4923
commit 5a8d015ef1
4 changed files with 218 additions and 225 deletions

View File

@@ -4,6 +4,7 @@
calls if the resource does not sanitize the template name
- bugfix fix 'mkdir(): File exists' error on create directory from parallel
processes https://github.com/smarty-php/smarty/pull/377
- bugfix solve preg_match() hhvm parameter problem https://github.com/smarty-php/smarty/pull/372
27.5.2017
- bugfix change compiled code for registered function and modifiers to called as callable to allow closures

View File

@@ -108,7 +108,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.32-dev-13';
const SMARTY_VERSION = '3.1.32-dev-14';
/**
* define variable scopes

View File

@@ -3,7 +3,6 @@
* Smarty Internal Plugin Configfilelexer
*
* This is the lexer to break the config file source into tokens
*
* @package Smarty
* @subpackage Config
* @author Uwe Tews
@@ -27,91 +26,78 @@ class Smarty_Internal_Configfilelexer
* @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;
/**
* state number
*
* @var int
*/
public $state = 1;
/**
* Smarty object
*
* @var Smarty
*/
public $smarty = null;
/**
* compiler object
*
* @var Smarty_Internal_Config_File_Compiler
*/
private $compiler = null;
/**
* copy of config_booleanize
*
* @var bool
*/
private $configBooleanize = false;
/**
* trace file
*
* @var resource
*/
public $yyTraceFILE;
/**
* trace prompt
*
* @var string
*/
public $yyTracePrompt;
/**
* state names
*
* @var array
*/
public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION',
6 => 'TRIPPLE');
public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE');
/**
* storage for assembled token patterns
@@ -119,15 +105,10 @@ class Smarty_Internal_Configfilelexer
* @var string
*/
private $yy_global_pattern1 = null;
private $yy_global_pattern2 = null;
private $yy_global_pattern3 = null;
private $yy_global_pattern4 = null;
private $yy_global_pattern5 = null;
private $yy_global_pattern6 = null;
/**
@@ -164,8 +145,8 @@ class Smarty_Internal_Configfilelexer
$this->yyTracePrompt = '<br>';
}
private $_yy_state = 1;
private $_yy_state = 1;
private $_yy_stack = array();
public function yylex()
@@ -176,49 +157,40 @@ class Smarty_Internal_Configfilelexer
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);
}
}
public function yybegin($state)
{
$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()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
"/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
$this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -228,15 +200,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state START');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state START');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -261,13 +234,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const START = 1;
function yy_r1_1()
@@ -321,11 +296,11 @@ class Smarty_Internal_Configfilelexer
$this->token = Smarty_Internal_Configfileparser::TPC_OTHER;
}
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 =
"/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
$this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -335,15 +310,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state VALUE');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state VALUE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -368,13 +344,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const VALUE = 2;
function yy_r2_1()
@@ -421,9 +399,7 @@ class Smarty_Internal_Configfilelexer
function yy_r2_7()
{
if (!$this->configBooleanize ||
!in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))
) {
if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) {
$this->yypopstate();
$this->yypushstate(self::NAKED_STRING_VALUE);
return true; //reprocess in new state
@@ -448,6 +424,7 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate();
}
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
@@ -461,15 +438,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state NAKED_STRING_VALUE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -494,13 +472,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const NAKED_STRING_VALUE = 3;
function yy_r3_1()
@@ -510,6 +490,7 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate();
}
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
@@ -523,15 +504,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state COMMENT');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state COMMENT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -556,13 +538,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const COMMENT = 4;
function yy_r4_1()
@@ -584,6 +568,7 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate();
}
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
@@ -597,15 +582,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state SECTION');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state SECTION');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -630,13 +616,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const SECTION = 5;
function yy_r5_1()
@@ -652,6 +640,7 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate();
}
public function yylex6()
{
if (!isset($this->yy_global_pattern6)) {
@@ -665,15 +654,16 @@ class Smarty_Internal_Configfilelexer
}
do {
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
substr($this->data, $this->counter, 5) . '... state TRIPPLE');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TRIPPLE');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -698,13 +688,15 @@ class Smarty_Internal_Configfilelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const TRIPPLE = 6;
function yy_r6_1()
@@ -729,4 +721,5 @@ class Smarty_Internal_Configfilelexer
$this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT;
}
}

View File

@@ -185,20 +185,43 @@ class Smarty_Internal_Templatelexer
* @var array
*/
public $smarty_token_names = array( // Text for parser error messages
'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[',
'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=',
'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$',
'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@',
'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`',
'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","',
'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to',
'NOT' => '(!,not)',
'OPENP' => '(',
'CLOSEP' => ')',
'OPENB' => '[',
'CLOSEB' => ']',
'PTR' => '->',
'APTR' => '=>',
'EQUAL' => '=',
'NUMBER' => 'number',
'UNIMATH' => '+" , "-',
'MATH' => '*" , "/" , "%',
'INCDEC' => '++" , "--',
'SPACE' => ' ',
'DOLLAR' => '$',
'SEMICOLON' => ';',
'COLON' => ':',
'DOUBLECOLON' => '::',
'AT' => '@',
'HATCH' => '#',
'QUOTE' => '"',
'BACKTICK' => '`',
'VERT' => '"|" modifier',
'DOT' => '.',
'COMMA' => '","',
'QMARK' => '"?"',
'ID' => 'id, name',
'TEXT' => 'text',
'LDELSLASH' => '{/..} closing tag',
'LDEL' => '{...} Smarty tag',
'COMMENT' => 'comment',
'AS' => 'as',
'TO' => 'to',
'PHP' => '"<?php", "<%", "{php}" tag',
'LOGOP' => '"<", "==" ... logical operator',
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
'SCOND' => '"is even" ... if condition',);
'SCOND' => '"is even" ... if condition',
);
/**
* constructor
@@ -236,12 +259,11 @@ class Smarty_Internal_Templatelexer
*/
public function isAutoLiteral()
{
return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false;
return $this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false;
}
private $_yy_state = 1;
private $_yy_state = 1;
private $_yy_stack = array();
public function yylex()
@@ -252,52 +274,40 @@ 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);
}
}
public function yybegin($state)
{
$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()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 =
"/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" .
$this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel .
")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel .
")|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>]))|\G([\S\s])/isS";
$this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((" . $this->ldel . "\\s*php([ ].*?)?" . $this->rdel . ")|(" . $this->ldel . "\\s*[\/]php" . $this->rdel . "))|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\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);
@@ -307,15 +317,16 @@ class Smarty_Internal_Templatelexer
}
do {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
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');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TEXT');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -340,13 +351,15 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const TEXT = 1;
function yy_r1_1()
@@ -377,9 +390,7 @@ class Smarty_Internal_Templatelexer
function yy_r1_7()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
@@ -390,9 +401,7 @@ class Smarty_Internal_Templatelexer
function yy_r1_8()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -416,8 +425,7 @@ class Smarty_Internal_Templatelexer
{
$to = $this->dataLength;
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i",
$this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("/($this->ldel)|(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*[\"']?\s*php\s*[\"']?\s*>)|([?][>])|([%][>])/i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -425,16 +433,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 =
"/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" .
$this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel .
"\\s*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel .
")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" .
$this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel .
"\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
$this->yy_global_pattern2 = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(" . $this->ldel . "\\s*make_nocache\\s+)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -444,15 +447,16 @@ class Smarty_Internal_Templatelexer
}
do {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
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');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TAG');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -477,13 +481,15 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const TAG = 2;
function yy_r2_1()
@@ -573,11 +579,11 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel .
"\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\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->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$]smarty\\.block\\.(child|parent))|\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";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -587,15 +593,16 @@ class Smarty_Internal_Templatelexer
}
do {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
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');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state TAGBODY');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -620,13 +627,15 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const TAGBODY = 3;
function yy_r3_1()
@@ -639,9 +648,7 @@ class Smarty_Internal_Templatelexer
function yy_r3_2()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -823,9 +830,7 @@ class Smarty_Internal_Templatelexer
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) ==
$this->smarty->right_delimiter
) {
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
preg_match("/\s+/", $this->value, $match);
$this->value = $match[0];
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
@@ -919,12 +924,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 =
"/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
$this->rdel . ")|\G([\S\s])/isS";
$this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -934,15 +938,16 @@ class Smarty_Internal_Templatelexer
}
do {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
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');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state LITERAL');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -967,13 +972,15 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const LITERAL = 4;
function yy_r4_1()
@@ -999,8 +1006,7 @@ class Smarty_Internal_Templatelexer
{
$to = $this->dataLength;
preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE,
$this->counter);
preg_match("/{$this->ldel}[\/]?literal{$this->rdel}/i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
} else {
@@ -1010,15 +1016,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 =
"/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" .
$this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" .
$this->ldel .
"\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" .
$this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
$this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
@@ -1028,15 +1030,16 @@ class Smarty_Internal_Templatelexer
}
do {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) {
if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, 0, $this->counter)) {
if (!isset($yymatches[0][1])) {
$yymatches = preg_grep("/(.|\s)+/", $yymatches);
} else {
$yymatches = array_filter($yymatches);
}
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');
throw new Exception('Error: lexing failed because a rule matched' .
' an empty string. Input "' . substr($this->data,
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING');
}
next($yymatches); // skip global match
$this->token = key($yymatches); // token number
@@ -1061,13 +1064,15 @@ class Smarty_Internal_Templatelexer
continue;
}
} else {
throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
throw new Exception('Unexpected input at line' . $this->line .
': ' . $this->data[$this->counter]);
}
break;
}
while (true);
} while (true);
} // end function
const DOUBLEQUOTEDSTRING = 5;
function yy_r5_1()
@@ -1085,9 +1090,7 @@ class Smarty_Internal_Templatelexer
function yy_r5_3()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -1098,9 +1101,7 @@ class Smarty_Internal_Templatelexer
function yy_r5_4()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
@@ -1111,9 +1112,7 @@ class Smarty_Internal_Templatelexer
function yy_r5_5()
{
if ($this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false
) {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->token = Smarty_Internal_Templateparser::TP_LDEL;