- 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 calls if the resource does not sanitize the template name
- bugfix fix 'mkdir(): File exists' error on create directory from parallel - bugfix fix 'mkdir(): File exists' error on create directory from parallel
processes https://github.com/smarty-php/smarty/pull/377 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 27.5.2017
- bugfix change compiled code for registered function and modifiers to called as callable to allow closures - 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 * smarty version
*/ */
const SMARTY_VERSION = '3.1.32-dev-13'; const SMARTY_VERSION = '3.1.32-dev-14';
/** /**
* define variable scopes * define variable scopes

View File

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

View File

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