- improvement on php_handling to allow very large PHP sections, better error handling

- improvement allow extreme large comment sections (forum 25538)
This commit is contained in:
Uwe Tews
2015-05-23 18:56:00 +02:00
parent c8ecad0b06
commit ec449734c3
8 changed files with 1277 additions and 763 deletions

View File

@@ -1,4 +1,8 @@
 ===== 3.1.24.dev ===== (xx.xx.2015)
23.05.2015
- improvement on php_handling to allow very large PHP sections, better error handling
- improvement allow extreme large comment sections (forum 25538)
21.05.2015
- bugfix broken PHP 5.2 compatibility when compiling <?php tags https://github.com/smarty-php/smarty/issues/40
- bugfix named {foreach} comparison like $smarty.foreach.foobar.index > 1 did compile into wrong code https://github.com/smarty-php/smarty/issues/41

View File

@@ -55,12 +55,6 @@ class Smarty_Internal_Templatelexer
* @var
*/
public $taglineno;
/**
* flag if parsing php script
*
* @var bool
*/
public $is_phpScript = false;
/**
* php code type
*
@@ -108,25 +102,35 @@ class Smarty_Internal_Templatelexer
*
* @var Smarty_Internal_TemplateCompilerBase
*/
private $compiler = null;
public $compiler = null;
/**
* literal tag nesting level
*
* @var int
*/
private $literal_cnt = 0;
/**
* PHP start tag string
*
* @var string
*/
/**
* trace file
*
* @var resource
*/
public $yyTraceFILE;
/**
* trace prompt
*
* @var string
*/
public $yyTracePrompt;
/**
* state names
*
@@ -138,15 +142,22 @@ class Smarty_Internal_Templatelexer
/**
* storage for assembled token patterns
*
* @var sring
* @var string
*/
private $yy_global_pattern1 = null;
private $yy_global_pattern2 = null;
private $yy_global_pattern3 = null;
private $yy_global_pattern4 = null;
private $yy_global_pattern5 = null;
private $yy_global_pattern6 = null;
private $yy_global_pattern7 = null;
private $yy_global_pattern8 = null;
/**
@@ -203,15 +214,15 @@ class Smarty_Internal_Templatelexer
{
$this->data = $data;
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
$this->counter += strlen($match[0]);
}
$this->line = 1;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/');
$this->ldel = preg_quote($this->smarty->left_delimiter, '~');
$this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '/');
$this->rdel = preg_quote($this->smarty->right_delimiter, '~');
$this->rdel_length = strlen($this->smarty->right_delimiter);
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
@@ -223,78 +234,81 @@ class Smarty_Internal_Templatelexer
$this->yyTracePrompt = '<br>';
}
/*
* 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
%input $this->data
%counter $this->counter
%token $this->token
%value $this->value
%line $this->line
linebreak = /[\t ]*[\r\n]+[\t ]*/
text = /[\S\s]/
textdoublequoted = /([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))/
namespace = /([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+/
all = /[\S\s]+/
emptyjava = /\{\}/
xmltag = /<[?]xml\s+([\S\s]*?)[?]>/
php = #<[?](?:php(?=[\s=]))?((?:(?![?]>)[^/][^?'"/]*)(([/][*](?:(?![*][/])[\S\s][^*]*)*[*][/])|([/][/][^\n]*)|('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*"))*)*[?]>#
asp = #<[%]((?:(?![%]>)[^/][^%'"/]*)(([/][*](?:(?![*][/])[\S\s][^*]*)*[*][/])|([/][/][^\n]*)|('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*"))*)*[%]>#
phpscript = #<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>((?:(?!</script>)[^/][^<'"/]*)(([/][*](?:(?![*][/])[\S\s][^*]*)*[*][/])|([/][/][^\n]*)|('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*"))*)*</script>#
phptag = #((SMARTYldel\s*php\s*(.)*?SMARTYrdel)((?:(?!(SMARTYldel\s*[/]php\s*SMARTYrdel))[^/\{][^SMARTYldelFIRST'"/]*)(([/][*](?:(?![*][/])[\S\s][^*]*)*[*][/])|([/][/][^\n]*)|('[^'\\]*(?:\\.[^'\\]*)*')|("[^"\\]*(?:\\.[^"\\]*)*"))*)*(SMARTYldel\s*[/]php\s*SMARTYrdel)?)|(SMARTYldel\s*[/]?php\s*SMARTYrdel)#
unmatched = /((<[?](?:php\s+|=)?)|(<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|<[%]|[?][>]|[%][>])/
slash = /\//
ldel = /SMARTYldel\s*/
rdel = /\s*SMARTYrdel/
nocacherdel = /(\s+nocache)?\s*SMARTYrdel/
notblockid = /(?:(?!block)[0-9]*[a-zA-Z_]\w*)/
smartyblockchildparent = /[\$]smarty\.block\.(child|parent)/
integer = /\d+/
hex = /0[xX][0-9a-fA-F]+/
math = /\s*([*]{1,2}|[%\/^&]|[<>]{2})\s*/
comment = /SMARTYldel[*]((?:(?![*]SMARTYrdel)[\S\s][^*]*))*[*]SMARTYrdel/
incdec = /\+\+|\-\-/
unimath = /\s*(\+|\-)\s*/
openP = /\s*\(\s*/
closeP = /\s*\)/
openB = /\[\s*/
closeB = /\s*\]/
dollar = /\$/
dot = /\./
comma = /\s*\,\s*/
doublecolon = /\:\:/
colon = /\s*\:\s*/
at = /@/
hatch = /#/
semicolon = /\s*\;\s*/
equal = /\s*=\s*/
space = /\s+/
ptr = /\s*\->\s*/
aptr = /\s*=>\s*/
singlequotestring = /'[^'\\]*(?:\\.[^'\\]*)*'/
backtick = /`/
vert = /\|/
qmark = /\s*[?]\s*/
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*/
id = /[0-9]*[a-zA-Z_]\w*/
literal = /literal/
strip = /strip/
lop = /\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*/
tlop = /\s+(eq|ne|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+/
scond = /\s+is\s+(not\s+)?(odd|even)/
isin = /\s+is\s+in\s+/
as = /\s+as\s+/
to = /\s+to\s+/
step = /\s+step\s+/
block = /block/
if = /(if|elseif|else if|while)\s+/
for = /for\s+/
foreach = /foreach(?![^\s])/
setfilter = /setfilter\s+/
instanceof = /\s+instanceof\s+/
not = /!\s*|not\s+/
typecast = /\((int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)\)\s*/
double_quote = /"/
single_quote = /'/
linebreak = ~[\t ]*[\r\n]+[\t ]*~
text = ~[\S\s]~
textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYldel|\$|`\$|"))~
namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~
all = ~[\S\s]+~
emptyjava = ~[{][}]~
phpstart = ~(<[?]((php\s+|=)|\s+))|(<[%])|(<[?]xml\s+)|(<script\s+language\s*=\s*["']?\s*php\s*["']?\s*>)|([?][>])|([%][>])|(SMARTYldel\s*php(.*?)SMARTYrdel)|(SMARTYldel\s*[/]phpSMARTYrdel)~
slash = ~[/]~
ldel = ~SMARTYldel\s*~
rdel = ~\s*SMARTYrdel~
nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~
notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~
smartyblockchildparent = ~[\$]smarty\.block\.(child|parent)~
integer = ~\d+~
hex = ~0[xX][0-9a-fA-F]+~
math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~
comment = ~SMARTYldel[*]~
incdec = ~([+]|[-]){2}~
unimath = ~\s*([+]|[-])\s*~
openP = ~\s*[(]\s*~
closeP = ~\s*[)]~
openB = ~\[\s*~
closeB = ~\s*\]~
dollar = ~[$]~
dot = ~[.]~
comma = ~\s*[,]\s*~
doublecolon = ~[:]{2}~
colon = ~\s*[:]\s*~
at = ~[@]~
hatch = ~[#]~
semicolon = ~\s*[;]\s*~
equal = ~\s*[=]\s*~
space = ~\s+~
ptr = ~\s*[-][>]\s*~
aptr = ~\s*[=][>]\s*~
singlequotestring = ~'[^'\\]*(?:\\.[^'\\]*)*'~
backtick = ~[`]~
vert = ~[|]~
qmark = ~\s*[?]\s*~
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*~
id = ~[0-9]*[a-zA-Z_]\w*~
literal = ~literal~
strip = ~strip~
lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~
tlop = ~\s+(eq|ne|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(is\s+(not\s+)?(odd|even|div)\s+by))\s+~
scond = ~\s+is\s+(not\s+)?(odd|even)~
isin = ~\s+is\s+in\s+~
as = ~\s+as\s+~
to = ~\s+to\s+~
step = ~\s+step\s+~
block = ~block~
if = ~(if|elseif|else if|while)\s+~
for = ~for\s+~
foreach = ~foreach(?![^\s])~
setfilter = ~setfilter\s+~
instanceof = ~\s+instanceof\s+~
not = ~([!]\s*)|(not\s+)~
typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~
double_quote = ~["]~
single_quote = ~[']~
*/
/*!lex2php
%statename TEXT
@@ -302,7 +316,19 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
comment {
$this->token = Smarty_Internal_Templateparser::TP_COMMENT;
preg_match("~[*]{$this->rdel}~",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1] + strlen($match[0][0]);
} else {
$this->compiler->trigger_template_error ("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
}
$this->value = substr($this->data,$this->counter,$to-$this->counter);
return false;
}
phpstart {
$obj = new Smarty_Internal_Compile_Private_Php();
$obj->parsePhp($this);
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
ldel literal rdel {
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
@@ -323,33 +349,9 @@ class Smarty_Internal_Templatelexer
rdel {
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
xmltag {
$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
$this->taglineno = $this->line;
}
asp {
$this->phpType = 'asp';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
php {
$this->phpType = 'php';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
phpscript {
$this->phpType = 'script';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
unmatched {
$this->phpType = 'unmatched';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
text {
$to = strlen($this->data);
preg_match("/{$this->ldel}|<[?]|<%|[?]>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -379,12 +381,6 @@ class Smarty_Internal_Templatelexer
$this->yybegin(self::TAGBODY);
$this->taglineno = $this->line;
}
phptag {
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_PHP;
$this->phpType = 'tag';
$this->taglineno = $this->line;
}
ldel id nocacherdel {
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_SIMPLETAG;
@@ -503,7 +499,7 @@ class Smarty_Internal_Templatelexer
attr {
// 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) {
preg_match("/\s+/",$this->value,$match);
preg_match("~\s+~",$this->value,$match);
$this->value = $match[0];
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} else {
@@ -580,7 +576,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("/{$this->ldel}\/?literal{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
} else {
@@ -674,7 +670,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("/SMARTYldel\s*((\/)?strip\s*SMARTYrdel|block\s+)/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("~SMARTYldel\s*(([/])?strip\s*SMARTYrdel|block\s+)~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -719,7 +715,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("/SMARTYldel\s*(literal\s*SMARTYrdel|(\/)?block(\s|SMARTYrdel)|[\$]smarty\.block\.(child|parent))/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("~SMARTYldel\s*(literal\s*SMARTYrdel|([/])?block(\s|SMARTYrdel)|[\$]smarty\.block\.(child|parent))~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -747,7 +743,7 @@ class Smarty_Internal_Templatelexer
}
text {
$to = strlen($this->data);
preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
} else {

View File

@@ -124,13 +124,6 @@ class Smarty_Internal_Templateparser
*/
private $security = null;
/**
* PHP tag handling mode
*
* @var int
*/
private $php_handling = 0;
/**
* constructor
*
@@ -143,13 +136,7 @@ class Smarty_Internal_Templateparser
$this->compiler = $compiler;
$this->template = $this->compiler->template;
$this->smarty = $this->template->smarty;
$this->compiler->has_variable_string = false;
$this->compiler->prefix_code = array();
if ($this->security = isset($this->smarty->security_policy)) {
$this->php_handling = $this->smarty->security_policy->php_handling;
} else {
$this->php_handling = $this->smarty->php_handling;
}
$this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false;
$this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template($this);
}
@@ -250,11 +237,6 @@ template_element(res)::= smartytag(st). {
$this->block_nesting_level = count($this->compiler->_tag_stack);
}
// comments
template_element(res)::= COMMENT(c). {
res = null;
}
// Literal
template_element(res) ::= literal(l). {
res = new Smarty_Internal_ParseTree_Text($this, l);
@@ -270,17 +252,6 @@ template_element(res)::= PHP(o). {
}
}
// XML tag
template_element(res)::= XMLTAG(x). {
$this->compiler->tag_nocache = true;
$xml = x;
$save = $this->template->has_nocache_code;
res = new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode("<?php echo '{$xml}';?>", $this->compiler, true));
$this->template->has_nocache_code = $save;
}
// template text
template_element(res)::= text_content(t). {
res = $this->compiler->processText(t);
@@ -411,8 +382,8 @@ smartytag(res)::= SIMPLETAG(t). {
res = null;;
} else {
if (defined($tag)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant($tag, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant($tag, $this->compiler);
}
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>$tag));
} else {
@@ -428,8 +399,8 @@ smartytag(res)::= SIMPLETAG(t). {
// tag with optional Smarty2 style attributes
tag(res) ::= LDEL ID(i) attributes(a). {
if (defined(i)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(i, $this->compiler);
}
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i));
} else {
@@ -438,8 +409,8 @@ tag(res) ::= LDEL ID(i) attributes(a). {
}
tag(res) ::= LDEL ID(i). {
if (defined(i)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(i, $this->compiler);
}
res = $this->compiler->compileTag('private_print_expression',array(),array('value'=>i));
} else {
@@ -451,8 +422,8 @@ tag(res) ::= LDEL ID(i). {
// tag with modifier and optional Smarty2 style attributes
tag(res) ::= LDEL ID(i) modifierlist(l)attributes(a). {
if (defined(i)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(i, $this->compiler);
}
res = $this->compiler->compileTag('private_print_expression',a,array('value'=>i, 'modifierlist'=>l));
} else {
@@ -607,8 +578,8 @@ attributes(res) ::= . {
// attribute
attribute(res) ::= SPACE ID(v) EQUAL ID(id). {
if (defined(id)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(id, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(id, $this->compiler);
}
res = array(v=>id);
} else {
@@ -788,8 +759,8 @@ value(res) ::= DOT INTEGER(n1). {
// ID, true, false, null
value(res) ::= ID(id). {
if (defined(id)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(id, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(id, $this->compiler);
}
res = id;
} else {
@@ -847,7 +818,7 @@ value(res) ::= NAMESPACE(c). {
// static class access
value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). {
if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->smarty->security_policy->isTrustedStaticClassAccess(c, s, $this->compiler))) {
if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess(c, s, $this->compiler))) {
if (isset($this->smarty->registered_classes[c])) {
res = $this->smarty->registered_classes[c].'::'.s[0].s[1];
} else {
@@ -957,8 +928,8 @@ indexdef(res) ::= DOT varvar(v) AT ID(p). {
indexdef(res) ::= DOT ID(i). {
if (defined(i)) {
if (isset($this->smarty->security_policy)) {
$this->smarty->security_policy->isTrustedConstant(i, $this->compiler);
if ($this->security) {
$this->security->isTrustedConstant(i, $this->compiler);
}
res = '['. i .']';
} else {
@@ -1102,7 +1073,7 @@ objectelement(res)::= PTR method(f). {
// function
//
function(res) ::= ns1(f) OPENP params(p) CLOSEP. {
if (!$this->security || $this->smarty->security_policy->isTrustedPhpFunction(f, $this->compiler)) {
if (!$this->security || $this->security->isTrustedPhpFunction(f, $this->compiler)) {
if (strcasecmp(f,'isset') === 0 || strcasecmp(f,'empty') === 0 || strcasecmp(f,'array') === 0 || is_callable(f)) {
$func_name = strtolower(f);
if ($func_name == 'isset') {

View File

@@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.24-dev/9';
const SMARTY_VERSION = '3.1.24-dev/10';
/**
* define variable scopes

View File

@@ -40,31 +40,30 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
// check and get attributes
$_attr = $this->getAttributes($compiler, $args);
$compiler->has_code = false;
$this->asp_tags = (ini_get('asp_tags') != '0');
if ($_attr['type'] == 'tag' && !($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
if ($_attr['type'] == 'xml') {
$compiler->tag_nocache = true;
$save = $compiler->template->has_nocache_code;
$compiler->template->has_nocache_code = $save;
$output = addcslashes($_attr['code'], "'\\");
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
return '';
}
if ($_attr['type'] != 'tag') {
if (isset($compiler->smarty->security_policy)) {
$this->php_handling = $compiler->smarty->security_policy->php_handling;
} else {
$this->php_handling = $compiler->smarty->php_handling;
}
if ($this->php_handling == Smarty::PHP_REMOVE) {
$output = preg_replace(array('#^(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)#',
'#(\?>)|(%>)|(<\/script>)$#'), '', $_attr['code']);
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
if ($compiler->php_handling == Smarty::PHP_REMOVE) {
return '';
} elseif ($this->php_handling == Smarty::PHP_QUOTE) {
$output = preg_replace_callback(array('#^(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)#',
'#(\?>)|(%>)|(<\/script>)$#'), array($this,
} elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
$output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
'quote'), $_attr['code']);
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
return '';
} elseif ($this->php_handling == Smarty::PHP_PASSTHRU || ($_attr['type'] == 'asp' && !$this->asp_tags) || $_attr['type'] == 'unmatched') {
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $_attr['code']));
} elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
$compiler->tag_nocache = true;
$save = $compiler->template->has_nocache_code;
$compiler->template->has_nocache_code = $save;
$output = addcslashes($_attr['code'], "'\\");
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Tag($compiler->parser, $compiler->processNocacheCode("<?php echo '" . $output . "';?>", $compiler, true)));
return '';
} elseif ($this->php_handling == Smarty::PHP_ALLOW) {
} elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
if (!($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', $compiler->lex->taglineno);
}
@@ -75,14 +74,12 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
}
} else {
$compiler->has_code = true;
if (!($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno);
}
$ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#');
if (!preg_match("#{$ldel}\\s*/\\s*php\\s*{$rdel}$#", $_attr['code'], $match)) {
$compiler->trigger_template_error('Missing {/php} closing tag', $compiler->lex->taglineno);
}
if (!preg_match("#^({$ldel}\\s*php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match)) {
$compiler->trigger_template_error('Missing {php} open tag', $compiler->lex->taglineno);
}
preg_match("#^({$ldel}php\\s*)((.)*?)({$rdel})#", $_attr['code'], $match);
if (!empty($match[2])) {
if ('nocache' == trim($match[2])) {
$compiler->tag_nocache = true;
@@ -95,6 +92,92 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
}
}
/**
* Lexer code for PHP tags
*
* This code has been moved from lexer here fo easier debugging and maintenance
*
* @param $lex
*/
public function parsePhp($lex)
{
$close = 0;
$lex->taglineno = $lex->line;
$closeTag = '?>';
if (strpos($lex->value, '<?xml') === 0) {
$lex->phpType = 'xml';
} elseif (strpos($lex->value, '<?') === 0) {
$lex->phpType = 'php';
} elseif (strpos($lex->value, '<%') === 0) {
$lex->phpType = 'asp';
$closeTag = '%>';
} elseif (strpos($lex->value, '%>') === 0) {
$lex->phpType = 'unmatched';
} elseif (strpos($lex->value, '?>') === 0) {
$lex->phpType = 'unmatched';
} elseif (strpos($lex->value, '<s') === 0) {
$lex->phpType = 'script';
$closeTag = '</script>';
} elseif (strpos($lex->value, $lex->smarty->left_delimiter) === 0) {
if ($lex->isAutoLiteral()) {
$lex->token = Smarty_Internal_Templateparser::TP_TEXT;
return;
}
$closeTag = "{$lex->smarty->left_delimiter}/php{$lex->smarty->right_delimiter}";
if ($lex->value == $closeTag) {
$lex->compiler->trigger_template_error("unexpected closing tag '{$closeTag}'");
}
$lex->phpType = 'tag';
}
if ($lex->phpType == 'unmatched') {
return;
}
if (($lex->phpType == 'php' || $lex->phpType == 'asp') && ($lex->compiler->php_handling == Smarty::PHP_PASSTHRU || $lex->compiler->php_handling == Smarty::PHP_QUOTE)) {
return;
}
$start = $lex->counter + strlen($lex->value);
$body = true;
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
$close = $match[0][1];
} else {
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
}
while ($body) {
if (preg_match('~([/][*])|([/][/][^\n]*)|(\'[^\'\\\\]*(?:\\.[^\'\\\\]*)*\')|("[^"\\\\]*(?:\\.[^"\\\\]*)*")~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start)) {
$value = $match[0][0];
$from = $pos = $match[0][1];
if ($pos > $close) {
$body = false;
} else {
$start = $pos + strlen($value);
$phpCommentStart = $value == '/*';
if ($phpCommentStart) {
$phpCommentEnd = preg_match('~([*][/])~', $lex->data, $match, PREG_OFFSET_CAPTURE, $start);
if ($phpCommentEnd) {
$pos2 = $match[0][1];
$start = $pos2 + strlen($match[0][0]);
}
}
while ($close > $pos && $close < $start) {
if (preg_match('~' . preg_quote($closeTag, '~') . '~i', $lex->data, $match, PREG_OFFSET_CAPTURE, $from)) {
$close = $match[0][1];
$from = $close + strlen($match[0][0]);
} else {
$lex->compiler->trigger_template_error("missing closing tag '{$closeTag}'");
}
}
if ($phpCommentStart && (!$phpCommentEnd || $pos2 > $close)) {
$lex->taglineno = $lex->line + substr_count(substr($lex->data, $lex->counter, $start), "\n");
$lex->compiler->trigger_template_error("missing PHP comment closing tag '*/'");
}
}
} else {
$body = false;
}
}
$lex->value = substr($lex->data, $lex->counter, $close + strlen($closeTag) - $lex->counter);
}
/*
* Call back function for $php_handling = PHP_QUOTE
*

View File

@@ -73,7 +73,7 @@ class Smarty_Internal_ParseTree_Template extends Smarty_Internal_ParseTree
if ($subtree == '') {
continue;
}
$code .= preg_replace('/(<%|%>|<\?php|<\?|\?>|<\/?script)/', "<?php echo '\$1'; ?>\n", $subtree);
$code .= preg_replace('/((<%)|(%>)|(<\?php)|(<\?)|(\?>)|(<\/?script))/', "<?php echo '\$1'; ?>\n", $subtree);
continue;
}
if ($this->subtrees[$key] instanceof Smarty_Internal_ParseTree_Tag) {

View File

@@ -62,13 +62,6 @@ class Smarty_Internal_Templatelexer
*/
public $taglineno;
/**
* flag if parsing php script
*
* @var bool
*/
public $is_phpScript = false;
/**
* php code type
*
@@ -123,7 +116,7 @@ class Smarty_Internal_Templatelexer
*
* @var Smarty_Internal_TemplateCompilerBase
*/
private $compiler = null;
public $compiler = null;
/**
* literal tag nesting level
@@ -132,6 +125,12 @@ class Smarty_Internal_Templatelexer
*/
private $literal_cnt = 0;
/**
* PHP start tag string
*
* @var string
*/
/**
* trace file
*
@@ -144,6 +143,7 @@ class Smarty_Internal_Templatelexer
*
* @var string
*/
public $yyTracePrompt;
/**
@@ -151,12 +151,13 @@ class Smarty_Internal_Templatelexer
*
* @var array
*/
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING', 6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL');
public $state_name = array(1 => 'TEXT', 2 => 'TAG', 3 => 'TAGBODY', 4 => 'LITERAL', 5 => 'DOUBLEQUOTEDSTRING',
6 => 'CHILDBODY', 7 => 'CHILDBLOCK', 8 => 'CHILDLITERAL');
/**
* storage for assembled token patterns
*
* @var sring
* @var string
*/
private $yy_global_pattern1 = null;
@@ -180,7 +181,15 @@ class Smarty_Internal_Templatelexer
* @var array
*/
public $smarty_token_names = array( // Text for parser error messages
'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', 'CLOSEB' => ']', 'PTR' => '->', 'APTR' => '=>', 'EQUAL' => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%', 'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';', 'COLON' => ':', 'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier', 'DOT' => '.', 'COMMA' => '","', 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text', 'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', 'COMMENT' => 'comment', 'AS' => 'as', 'TO' => 'to', 'PHP' => '"<?php", "<%", "{php}" tag', 'LOGOP' => '"<", "==" ... logical operator', 'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition', 'SCOND' => '"is even" ... if condition',);
'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', 'CLOSEB' => ']', 'PTR' => '->',
'APTR' => '=>', 'EQUAL' => '=', 'NUMBER' => 'number', 'UNIMATH' => '+" , "-', 'MATH' => '*" , "/" , "%',
'INCDEC' => '++" , "--', 'SPACE' => ' ', 'DOLLAR' => '$', 'SEMICOLON' => ';', 'COLON' => ':',
'DOUBLECOLON' => '::', 'AT' => '@', 'HATCH' => '#', 'QUOTE' => '"', 'BACKTICK' => '`', 'VERT' => '"|" modifier',
'DOT' => '.', 'COMMA' => '","', 'QMARK' => '"?"', 'ID' => 'id, name', 'TEXT' => 'text',
'LDELSLASH' => '{/..} closing tag', 'LDEL' => '{...} Smarty tag', 'COMMENT' => 'comment', 'AS' => 'as',
'TO' => 'to', 'PHP' => '"<?php", "<%", "{php}" tag', 'LOGOP' => '"<", "==" ... logical operator',
'TLOGOP' => '"lt", "eq" ... logical operator; "is div by" ... if condition',
'SCOND' => '"is even" ... if condition',);
/**
* constructor
@@ -192,15 +201,15 @@ class Smarty_Internal_Templatelexer
{
$this->data = $data;
$this->counter = 0;
if (preg_match('/^\xEF\xBB\xBF/', $this->data, $match)) {
if (preg_match('~^\xEF\xBB\xBF~i', $this->data, $match)) {
$this->counter += strlen($match[0]);
}
$this->line = 1;
$this->smarty = $compiler->smarty;
$this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/');
$this->ldel = preg_quote($this->smarty->left_delimiter, '~');
$this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '/');
$this->rdel = preg_quote($this->smarty->right_delimiter, '~');
$this->rdel_length = strlen($this->smarty->right_delimiter);
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
@@ -212,6 +221,14 @@ class Smarty_Internal_Templatelexer
$this->yyTracePrompt = '<br>';
}
/*
* 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();
@@ -255,7 +272,7 @@ class Smarty_Internal_Templatelexer
public function yylex1()
{
if (!isset($this->yy_global_pattern1)) {
$this->yy_global_pattern1 = "/\G(\\{\\})|\G(" . $this->ldel . "[*]((?:(?![*]" . $this->rdel . ")[\S\s][^*]*))*[*]" . $this->rdel . ")|\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*)|\G(\\s*" . $this->rdel . ")|\G(<[?]xml\\s+([\S\s]*?)[?]>)|\G(<[%]((?:(?![%]>)[^\/][^%'\"\/]*)(([\/][*](?:(?![*][\/])[\S\s][^*]*)*[*][\/])|([\/][\/][^\n]*)|('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"))*)*[%]>)|\G(<[?](?:php(?=[\s=]))?((?:(?![?]>)[^\/][^?'\"\/]*)(([\/][*](?:(?![*][\/])[\S\s][^*]*)*[*][\/])|([\/][\/][^\n]*)|('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"))*)*[?]>)|\G(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>((?:(?!<\/script>)[^\/][^<'\"\/]*)(([\/][*](?:(?![*][\/])[\S\s][^*]*)*[*][\/])|([\/][\/][^\n]*)|('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"))*)*<\/script>)|\G(((<[?](?:php\\s+|=)?)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*[>])|<[%]|[?][>]|[%][>]))|\G([\S\s])/iS";
$this->yy_global_pattern1 = "/\G([{][}])|\G(" . $this->ldel . "[*])|\G((<[?]((php\\s+|=)|\\s+))|(<[%])|(<[?]xml\\s+)|(<script\\s+language\\s*=\\s*[\"']?\\s*php\\s*[\"']?\\s*>)|([?][>])|([%][>])|(" . $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([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -308,10 +325,25 @@ class Smarty_Internal_Templatelexer
function yy_r1_2()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMENT;
preg_match("~[*]{$this->rdel}~", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1] + strlen($match[0][0]);
} else {
$this->compiler->trigger_template_error("missing or misspelled comment closing tag '*{$this->smarty->right_delimiter}'");
}
$this->value = substr($this->data, $this->counter, $to - $this->counter);
return false;
}
function yy_r1_4()
function yy_r1_3()
{
$obj = new Smarty_Internal_Compile_Private_Php();
$obj->parsePhp($this);
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
function yy_r1_15()
{
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
@@ -322,7 +354,7 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r1_5()
function yy_r1_16()
{
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
@@ -333,56 +365,17 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r1_6()
function yy_r1_17()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
function yy_r1_7()
{
$this->token = Smarty_Internal_Templateparser::TP_XMLTAG;
$this->taglineno = $this->line;
}
function yy_r1_9()
{
$this->phpType = 'asp';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
function yy_r1_16()
{
$this->phpType = 'php';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
function yy_r1_23()
{
$this->phpType = 'script';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
function yy_r1_30()
{
$this->phpType = 'unmatched';
$this->taglineno = $this->line;
$this->token = Smarty_Internal_Templateparser::TP_PHP;
}
function yy_r1_34()
function yy_r1_18()
{
$to = strlen($this->data);
preg_match("/{$this->ldel}|<[?]|<%|[?]>|%>|<script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*>/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("~($this->ldel)|([<]script\s+language\s*=\s*[\"\']?\s*php\s*[\"\']?\s*[>])|([<][?])|([<][%])|([?][>])|([%][>])~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -393,7 +386,7 @@ class Smarty_Internal_Templatelexer
public function yylex2()
{
if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(((" . $this->ldel . "\\s*php\\s*(.)*?" . $this->rdel . ")((?:(?!(" . $this->ldel . "\\s*[\/]php\\s*" . $this->rdel . "))[^\/{][^" . preg_quote($this->smarty->left_delimiter[0]) . "'\"\/]*)(([\/][*](?:(?![*][\/])[\S\s][^*]*)*[*][\/])|([\/][\/][^\n]*)|('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"))*)*(" . $this->ldel . "\\s*[\/]php\\s*" . $this->rdel . ")?)|(" . $this->ldel . "\\s*[\/]?php\\s*" . $this->rdel . "))|\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*)/iS";
$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*[0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/](?:(?!block)[0-9]*[a-zA-Z_]\\w*)\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[$][0-9]*[a-zA-Z_]\\w*(\\s+nocache)?\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*)/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -470,15 +463,6 @@ class Smarty_Internal_Templatelexer
}
function yy_r2_6()
{
$this->yypopstate();
$this->token = Smarty_Internal_Templateparser::TP_PHP;
$this->phpType = 'tag';
$this->taglineno = $this->line;
}
function yy_r2_19()
{
$this->yypopstate();
@@ -486,7 +470,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
function yy_r2_21()
function yy_r2_8()
{
$this->yypopstate();
@@ -494,7 +478,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
function yy_r2_22()
function yy_r2_9()
{
$this->yypopstate();
@@ -502,7 +486,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
function yy_r2_24()
function yy_r2_11()
{
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
@@ -510,7 +494,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line;
}
function yy_r2_25()
function yy_r2_12()
{
$this->token = Smarty_Internal_Templateparser::TP_LDEL;
@@ -521,7 +505,7 @@ class Smarty_Internal_Templatelexer
public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\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|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(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(\\+\\+|--)|\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(::)|\G(\\s*:\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G(" . $this->ldel . "\\s*)|\G([\S\s])/iS";
$this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\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|neg|gt|ge|gte|lt|le|lte|mod|and|or|xor|(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(" . $this->ldel . "\\s*)|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -658,90 +642,90 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_NOT;
}
function yy_r3_27()
function yy_r3_29()
{
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
}
function yy_r3_31()
function yy_r3_33()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENP;
}
function yy_r3_32()
function yy_r3_34()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
}
function yy_r3_33()
function yy_r3_35()
{
$this->token = Smarty_Internal_Templateparser::TP_OPENB;
}
function yy_r3_34()
function yy_r3_36()
{
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
}
function yy_r3_35()
function yy_r3_37()
{
$this->token = Smarty_Internal_Templateparser::TP_PTR;
}
function yy_r3_36()
function yy_r3_38()
{
$this->token = Smarty_Internal_Templateparser::TP_APTR;
}
function yy_r3_37()
function yy_r3_39()
{
$this->token = Smarty_Internal_Templateparser::TP_EQUAL;
}
function yy_r3_38()
function yy_r3_40()
{
$this->token = Smarty_Internal_Templateparser::TP_INCDEC;
}
function yy_r3_39()
function yy_r3_42()
{
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
}
function yy_r3_41()
function yy_r3_44()
{
$this->token = Smarty_Internal_Templateparser::TP_MATH;
}
function yy_r3_43()
function yy_r3_46()
{
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
function yy_r3_44()
function yy_r3_47()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
function yy_r3_45()
function yy_r3_48()
{
// 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) {
preg_match("/\s+/", $this->value, $match);
preg_match("~\s+~", $this->value, $match);
$this->value = $match[0];
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} else {
@@ -749,86 +733,86 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r3_46()
function yy_r3_49()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}
function yy_r3_49()
function yy_r3_52()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}
function yy_r3_50()
function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}
function yy_r3_51()
function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}
function yy_r3_52()
function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}
function yy_r3_53()
function yy_r3_56()
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}
function yy_r3_54()
function yy_r3_57()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}
function yy_r3_55()
function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}
function yy_r3_56()
function yy_r3_59()
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}
function yy_r3_57()
function yy_r3_60()
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}
function yy_r3_58()
function yy_r3_61()
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}
function yy_r3_59()
function yy_r3_62()
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}
function yy_r3_60()
function yy_r3_63()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
}
function yy_r3_61()
function yy_r3_64()
{
if ($this->smarty->auto_literal && isset($this->value[$this->ldel_length]) ? strpos(" \n\t\r", $this->value[$this->ldel_length]) !== false : false) {
@@ -839,7 +823,7 @@ class Smarty_Internal_Templatelexer
}
}
function yy_r3_62()
function yy_r3_65()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
@@ -848,7 +832,7 @@ class Smarty_Internal_Templatelexer
public function yylex4()
{
if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS";
$this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -915,7 +899,7 @@ class Smarty_Internal_Templatelexer
{
$to = strlen($this->data);
preg_match("/{$this->ldel}\/?literal{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("~{$this->ldel}[/]?literal{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
} else {
@@ -928,7 +912,7 @@ class Smarty_Internal_Templatelexer
public function yylex5()
{
if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/iS";
$this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/])|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G([\"])|\G([`][$])|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -1063,7 +1047,7 @@ class Smarty_Internal_Templatelexer
public function yylex6()
{
if (!isset($this->yy_global_pattern6)) {
$this->yy_global_pattern6 = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/iS";
$this->yy_global_pattern6 = "/\G(" . $this->ldel . "\\s*strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]strip\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -1142,7 +1126,7 @@ class Smarty_Internal_Templatelexer
{
$to = strlen($this->data);
preg_match("/" . $this->ldel . "\s*((\/)?strip\s*" . $this->rdel . "|block\s+)/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("~" . $this->ldel . "\s*(([/])?strip\s*" . $this->rdel . "|block\s+)~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -1153,7 +1137,7 @@ class Smarty_Internal_Templatelexer
public function yylex7()
{
if (!isset($this->yy_global_pattern7)) {
$this->yy_global_pattern7 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*\/block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/iS";
$this->yy_global_pattern7 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*block)|\G(" . $this->ldel . "\\s*[\/]block)|\G(" . $this->ldel . "\\s*[$]smarty\\.block\\.(child|parent))|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -1245,7 +1229,7 @@ class Smarty_Internal_Templatelexer
{
$to = strlen($this->data);
preg_match("/" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|(\/)?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("~" . $this->ldel . "\s*(literal\s*" . $this->rdel . "|([/])?block(\s|" . $this->rdel . ")|[\$]smarty\.block\.(child|parent))~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
}
@@ -1256,7 +1240,7 @@ class Smarty_Internal_Templatelexer
public function yylex8()
{
if (!isset($this->yy_global_pattern8)) {
$this->yy_global_pattern8 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/iS";
$this->yy_global_pattern8 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*[\/]literal\\s*" . $this->rdel . ")|\G([\S\s])/isS";
}
if ($this->counter >= strlen($this->data)) {
return false; // end of input
@@ -1326,7 +1310,7 @@ class Smarty_Internal_Templatelexer
{
$to = strlen($this->data);
preg_match("/{$this->ldel}\/?literal\s*{$this->rdel}/", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
preg_match("~{$this->ldel}[/]?literal\s*{$this->rdel}~i", $this->data, $match, PREG_OFFSET_CAPTURE, $this->counter);
if (isset($match[0][1])) {
$to = $match[0][1];
} else {

File diff suppressed because one or more lines are too long