- improvement repeated delimiter like {{ and }} will be treated as literal

https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw
This commit is contained in:
Uwe Tews
2017-08-09 11:15:33 +02:00
parent 353240c38d
commit 418a1fd443
8 changed files with 2501 additions and 2530 deletions

View File

@@ -1,4 +1,8 @@
===== 3.1.32 - dev === ===== 3.1.32 - dev ===
09.8.2017
- improvement repeated delimiter like {{ and }} will be treated as literal
https://groups.google.com/forum/#!topic/smarty-developers/h9r82Bx4KZw
05.8.2017 05.8.2017
- bugfix wordwrap modifier could fail if used in nocache code. - bugfix wordwrap modifier could fail if used in nocache code.
converted plugin file shared.mb_wordwrap.php into modifier.mb_wordwrap.php converted plugin file shared.mb_wordwrap.php into modifier.mb_wordwrap.php

View File

@@ -138,6 +138,10 @@ class Smarty_Internal_Configfilelexer
$this->configBooleanize = $this->smarty->config_booleanize; $this->configBooleanize = $this->smarty->config_booleanize;
} }
public function replace ($input) {
return $input;
}
public function PrintTrace() public function PrintTrace()
{ {
$this->yyTraceFILE = fopen('php://output', 'w'); $this->yyTraceFILE = fopen('php://output', 'w');

View File

@@ -240,9 +240,11 @@ class Smarty_Internal_Templatelexer
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/'); $this->pldel = preg_quote($this->smarty->left_delimiter, '/');
$this->ldel = $this->pldel . ($this->smarty->auto_literal ? '(?!\\s+)' : '\\s*');
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $rdel = preg_quote($this->smarty->right_delimiter, '/');
$this->rdel = "(?<!{$rdel}){$rdel}(?!{$rdel})";
$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;
@@ -253,13 +255,8 @@ class Smarty_Internal_Templatelexer
$this->yyTraceFILE = fopen('php://output', 'w'); $this->yyTraceFILE = fopen('php://output', 'w');
$this->yyTracePrompt = '<br>'; $this->yyTracePrompt = '<br>';
} }
public function replace ($input) {
/* return str_replace(array('SMARTYldel','SMARTYrawldel','SMARTYrdel'),array($this->ldel,$this->pldel,$this->rdel),$input);
* Check if this tag is autoliteral
*/
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;
} }
/*!lex2php /*!lex2php
@@ -269,15 +266,16 @@ class Smarty_Internal_Templatelexer
%value $this->value %value $this->value
%line $this->line %line $this->line
linebreak = ~[\t ]*[\r\n]+[\t ]*~ linebreak = ~[\t ]*[\r\n]+[\t ]*~
ldelrepeat = ~SMARTYrawldel{2,}~
text = ~[\S\s]~ text = ~[\S\s]~
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))~ textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))~
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~ namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
all = ~[\S\s]+~ all = ~[\S\s]+~
emptyjava = ~[{][}]~ emptyjava = ~[{][}]~
phptag = ~(SMARTYldel\s*php([ ].*?)?SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~ phptag = ~(SMARTYldelphp([ ].*?)?SMARTYrdel)|(SMARTYldel[/]phpSMARTYrdel)~
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])~ phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])~
slash = ~[/]~ slash = ~[/]~
ldel = ~SMARTYldel\s*~ ldel = ~SMARTYldel~
rdel = ~\s*SMARTYrdel~ rdel = ~\s*SMARTYrdel~
nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~ nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~ notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~
@@ -351,31 +349,27 @@ class Smarty_Internal_Templatelexer
phptag { phptag {
$this->compiler->getTagCompiler('private_php')->parsePhp($this); $this->compiler->getTagCompiler('private_php')->parsePhp($this);
} }
ldel literal rdel { ldelrepeat {
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; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else { }
ldel literal rdel {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} }
ldel slash literal rdel {
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL);
} }
ldel { ldel {
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); $this->yypushstate(self::TAG);
return true; return true;
} }
}
rdel {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
phpstart { phpstart {
$this->compiler->getTagCompiler('private_php')->parsePhp($this); $this->compiler->getTagCompiler('private_php')->parsePhp($this);
} }
text { text {
$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",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); preg_match("/((?<!$this->pldel){$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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} }
@@ -450,13 +444,9 @@ class Smarty_Internal_Templatelexer
$this->yypopstate(); $this->yypopstate();
} }
ldel { ldel {
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); $this->yypushstate(self::TAG);
return true; return true;
} }
}
double_quote { double_quote {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->yypushstate(self::DOUBLEQUOTEDSTRING);
@@ -627,6 +617,9 @@ class Smarty_Internal_Templatelexer
*/ */
/*!lex2php /*!lex2php
%statename DOUBLEQUOTEDSTRING %statename DOUBLEQUOTEDSTRING
ldelrepeat {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
ldel literal rdel { ldel literal rdel {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
@@ -634,30 +627,18 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
ldel slash { ldel slash {
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); $this->yypushstate(self::TAG);
return true; return true;
} }
}
ldel id { ldel id {
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); $this->yypushstate(self::TAG);
return true; return true;
} }
}
ldel { ldel {
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; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->taglineno = $this->line; $this->taglineno = $this->line;
$this->yypushstate(self::TAGBODY); $this->yypushstate(self::TAGBODY);
} }
}
double_quote { double_quote {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();

View File

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

View File

@@ -3,6 +3,7 @@
* 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
@@ -20,6 +21,12 @@
*/ */
class Smarty_Internal_Configfilelexer class Smarty_Internal_Configfilelexer
{ {
const START = 1;
const VALUE = 2;
const NAKED_STRING_VALUE = 3;
const COMMENT = 4;
const SECTION = 5;
const TRIPPLE = 6;
/** /**
* Source * Source
* *
@@ -68,18 +75,6 @@ class Smarty_Internal_Configfilelexer
* @var Smarty * @var Smarty
*/ */
public $smarty = null; 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 * trace file
* *
@@ -97,8 +92,27 @@ class Smarty_Internal_Configfilelexer
* *
* @var array * @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');
/**
* token names
*
* @var array
*/
public $smarty_token_names = array( // Text for parser error messages
);
/**
* compiler object
*
* @var Smarty_Internal_Config_File_Compiler
*/
private $compiler = null;
/**
* copy of config_booleanize
*
* @var bool
*/
private $configBooleanize = false;
/** /**
* storage for assembled token patterns * storage for assembled token patterns
* *
@@ -110,14 +124,8 @@ class Smarty_Internal_Configfilelexer
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;
private $_yy_state = 1;
/** private $_yy_stack = array();
* token names
*
* @var array
*/
public $smarty_token_names = array( // Text for parser error messages
);
/** /**
* constructor * constructor
@@ -143,54 +151,25 @@ class Smarty_Internal_Configfilelexer
{ {
$this->yyTraceFILE = fopen('php://output', 'w'); $this->yyTraceFILE = fopen('php://output', 'w');
$this->yyTracePrompt = '<br>'; $this->yyTracePrompt = '<br>';
} } // end function
private $_yy_state = 1;
private $_yy_stack = array();
public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
}
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);
}
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);
}
}
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);
}
$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);
}
}
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, 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)) { 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 =
$this->replace("/\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);
@@ -207,9 +186,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state START'); $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
@@ -220,11 +200,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -234,16 +214,22 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
public function replace($input)
{
return $input;
}
const START = 1; public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
}
function yy_r1_1() function yy_r1_1()
{ {
@@ -252,6 +238,26 @@ class Smarty_Internal_Configfilelexer
$this->yypushstate(self::COMMENT); $this->yypushstate(self::COMMENT);
} }
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);
}
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);
}
}
function yy_r1_2() function yy_r1_2()
{ {
@@ -276,7 +282,7 @@ class Smarty_Internal_Configfilelexer
{ {
return false; return false;
} } // end function
function yy_r1_6() function yy_r1_6()
{ {
@@ -296,11 +302,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 = "/\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 =
$this->replace("/\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);
@@ -317,9 +323,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state VALUE'); $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
@@ -330,11 +337,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -344,16 +351,12 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const VALUE = 2;
function yy_r2_1() function yy_r2_1()
{ {
@@ -368,6 +371,26 @@ class Smarty_Internal_Configfilelexer
$this->yypopstate(); $this->yypopstate();
} }
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);
}
$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);
}
}
function yy_r2_3() function yy_r2_3()
{ {
@@ -394,12 +417,13 @@ class Smarty_Internal_Configfilelexer
$this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_DOUBLE_QUOTED_STRING;
$this->yypopstate(); $this->yypopstate();
} } // end function
function yy_r2_7() 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->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
@@ -422,13 +446,12 @@ class Smarty_Internal_Configfilelexer
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
$this->value = ""; $this->value = "";
$this->yypopstate(); $this->yypopstate();
} } // end function
public function yylex3()
public function yylex3()
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/isS"; $this->yy_global_pattern3 = $this->replace("/\G([^\n]+?(?=[ \t\r]*\n))/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -445,9 +468,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state NAKED_STRING_VALUE'); $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
@@ -458,11 +482,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -472,16 +496,12 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const NAKED_STRING_VALUE = 3;
function yy_r3_1() function yy_r3_1()
{ {
@@ -490,11 +510,10 @@ 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)) {
$this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS"; $this->yy_global_pattern4 = $this->replace("/\G([ \t\r]+)|\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);
@@ -511,9 +530,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state COMMENT'); $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
@@ -524,11 +544,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -538,16 +558,12 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const COMMENT = 4;
function yy_r4_1() function yy_r4_1()
{ {
@@ -559,7 +575,7 @@ class Smarty_Internal_Configfilelexer
{ {
$this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING; $this->token = Smarty_Internal_Configfileparser::TPC_NAKED_STRING;
} } // end function
function yy_r4_3() function yy_r4_3()
{ {
@@ -568,11 +584,10 @@ 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)) {
$this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS"; $this->yy_global_pattern5 = $this->replace("/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -589,9 +604,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state SECTION'); $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
@@ -602,11 +618,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -616,16 +632,12 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const SECTION = 5;
function yy_r5_1() function yy_r5_1()
{ {
@@ -638,13 +650,12 @@ class Smarty_Internal_Configfilelexer
$this->token = Smarty_Internal_Configfileparser::TPC_SECTION; $this->token = Smarty_Internal_Configfileparser::TPC_SECTION;
$this->yypopstate(); $this->yypopstate();
} } // end function
public function yylex6()
public function yylex6()
{ {
if (!isset($this->yy_global_pattern6)) { if (!isset($this->yy_global_pattern6)) {
$this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS"; $this->yy_global_pattern6 = $this->replace("/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -661,9 +672,10 @@ class Smarty_Internal_Configfilelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state TRIPPLE'); $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
@@ -674,11 +686,11 @@ class Smarty_Internal_Configfilelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -688,16 +700,12 @@ class Smarty_Internal_Configfilelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const TRIPPLE = 6;
function yy_r6_1() function yy_r6_1()
{ {

File diff suppressed because it is too large Load Diff

View File

@@ -18,76 +18,71 @@
*/ */
class Smarty_Internal_Templatelexer class Smarty_Internal_Templatelexer
{ {
const TEXT = 1;
const TAG = 2;
const TAGBODY = 3;
const LITERAL = 4;
const DOUBLEQUOTEDSTRING = 5;
/** /**
* Source * Source
* *
* @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;
/** /**
* tag start line * tag start line
* *
* @var * @var
*/ */
public $taglineno; public $taglineno;
/** /**
* php code type * php code type
* *
* @var string * @var string
*/ */
public $phpType = ''; public $phpType = '';
/** /**
* escaped left delimiter * escaped left delimiter
* *
* @var string * @var string
*/ */
public $ldel = ''; public $ldel = '';
/** /**
* escaped left delimiter length * escaped left delimiter length
* *
* @var int * @var int
*/ */
public $ldel_length = 0; public $ldel_length = 0;
/** /**
* escaped right delimiter * escaped right delimiter
* *
@@ -95,133 +90,97 @@ class Smarty_Internal_Templatelexer
*/ */
public $rdel = ''; public $rdel = '';
/**
* PHP start tag string
*
* @var string
*/
/** /**
* escaped right delimiter length * escaped right delimiter length
* *
* @var int * @var int
*/ */
public $rdel_length = 0; public $rdel_length = 0;
/** /**
* 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_TemplateCompilerBase * @var Smarty_Internal_TemplateCompilerBase
*/ */
public $compiler = null; public $compiler = null;
/**
* literal tag nesting level
*
* @var int
*/
private $literal_cnt = 0;
/**
* PHP start tag string
*
* @var string
*/
/** /**
* trace file * trace file
* *
* @var resource * @var resource
*/ */
public $yyTraceFILE; public $yyTraceFILE;
/** /**
* trace prompt * trace prompt
* *
* @var string * @var string
*/ */
public $yyTracePrompt; public $yyTracePrompt;
/** /**
* XML flag true while processing xml * XML flag true while processing xml
* *
* @var bool * @var bool
*/ */
public $is_xml = false; public $is_xml = false;
/** /**
* state names * state names
* *
* @var array * @var array
*/ */
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',); public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',);
/**
* storage for assembled token patterns
*
* @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;
/** /**
* token names * token names
* *
* @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)', 'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[',
'OPENP' => '(', 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=',
'CLOSEP' => ')', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
'OPENB' => '[', 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$',
'CLOSEB' => ']', 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@',
'PTR' => '->', 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`',
'APTR' => '=>', 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","',
'EQUAL' => '=', 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
'NUMBER' => 'number', 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag',
'UNIMATH' => '+" , "-', 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to',
'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',);
); /**
* literal tag nesting level
*
* @var int
*/
private $literal_cnt = 0;
/**
* storage for assembled token patterns
*
* @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_state = 1;
private $_yy_stack = array();
/** /**
* constructor * constructor
@@ -240,9 +199,11 @@ class Smarty_Internal_Templatelexer
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/'); $this->pldel = preg_quote($this->smarty->left_delimiter, '/');
$this->ldel = $this->pldel . ($this->smarty->auto_literal ? '(?!\\s+)' : '\\s*');
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $rdel = preg_quote($this->smarty->right_delimiter, '/');
$this->rdel = "(?<!{$rdel}){$rdel}(?!{$rdel})";
$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;
@@ -254,60 +215,11 @@ class Smarty_Internal_Templatelexer
$this->yyTracePrompt = '<br>'; $this->yyTracePrompt = '<br>';
} }
/* public function yylex1()
* Check if this tag is autoliteral
*/
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;
}
private $_yy_state = 1;
private $_yy_stack = array();
public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
}
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);
}
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);
}
}
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);
}
$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);
}
}
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);
}
}
public function yylex1()
{ {
if (!isset($this->yy_global_pattern1)) { 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 =
$this->replace("/\G([{][}])|\G(SMARTYldel[*])|\G((SMARTYldelphp([ ].*?)?SMARTYrdel)|(SMARTYldel[\/]phpSMARTYrdel))|\G(SMARTYrawldel{2,})|\G(SMARTYldelliteral\\s*SMARTYrdel)|\G(SMARTYldel[\/]literal\\s*SMARTYrdel)|\G(SMARTYldel)|\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);
@@ -324,9 +236,10 @@ class Smarty_Internal_Templatelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state TEXT'); $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
@@ -337,11 +250,11 @@ class Smarty_Internal_Templatelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -351,16 +264,24 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function } // end function
public function replace($input)
{
return str_replace(array('SMARTYldel', 'SMARTYrawldel', 'SMARTYrdel'),
array($this->ldel, $this->pldel, $this->rdel),
$input);
}
const TEXT = 1; public function yylex()
{
return $this->{'yylex' . $this->_yy_state}();
}
function yy_r1_1() function yy_r1_1()
{ {
@@ -390,42 +311,65 @@ class Smarty_Internal_Templatelexer
function yy_r1_7() 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) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL);
}
} }
function yy_r1_8() 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) { $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->yypushstate(self::LITERAL);
} else { }
$this->yypushstate(self::TAG);
return true; 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);
}
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);
} }
} }
function yy_r1_9() function yy_r1_9()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL);
} }
function yy_r1_10() function yy_r1_10()
{ {
$this->compiler->getTagCompiler('private_php')->parsePhp($this); $this->yypushstate(self::TAG);
return true;
} }
function yy_r1_19() function yy_r1_11()
{
$this->compiler->getTagCompiler('private_php')->parsePhp($this);
} // end function
function yy_r1_20()
{ {
$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", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); preg_match("/((?<!$this->pldel){$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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} }
@@ -433,11 +377,11 @@ class Smarty_Internal_Templatelexer
$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 = "/\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 =
$this->replace("/\G(SMARTYldel(if|elseif|else if|while)\\s+)|\G(SMARTYldelfor\\s+)|\G(SMARTYldelforeach(?![^\s]))|\G(SMARTYldelsetfilter\\s+)|\G(SMARTYldelmake_nocache\\s+)|\G(SMARTYldel[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G(SMARTYldel[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*SMARTYrdel)|\G(SMARTYldel[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G(SMARTYldel[\/])|\G(SMARTYldel)/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -454,9 +398,10 @@ class Smarty_Internal_Templatelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state TAG'); $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
@@ -467,11 +412,11 @@ class Smarty_Internal_Templatelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -481,16 +426,12 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const TAG = 2;
function yy_r2_1() function yy_r2_1()
{ {
@@ -500,6 +441,18 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
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);
}
}
function yy_r2_3() function yy_r2_3()
{ {
@@ -540,6 +493,26 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
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);
}
$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);
}
}
function yy_r2_9() function yy_r2_9()
{ {
@@ -551,7 +524,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;
@@ -561,7 +534,7 @@ class Smarty_Internal_Templatelexer
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} } // end function
function yy_r2_12() function yy_r2_12()
{ {
@@ -579,11 +552,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 . "\\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 =
$this->replace("/\G(\\s*SMARTYrdel)|\G(SMARTYldel)|\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);
@@ -600,9 +573,10 @@ class Smarty_Internal_Templatelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state TAGBODY'); $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
@@ -613,11 +587,11 @@ class Smarty_Internal_Templatelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -627,16 +601,12 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const TAGBODY = 3;
function yy_r3_1() function yy_r3_1()
{ {
@@ -648,13 +618,9 @@ class Smarty_Internal_Templatelexer
function yy_r3_2() 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) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
}
function yy_r3_3() function yy_r3_3()
{ {
@@ -830,7 +796,8 @@ 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) == $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); 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;
@@ -916,7 +883,7 @@ class Smarty_Internal_Templatelexer
{ {
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $this->token = Smarty_Internal_Templateparser::TP_SPACE;
} } // end function
function yy_r3_66() function yy_r3_66()
{ {
@@ -924,11 +891,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 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS"; $this->yy_global_pattern4 =
$this->replace("/\G(SMARTYldelliteral\\s*SMARTYrdel)|\G(SMARTYldel[\/]literal\\s*SMARTYrdel)|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -945,9 +912,10 @@ class Smarty_Internal_Templatelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state LITERAL'); $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
@@ -958,11 +926,11 @@ class Smarty_Internal_Templatelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -972,16 +940,12 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const LITERAL = 4;
function yy_r4_1() function yy_r4_1()
{ {
@@ -1006,7 +970,11 @@ class Smarty_Internal_Templatelexer
{ {
$to = $this->dataLength; $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} else { } else {
@@ -1014,13 +982,13 @@ class Smarty_Internal_Templatelexer
} }
$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_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} } // end function
public function yylex5()
public function yylex5()
{ {
if (!isset($this->yy_global_pattern5)) { 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 =
$this->replace("/\G(SMARTYrawldel{2,})|\G(SMARTYldelliteral\\s*SMARTYrdel)|\G(SMARTYldel[\/]literal\\s*SMARTYrdel)|\G(SMARTYldel[\/])|\G(SMARTYldel[0-9]*[a-zA-Z_]\\w*)|\G(SMARTYldel)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(SMARTYldel|\\$|`\\$|\")))|\G([\S\s])/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -1037,9 +1005,10 @@ class Smarty_Internal_Templatelexer
$yymatches = array_filter($yymatches); $yymatches = array_filter($yymatches);
} }
if (empty($yymatches)) { if (empty($yymatches)) {
throw new Exception('Error: lexing failed because a rule matched' . throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' .
' an empty string. Input "' . substr($this->data, substr($this->data,
$this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); $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
@@ -1050,11 +1019,11 @@ class Smarty_Internal_Templatelexer
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
// accept this token // accept this token
return true; return true;
} elseif ($r === true) { } else if ($r === true) {
// we have changed state // we have changed state
// process this token in the new state // process this token in the new state
return $this->yylex(); return $this->yylex();
} elseif ($r === false) { } else if ($r === false) {
$this->counter += strlen($this->value); $this->counter += strlen($this->value);
$this->line += substr_count($this->value, "\n"); $this->line += substr_count($this->value, "\n");
if ($this->counter >= $this->dataLength) { if ($this->counter >= $this->dataLength) {
@@ -1064,16 +1033,12 @@ class Smarty_Internal_Templatelexer
continue; continue;
} }
} else { } else {
throw new Exception('Unexpected input at line' . $this->line . throw new Exception('Unexpected input at line' . $this->line . ': ' . $this->data[ $this->counter ]);
': ' . $this->data[$this->counter]);
} }
break; break;
} while (true); } while (true);
} // end function }
const DOUBLEQUOTEDSTRING = 5;
function yy_r5_1() function yy_r5_1()
{ {
@@ -1090,45 +1055,39 @@ class Smarty_Internal_Templatelexer
function yy_r5_3() 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) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG);
return true;
}
} }
function yy_r5_4() 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) {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
} else {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
}
function yy_r5_5() 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) { $this->yypushstate(self::TAG);
$this->token = Smarty_Internal_Templateparser::TP_TEXT; return true;
} else { }
function yy_r5_6()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->taglineno = $this->line; $this->taglineno = $this->line;
$this->yypushstate(self::TAGBODY); $this->yypushstate(self::TAGBODY);
} }
}
function yy_r5_6() function yy_r5_7()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r5_7() function yy_r5_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
@@ -1137,16 +1096,10 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r5_8()
{
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
}
function yy_r5_9() function yy_r5_9()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
} }
function yy_r5_10() function yy_r5_10()
@@ -1155,7 +1108,13 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r5_14() function yy_r5_11()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_15()
{ {
$to = $this->dataLength; $to = $this->dataLength;

File diff suppressed because it is too large Load Diff