- bugfix custom delimiters could fail since modification of version 3.1.32-dev-23

https://github.com/smarty-php/smarty/issues/394
This commit is contained in:
Uwe Tews
2017-10-21 13:14:14 +02:00
parent 668d07cda9
commit 3d7dece088
7 changed files with 732 additions and 804 deletions

View File

@@ -1,4 +1,8 @@
===== 3.1.32 - dev === ===== 3.1.32 - dev ===
21.10.2017
- bugfix custom delimiters could fail since modification of version 3.1.32-dev-23
https://github.com/smarty-php/smarty/issues/394
18.10.2017 18.10.2017
- bugfix fix implementation of unclosed block tag in double quoted string of 12.10.2017 - bugfix fix implementation of unclosed block tag in double quoted string of 12.10.2017
https://github.com/smarty-php/smarty/issues/396 https://github.com/smarty-php/smarty/issues/397 https://github.com/smarty-php/smarty/issues/396 https://github.com/smarty-php/smarty/issues/397

View File

@@ -74,41 +74,6 @@ class Smarty_Internal_Templatelexer
*/ */
public $phpType = ''; public $phpType = '';
/**
* escaped left delimiter
*
* @var string
*/
public $ldel = '';
/**
* escaped left delimiter with space
*
* @var string
*/
public $ldel_q = '';
/**
* escaped left delimiter length
*
* @var int
*/
public $ldel_length = 0;
/**
* escaped right delimiter
*
* @var string
*/
public $rdel = '';
/**
* escaped right delimiter length
*
* @var int
*/
public $rdel_length = 0;
/** /**
* state number * state number
* *
@@ -202,13 +167,6 @@ class Smarty_Internal_Templatelexer
'SCOND' => '"is even" ... if condition', 'SCOND' => '"is even" ... if condition',
); );
/**
* preg string of user defined litereals
*
* @var string
*/
public $literals = '';
/** /**
* literal tag nesting level * literal tag nesting level
* *
@@ -266,29 +224,11 @@ class Smarty_Internal_Templatelexer
$this->counter += strlen($match[0]); $this->counter += strlen($match[0]);
} }
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->template->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/') . ($this->smarty->auto_literal ? '' : '\\s*'); $this->compiler->initDelimiterPreg();
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->smarty_token_names['LDEL'] = $this->smarty->getLeftDelimiter();
$this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $this->smarty_token_names['RDEL'] = $this->smarty->getRightDelimiter();
$this->rdel_length = strlen($this->smarty->right_delimiter);
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
$literals = $this->smarty->getLiterals();
if (!empty($literals)) {
foreach ($literals as $key => $literal) {
$literals[$key] = preg_quote($literal, '/');
}
}
if ($this->smarty->auto_literal) {
$literals[] = $this->ldel . '{1,}\\s+';
}
if (!empty($literals)) {
$this->literals = implode('|', $literals);
} else {
$this->literals = preg_quote('^$', '/');
}
} }
/** /**
@@ -304,15 +244,13 @@ class Smarty_Internal_Templatelexer
/** /**
* replace placeholders with runtime preg code * replace placeholders with runtime preg code
* *
* @param string $input * @param string $preg
* *
* @return string * @return string
*/ */
public function replace($input) public function replace($preg)
{ {
return str_replace(array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel'), return $this->compiler->replaceDelimiter($preg);
array($this->ldel, $this->literals, $this->rdel),
$input);
} }
/** /**
@@ -322,8 +260,8 @@ class Smarty_Internal_Templatelexer
*/ */
public function isAutoLiteral() public function isAutoLiteral()
{ {
return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false; strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false;
} }
/*!lex2php /*!lex2php
@@ -332,22 +270,22 @@ class Smarty_Internal_Templatelexer
%token $this->token %token $this->token
%value $this->value %value $this->value
%line $this->line %line $this->line
userliteral = ~SMARTYliteral~ userliteral = ~(SMARTYldel)SMARTYautoliteral\s+SMARTYliteral~
char = ~[\S\s]~ char = ~[\S\s]~
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYliteral|SMARTYldel|\$|`\$|"))~ textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~
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*)+~
emptyjava = ~[{][}]~ emptyjava = ~[{][}]~
phptag = ~(SMARTYldelphp([ ].*?)?SMARTYrdel)|(SMARTYldel[/]phpSMARTYrdel)~ phptag = ~(SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[/]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~ ldel = ~(SMARTYldel)SMARTYal~
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*)~
integer = ~\d+~ integer = ~\d+~
hex = ~0[xX][0-9a-fA-F]+~ hex = ~0[xX][0-9a-fA-F]+~
math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~ math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
comment = ~SMARTYldel[*]~ comment = ~(SMARTYldel)SMARTYal[*]~
incdec = ~([+]|[-]){2}~ incdec = ~([+]|[-]){2}~
unimath = ~\s*([+]|[-])\s*~ unimath = ~\s*([+]|[-])\s*~
openP = ~\s*[(]\s*~ openP = ~\s*[(]\s*~
@@ -370,14 +308,14 @@ class Smarty_Internal_Templatelexer
backtick = ~[`]~ backtick = ~[`]~
vert = ~[|]~ vert = ~[|]~
qmark = ~\s*[?]\s*~ qmark = ~\s*[?]\s*~
constant = ~([_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*)(?![0-9A-Z_]*[a-z])~ constant = ~[_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*(?![0-9A-Z_]*[a-z])~
attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~ attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~
id = ~[0-9]*[a-zA-Z_]\w*~ id = ~[0-9]*[a-zA-Z_]\w*~
literal = ~literal~ literal = ~literal~
strip = ~strip~ strip = ~strip~
lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~ lop = ~\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\s*~
slop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\s+~ slop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\s+~
tlop = ~\s+(is\s+(not\s+)?(odd|even|div)\s+by)\s+~ tlop = ~\s+is\s+(not\s+)?(odd|even|div)\s+by\s+~
scond = ~\s+is\s+(not\s+)?(odd|even)~ scond = ~\s+is\s+(not\s+)?(odd|even)~
isin = ~\s+is\s+in\s+~ isin = ~\s+is\s+in\s+~
as = ~\s+as\s+~ as = ~\s+as\s+~
@@ -390,12 +328,11 @@ class Smarty_Internal_Templatelexer
foreach = ~foreach(?![^\s])~ foreach = ~foreach(?![^\s])~
setfilter = ~setfilter\s+~ setfilter = ~setfilter\s+~
instanceof = ~\s+instanceof\s+~ instanceof = ~\s+instanceof\s+~
not = ~([!]\s*)|(not\s+)~ not = ~[!]\s*|not\s+~
typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~ typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~
double_quote = ~["]~ double_quote = ~["]~
text = ~((.*?)(?=(SMARTYliteral|[{]|([<][?]((php\s+|=)|\s+))|([<][%])|([<][?]xml\s+)|([<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>])|([?][>])|([%][>]))))|(.*)~ text = ~(.*?)(?=((SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]SMARTYliteral))|[\s\S]+~
literaltext = ~(.*?)(?=SMARTYldel[/]?literalSMARTYrdel)~ literaltext = ~(.*?)(?=(SMARTYldel)SMARTYal[/]?literalSMARTYrdel)~
anytext = ~.*~
*/ */
/*!lex2php /*!lex2php
%statename TEXT %statename TEXT
@@ -403,11 +340,11 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
comment { comment {
preg_match("/[*]{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); preg_match("/[*]{$this->compiler->getRdelPreg()}/",$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->getRightDelimiter()}'");
} }
$this->value = substr($this->data,$this->counter,$to-$this->counter); $this->value = substr($this->data,$this->counter,$to-$this->counter);
return false; return false;
@@ -475,12 +412,12 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
ldel dollar id nocacherdel { ldel dollar id nocacherdel {
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;
} else { } else {
$this->value = $this->smarty->left_delimiter; $this->value = $this->smarty->getLeftDelimiter();
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
@@ -592,7 +529,7 @@ class Smarty_Internal_Templatelexer
} }
attr { attr {
// 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->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) {
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;
@@ -663,9 +600,6 @@ class Smarty_Internal_Templatelexer
literaltext { literaltext {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} }
anytext {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
*/ */
/*!lex2php /*!lex2php
%statename DOUBLEQUOTEDSTRING %statename DOUBLEQUOTEDSTRING

View File

@@ -167,6 +167,20 @@ class Smarty_Internal_Templateparser
$this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code)); $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code));
} }
/**
* error rundown
*
*/
public function errorRunDown()
{
while ($this->yystack !== Array()) {
$this->yy_pop_parser_stack();
}
if (is_resource($this->yyTraceFILE)) {
fclose($this->yyTraceFILE);
}
}
/** /**
* merge PHP code with prefix code and return parse tree tag object * merge PHP code with prefix code and return parse tree tag object
* *
@@ -327,7 +341,7 @@ smartytag(res) ::= tag(t) RDEL. {
// output tags start here // output tags start here
// //
smartytag(res) ::= SIMPELOUTPUT(i). { smartytag(res) ::= SIMPELOUTPUT(i). {
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $'); $var = trim(substr(i, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) { if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) {
res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\''))); res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\'')));
} else { } else {
@@ -381,8 +395,8 @@ tag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). {
// simple tag like {name} // simple tag like {name}
smartytag(res)::= SIMPLETAG(t). { smartytag(res)::= SIMPLETAG(t). {
$tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length)); $tag = trim(substr(t, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()));
if ($tag == 'strip') { if ($tag === 'strip') {
$this->strip = true; $this->strip = true;
res = null;; res = null;;
} else { } else {
@@ -453,23 +467,23 @@ tag(res) ::= LDELMAKENOCACHE DOLLARID(i). {
// {if}, {elseif} and {while} tag // {if}, {elseif} and {while} tag
tag(res) ::= LDELIF(i) expr(ie). { tag(res) ::= LDELIF(i) expr(ie). {
$tag = trim(substr(i,$this->lex->ldel_length)); $tag = trim(substr(i,$this->compiler->getLdelLength()));
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
} }
tag(res) ::= LDELIF(i) expr(ie) attributes(a). { tag(res) ::= LDELIF(i) expr(ie) attributes(a). {
$tag = trim(substr(i,$this->lex->ldel_length)); $tag = trim(substr(i,$this->compiler->getLdelLength()));
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
} }
tag(res) ::= LDELIF(i) statement(ie). { tag(res) ::= LDELIF(i) statement(ie). {
$tag = trim(substr(i,$this->lex->ldel_length)); $tag = trim(substr(i,$this->compiler->getLdelLength()));
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie));
} }
tag(res) ::= LDELIF(i) statement(ie) attributes(a). { tag(res) ::= LDELIF(i) statement(ie) attributes(a). {
$tag = trim(substr(i,$this->lex->ldel_length)); $tag = trim(substr(i,$this->compiler->getLdelLength()));
res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,a,array('if condition'=>ie));
} }
// {for} tag // {for} tag
@@ -517,8 +531,8 @@ tag(res) ::= LDELSETFILTER ID(m) modparameters(p) modifierlist(l). {
// end of block tag {/....} // end of block tag {/....}
smartytag(res)::= CLOSETAG(t). { smartytag(res)::= CLOSETAG(t). {
$tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length), ' /'); $tag = trim(substr(t, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' /');
if ($tag == 'strip') { if ($tag === 'strip') {
$this->strip = false; $this->strip = false;
res = null; res = null;
} else { } else {
@@ -785,7 +799,7 @@ value(res) ::= doublequoted_with_quotes(s). {
value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). { value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). {
$prefixVar = $this->compiler->getNewPrefixVariable(); $prefixVar = $this->compiler->getNewPrefixVariable();
if (vi['var'] == '\'smarty\'') { if (vi['var'] === '\'smarty\'') {
$this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>'); $this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>');
} else { } else {
$this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>'); $this->compiler->appendPrefixCode("<?php $prefixVar" .' = '. $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>');
@@ -845,7 +859,7 @@ variable(res) ::= DOLLARID(i). {
res = $this->compiler->compileVariable('\''.substr(i,1).'\''); res = $this->compiler->compileVariable('\''.substr(i,1).'\'');
} }
variable(res) ::= varindexed(vi). { variable(res) ::= varindexed(vi). {
if (vi['var'] == '\'smarty\'') { if (vi['var'] === '\'smarty\'') {
$smarty_var = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']); $smarty_var = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']);
res = $smarty_var; res = $smarty_var;
} else { } else {
@@ -987,7 +1001,7 @@ varvarele(res) ::= ID(s). {
res = '\''.s.'\''; res = '\''.s.'\'';
} }
varvarele(res) ::= SIMPELOUTPUT(i). { varvarele(res) ::= SIMPELOUTPUT(i). {
$var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $'); $var = trim(substr(i, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $');
res = $this->compiler->compileVariable('\''.$var.'\''); res = $this->compiler->compileVariable('\''.$var.'\'');
} }
@@ -1000,7 +1014,7 @@ varvarele(res) ::= LDEL expr(e) RDEL. {
// objects // objects
// //
object(res) ::= varindexed(vi) objectchain(oc). { object(res) ::= varindexed(vi) objectchain(oc). {
if (vi['var'] == '\'smarty\'') { if (vi['var'] === '\'smarty\'') {
res = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).oc; res = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).oc;
} else { } else {
res = $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].oc; res = $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].oc;
@@ -1019,7 +1033,7 @@ objectchain(res) ::= objectchain(oc) objectelement(oe). {
// variable // variable
objectelement(res)::= PTR ID(i) arrayindex(a). { objectelement(res)::= PTR ID(i) arrayindex(a). {
if ($this->security && substr(i,0,1) == '_') { if ($this->security && substr(i,0,1) === '_') {
$this->compiler->trigger_template_error (self::Err1); $this->compiler->trigger_template_error (self::Err1);
} }
res = '->'.i.a; res = '->'.i.a;
@@ -1064,7 +1078,7 @@ function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
// method // method
// //
method(res) ::= ID(f) OPENP params(p) CLOSEP. { method(res) ::= ID(f) OPENP params(p) CLOSEP. {
if ($this->security && substr(f,0,1) == '_') { if ($this->security && substr(f,0,1) === '_') {
$this->compiler->trigger_template_error (self::Err1); $this->compiler->trigger_template_error (self::Err1);
} }
res = f . "(". implode(',',p) .")"; res = f . "(". implode(',',p) .")";

File diff suppressed because it is too large Load Diff

View File

@@ -270,6 +270,36 @@ abstract class Smarty_Internal_TemplateCompilerBase
* @var array * @var array
*/ */
public $_cache = array(); public $_cache = array();
/**
* Lexer preg pattern for left delimiter
*
* @var string
*/
private $ldelPreg = '[{]';
/**
* Lexer preg pattern for right delimiter
*
* @var string
*/
private $rdelPreg = '[}]';
/**
* Length of right delimiter
*
* @var int
*/
private $rdelLength = 0;
/**
* Length of left delimiter
*
* @var int
*/
private $ldelLength = 0;
/**
* Lexer preg pattern for user literals
*
* @var string
*/
private $literalPreg = '';
/** /**
* Initialize compiler * Initialize compiler
@@ -1002,6 +1032,11 @@ abstract class Smarty_Internal_TemplateCompilerBase
$error_text .= ', expected one of: ' . implode(' , ', $expect); $error_text .= ', expected one of: ' . implode(' , ', $expect);
} }
} }
if ($this->smarty->_parserdebug) {
$this->parser->errorRunDown();
echo ob_get_clean();
flush();
}
$e = new SmartyCompilerException($error_text); $e = new SmartyCompilerException($error_text);
$e->line = $line; $e->line = $line;
$e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ])); $e->source = trim(preg_replace('![\t\r\n]+!', ' ', $match[ $line - 1 ]));
@@ -1041,6 +1076,52 @@ abstract class Smarty_Internal_TemplateCompilerBase
return count($this->_tag_stack); return count($this->_tag_stack);
} }
/**
* @param $lexerPreg
*
* @return mixed
*/
public function replaceDelimiter($lexerPreg)
{
return str_replace(array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel', 'SMARTYautoliteral', 'SMARTYal'),
array($this->ldelPreg, $this->literalPreg, $this->rdelPreg,
$this->smarty->getAutoLiteral() ? '{1,}' : '{9}',
$this->smarty->getAutoLiteral() ? '' : '\\s*'),
$lexerPreg);
}
/**
* Build lexer regular expressions for left and right delimiter and user defined literals
*/
public function initDelimiterPreg()
{
$ldel = $this->smarty->getLeftDelimiter();
$this->ldelLength = strlen($ldel);
$this->ldelPreg = '';
foreach (str_split($ldel, 1) as $chr) {
$this->ldelPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']';
}
$rdel = $this->smarty->getRightDelimiter();
$this->rdelLength = strlen($rdel);
$this->rdelPreg = '';
foreach (str_split($rdel, 1) as $chr) {
$this->rdelPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']';
}
$literals = $this->smarty->getLiterals();
if (!empty($literals)) {
foreach ($literals as $key => $literal) {
$literalPreg = '';
foreach (str_split($literal, 1) as $chr) {
$literalPreg .= '[' . ($chr === '\\' ? '\\' : '') . $chr . ']';
}
$literals[ $key ] = $literalPreg;
}
$this->literalPreg = '|' . implode('|', $literals);
} else {
$this->literalPreg = '';
}
}
/** /**
* leave double quoted string * leave double quoted string
* - throw exception if block in string was not closed * - throw exception if block in string was not closed
@@ -1057,6 +1138,46 @@ abstract class Smarty_Internal_TemplateCompilerBase
} }
} }
/**
* Get left delimiter preg
*
* @return string
*/
public function getLdelPreg()
{
return $this->ldelPreg;
}
/**
* Get right delimiter preg
*
* @return string
*/
public function getRdelPreg()
{
return $this->rdelPreg;
}
/**
* Get length of left delimiter
*
* @return int
*/
public function getLdelLength()
{
return $this->ldelLength;
}
/**
* Get length of right delimiter
*
* @return int
*/
public function getRdelLength()
{
return $this->rdelLength;
}
/** /**
* Get name of current open block tag * Get name of current open block tag
* *

View File

@@ -71,36 +71,6 @@ class Smarty_Internal_Templatelexer
* @var string * @var string
*/ */
public $phpType = ''; public $phpType = '';
/**
* escaped left delimiter
*
* @var string
*/
public $ldel = '';
/**
* escaped left delimiter with space
*
* @var string
*/
public $ldel_q = '';
/**
* escaped left delimiter length
*
* @var int
*/
public $ldel_length = 0;
/**
* escaped right delimiter
*
* @var string
*/
public $rdel = '';
/**
* escaped right delimiter length
*
* @var int
*/
public $rdel_length = 0;
/** /**
* state number * state number
* *
@@ -186,12 +156,6 @@ class Smarty_Internal_Templatelexer
'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',
); );
/**
* preg string of user defined litereals
*
* @var string
*/
public $literals = '';
/** /**
* literal tag nesting level * literal tag nesting level
* *
@@ -246,28 +210,11 @@ class Smarty_Internal_Templatelexer
$this->counter += strlen($match[ 0 ]); $this->counter += strlen($match[ 0 ]);
} }
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->template->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/') . ($this->smarty->auto_literal ? '' : '\\s*'); $this->compiler->initDelimiterPreg();
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->smarty_token_names[ 'LDEL' ] = $this->smarty->getLeftDelimiter();
$this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $this->smarty_token_names[ 'RDEL' ] = $this->smarty->getRightDelimiter();
$this->rdel_length = strlen($this->smarty->right_delimiter);
$this->smarty_token_names[ 'LDEL' ] = $this->smarty->left_delimiter;
$this->smarty_token_names[ 'RDEL' ] = $this->smarty->right_delimiter;
$literals = $this->smarty->getLiterals();
if (!empty($literals)) {
foreach ($literals as $key => $literal) {
$literals[ $key ] = preg_quote($literal, '/');
}
}
if ($this->smarty->auto_literal) {
$literals[] = $this->ldel . '{1,}\\s+';
}
if (!empty($literals)) {
$this->literals = implode('|', $literals);
} else {
$this->literals = preg_quote('^$', '/');
}
} }
/** /**
@@ -283,15 +230,13 @@ class Smarty_Internal_Templatelexer
/** /**
* replace placeholders with runtime preg code * replace placeholders with runtime preg code
* *
* @param string $input * @param string $preg
* *
* @return string * @return string
*/ */
public function replace($input) public function replace($preg)
{ {
return str_replace(array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel'), return $this->compiler->replaceDelimiter($preg);
array($this->ldel, $this->literals, $this->rdel),
$input);
} }
/** /**
@@ -301,8 +246,8 @@ class Smarty_Internal_Templatelexer
*/ */
public function isAutoLiteral() public function isAutoLiteral()
{ {
return $this->smarty->auto_literal && isset($this->value[ $this->ldel_length ]) ? return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ?
strpos(" \n\t\r", $this->value[ $this->ldel_length ]) !== false : false; strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false;
} // end function } // end function
public function yylex() public function yylex()
@@ -365,7 +310,7 @@ class Smarty_Internal_Templatelexer
{ {
if (!isset($this->yy_global_pattern1)) { if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 = $this->yy_global_pattern1 =
$this->replace("/\G([{][}])|\G(SMARTYldel[*])|\G((SMARTYldelphp([ ].*?)?SMARTYrdel)|(SMARTYldel[\/]phpSMARTYrdel))|\G(SMARTYliteral)|\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(((.*?)(?=(SMARTYliteral|[{]|([<][?]((php\\s+|=)|\\s+))|([<][%])|([<][?]xml\\s+)|([<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>])|([?][>])|([%][>]))))|(.*))/isS"); $this->replace("/\G([{][}])|\G((SMARTYldel)SMARTYal[*])|\G((SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[\/]phpSMARTYrdel)|\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>])|\G((.*?)(?=((SMARTYldel)SMARTYal|[<][?]((php\\s+|=)|\\s+)|[<][%]|[<][?]xml\\s+|[<]script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>]|[?][>]|[%][>]SMARTYliteral))|[\s\S]+)/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -423,50 +368,50 @@ class Smarty_Internal_Templatelexer
function yy_r1_2() function yy_r1_2()
{ {
preg_match("/[*]{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter); preg_match("/[*]{$this->compiler->getRdelPreg()}/", $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->getRightDelimiter()}'");
} }
$this->value = substr($this->data, $this->counter, $to - $this->counter); $this->value = substr($this->data, $this->counter, $to - $this->counter);
return false; return false;
} }
function yy_r1_3() function yy_r1_4()
{ {
$this->compiler->getTagCompiler('private_php')->parsePhp($this); $this->compiler->getTagCompiler('private_php')->parsePhp($this);
} }
function yy_r1_7() function yy_r1_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r1_8() function yy_r1_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERALSTART; $this->token = Smarty_Internal_Templateparser::TP_LITERALSTART;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} }
function yy_r1_9() function yy_r1_12()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERALEND; $this->token = Smarty_Internal_Templateparser::TP_LITERALEND;
$this->yypushstate(self::LITERAL); $this->yypushstate(self::LITERAL);
} // end function } // end function
function yy_r1_10() function yy_r1_14()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
function yy_r1_11() function yy_r1_16()
{ {
$this->compiler->getTagCompiler('private_php')->parsePhp($this); $this->compiler->getTagCompiler('private_php')->parsePhp($this);
} }
function yy_r1_20() function yy_r1_19()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
@@ -475,7 +420,7 @@ class Smarty_Internal_Templatelexer
{ {
if (!isset($this->yy_global_pattern2)) { if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 = $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"); $this->replace("/\G((SMARTYldel)SMARTYal(if|elseif|else if|while)\\s+)|\G((SMARTYldel)SMARTYalfor\\s+)|\G((SMARTYldel)SMARTYalforeach(?![^\s]))|\G((SMARTYldel)SMARTYalsetfilter\\s+)|\G((SMARTYldel)SMARTYalmake_nocache\\s+)|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal)/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -533,70 +478,70 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_3() function yy_r2_4()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELFOR; $this->token = Smarty_Internal_Templateparser::TP_LDELFOR;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_4() function yy_r2_6()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH; $this->token = Smarty_Internal_Templateparser::TP_LDELFOREACH;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_5() function yy_r2_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER; $this->token = Smarty_Internal_Templateparser::TP_LDELSETFILTER;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_6() function yy_r2_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE; $this->token = Smarty_Internal_Templateparser::TP_LDELMAKENOCACHE;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_7() function yy_r2_12()
{ {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG; $this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_9() function yy_r2_15()
{ {
$this->yypopstate(); $this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_CLOSETAG; $this->token = Smarty_Internal_Templateparser::TP_CLOSETAG;
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_10() function yy_r2_17()
{ {
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;
} else { } else {
$this->value = $this->smarty->left_delimiter; $this->value = $this->smarty->getLeftDelimiter();
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
} // end function } // end function
function yy_r2_12() function yy_r2_20()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_13() function yy_r2_22()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
$this->yybegin(self::TAGBODY); $this->yybegin(self::TAGBODY);
@@ -607,7 +552,7 @@ class Smarty_Internal_Templatelexer
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = $this->yy_global_pattern3 =
$this->replace("/\G(\\s*SMARTYrdel)|\G(SMARTYldel)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+(is\\s+(not\\s+)?(odd|even|div)\\s+by)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G(([!]\\s*)|(not\\s+))|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|])|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS"); $this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\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);
@@ -670,148 +615,148 @@ class Smarty_Internal_Templatelexer
return true; return true;
} }
function yy_r3_3() function yy_r3_4()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypushstate(self::DOUBLEQUOTEDSTRING); $this->yypushstate(self::DOUBLEQUOTEDSTRING);
$this->compiler->enterDoubleQuote(); $this->compiler->enterDoubleQuote();
} }
function yy_r3_4() function yy_r3_5()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING; $this->token = Smarty_Internal_Templateparser::TP_SINGLEQUOTESTRING;
} }
function yy_r3_5() function yy_r3_6()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
} }
function yy_r3_6() function yy_r3_7()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLAR; $this->token = Smarty_Internal_Templateparser::TP_DOLLAR;
} }
function yy_r3_7() function yy_r3_8()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ISIN; $this->token = Smarty_Internal_Templateparser::TP_ISIN;
} }
function yy_r3_8() function yy_r3_9()
{ {
$this->token = Smarty_Internal_Templateparser::TP_AS; $this->token = Smarty_Internal_Templateparser::TP_AS;
} }
function yy_r3_9() function yy_r3_10()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TO; $this->token = Smarty_Internal_Templateparser::TP_TO;
} }
function yy_r3_10() function yy_r3_11()
{ {
$this->token = Smarty_Internal_Templateparser::TP_STEP; $this->token = Smarty_Internal_Templateparser::TP_STEP;
} }
function yy_r3_11() function yy_r3_12()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF; $this->token = Smarty_Internal_Templateparser::TP_INSTANCEOF;
} }
function yy_r3_12() function yy_r3_13()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LOGOP; $this->token = Smarty_Internal_Templateparser::TP_LOGOP;
} }
function yy_r3_17() function yy_r3_15()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SLOGOP; $this->token = Smarty_Internal_Templateparser::TP_SLOGOP;
} }
function yy_r3_19() function yy_r3_17()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TLOGOP; $this->token = Smarty_Internal_Templateparser::TP_TLOGOP;
} }
function yy_r3_23() function yy_r3_20()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SINGLECOND; $this->token = Smarty_Internal_Templateparser::TP_SINGLECOND;
} }
function yy_r3_26() function yy_r3_23()
{ {
$this->token = Smarty_Internal_Templateparser::TP_NOT; $this->token = Smarty_Internal_Templateparser::TP_NOT;
} }
function yy_r3_29() function yy_r3_24()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST; $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
} }
function yy_r3_33() function yy_r3_28()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENP; $this->token = Smarty_Internal_Templateparser::TP_OPENP;
} }
function yy_r3_34() function yy_r3_29()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP; $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
} }
function yy_r3_35() function yy_r3_30()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENB; $this->token = Smarty_Internal_Templateparser::TP_OPENB;
} }
function yy_r3_36() function yy_r3_31()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB; $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
} }
function yy_r3_37() function yy_r3_32()
{ {
$this->token = Smarty_Internal_Templateparser::TP_PTR; $this->token = Smarty_Internal_Templateparser::TP_PTR;
} }
function yy_r3_38() function yy_r3_33()
{ {
$this->token = Smarty_Internal_Templateparser::TP_APTR; $this->token = Smarty_Internal_Templateparser::TP_APTR;
} }
function yy_r3_39() function yy_r3_34()
{ {
$this->token = Smarty_Internal_Templateparser::TP_EQUAL; $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
} }
function yy_r3_40() function yy_r3_35()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INCDEC; $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
} }
function yy_r3_42() function yy_r3_37()
{ {
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH; $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
} }
function yy_r3_44() function yy_r3_39()
{ {
$this->token = Smarty_Internal_Templateparser::TP_MATH; $this->token = Smarty_Internal_Templateparser::TP_MATH;
} }
function yy_r3_46() function yy_r3_41()
{ {
$this->token = Smarty_Internal_Templateparser::TP_AT; $this->token = Smarty_Internal_Templateparser::TP_AT;
} }
function yy_r3_47() function yy_r3_42()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HATCH; $this->token = Smarty_Internal_Templateparser::TP_HATCH;
} }
function yy_r3_48() function yy_r3_43()
{ {
// 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->compiler->getRdelLength()) ===
$this->smarty->right_delimiter) { $this->smarty->getRightDelimiter()) {
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;
@@ -820,73 +765,73 @@ class Smarty_Internal_Templatelexer
} }
} }
function yy_r3_49() function yy_r3_44()
{ {
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
} }
function yy_r3_52() function yy_r3_47()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ID; $this->token = Smarty_Internal_Templateparser::TP_ID;
} }
function yy_r3_53() function yy_r3_48()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INTEGER; $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
} }
function yy_r3_54() function yy_r3_49()
{ {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r3_55() function yy_r3_50()
{ {
$this->token = Smarty_Internal_Templateparser::TP_VERT; $this->token = Smarty_Internal_Templateparser::TP_VERT;
} }
function yy_r3_56() function yy_r3_51()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOT; $this->token = Smarty_Internal_Templateparser::TP_DOT;
} }
function yy_r3_57() function yy_r3_52()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COMMA; $this->token = Smarty_Internal_Templateparser::TP_COMMA;
} }
function yy_r3_58() function yy_r3_53()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
} }
function yy_r3_59() function yy_r3_54()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
} }
function yy_r3_60() function yy_r3_55()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COLON; $this->token = Smarty_Internal_Templateparser::TP_COLON;
} }
function yy_r3_61() function yy_r3_56()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QMARK; $this->token = Smarty_Internal_Templateparser::TP_QMARK;
} }
function yy_r3_62() function yy_r3_57()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HEX; $this->token = Smarty_Internal_Templateparser::TP_HEX;
} }
function yy_r3_63() function yy_r3_58()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function } // end function
function yy_r3_64() function yy_r3_59()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
@@ -895,7 +840,7 @@ class Smarty_Internal_Templatelexer
{ {
if (!isset($this->yy_global_pattern4)) { if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 = $this->yy_global_pattern4 =
$this->replace("/\G(SMARTYldelliteral\\s*SMARTYrdel)|\G(SMARTYldel[\/]literal\\s*SMARTYrdel)|\G((.*?)(?=SMARTYldel[\/]?literalSMARTYrdel))|\G(.*)/isS"); $this->replace("/\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((.*?)(?=(SMARTYldel)SMARTYal[\/]?literalSMARTYrdel))/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -952,7 +897,7 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
} }
function yy_r4_2() function yy_r4_3()
{ {
if ($this->literal_cnt) { if ($this->literal_cnt) {
$this->literal_cnt--; $this->literal_cnt--;
@@ -963,11 +908,6 @@ class Smarty_Internal_Templatelexer
} }
} }
function yy_r4_3()
{
$this->token = Smarty_Internal_Templateparser::TP_LITERAL;
}
function yy_r4_5() function yy_r4_5()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LITERAL; $this->token = Smarty_Internal_Templateparser::TP_LITERAL;
@@ -977,7 +917,7 @@ class Smarty_Internal_Templatelexer
{ {
if (!isset($this->yy_global_pattern5)) { if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = $this->yy_global_pattern5 =
$this->replace("/\G(SMARTYliteral)|\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(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(SMARTYliteral|SMARTYldel|\\$|`\\$|\")))/isS"); $this->replace("/\G((SMARTYldel)SMARTYautoliteral\\s+SMARTYliteral)|\G((SMARTYldel)SMARTYalliteral\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/]literal\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal[\/])|\G((SMARTYldel)SMARTYal[0-9]*[a-zA-Z_]\\w*)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=((SMARTYldel)SMARTYal|\\$|`\\$|\"SMARTYliteral)))/isS");
} }
if (!isset($this->dataLength)) { if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data); $this->dataLength = strlen($this->data);
@@ -1033,42 +973,42 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r5_2()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_3() function yy_r5_3()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r5_4()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_5() function yy_r5_5()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r5_7()
{ {
$this->yypushstate(self::TAG); $this->yypushstate(self::TAG);
return true; return true;
} }
function yy_r5_6() function yy_r5_9()
{
$this->yypushstate(self::TAG);
return true;
}
function yy_r5_11()
{ {
$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_7() function yy_r5_13()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QUOTE; $this->token = Smarty_Internal_Templateparser::TP_QUOTE;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r5_8() function yy_r5_14()
{ {
$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);
@@ -1076,17 +1016,17 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r5_9() function yy_r5_15()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOLLARID; $this->token = Smarty_Internal_Templateparser::TP_DOLLARID;
} }
function yy_r5_10() function yy_r5_16()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r5_11() function yy_r5_17()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TEXT; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }

File diff suppressed because it is too large Load Diff