- 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)  ===== 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 21.05.2015
- bugfix broken PHP 5.2 compatibility when compiling <?php tags https://github.com/smarty-php/smarty/issues/40 - 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 - 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

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

View File

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

View File

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

View File

@@ -40,31 +40,30 @@ class Smarty_Internal_Compile_Private_Php extends Smarty_Internal_CompileBase
// check and get attributes // check and get attributes
$_attr = $this->getAttributes($compiler, $args); $_attr = $this->getAttributes($compiler, $args);
$compiler->has_code = false; $compiler->has_code = false;
$this->asp_tags = (ini_get('asp_tags') != '0'); if ($_attr['type'] == 'xml') {
if ($_attr['type'] == 'tag' && !($compiler->smarty instanceof SmartyBC)) { $compiler->tag_nocache = true;
$compiler->trigger_template_error('{php}[/php} tags not allowed. Use SmartyBC to enable them', $compiler->lex->taglineno); $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 ($_attr['type'] != 'tag') {
if (isset($compiler->smarty->security_policy)) { if ($compiler->php_handling == Smarty::PHP_REMOVE) {
$this->php_handling = $compiler->smarty->security_policy->php_handling; return '';
} else { } elseif ($compiler->php_handling == Smarty::PHP_QUOTE) {
$this->php_handling = $compiler->smarty->php_handling; $output = preg_replace_callback('#(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)|(\?>)|(%>)|(<\/script>)#i', array($this,
} 'quote'), $_attr['code']);
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)); $compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output));
return ''; return '';
} elseif ($this->php_handling == Smarty::PHP_QUOTE) { } elseif ($compiler->php_handling == Smarty::PHP_PASSTHRU || $_attr['type'] == 'unmatched') {
$output = preg_replace_callback(array('#^(<\?(?:php|=)?)|(<%)|(<script\s+language\s*=\s*["\']?\s*php\s*["\']?\s*>)#', $compiler->tag_nocache = true;
'#(\?>)|(%>)|(<\/script>)$#'), array($this, $save = $compiler->template->has_nocache_code;
'quote'), $_attr['code']); $compiler->template->has_nocache_code = $save;
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $output)); $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 ''; return '';
} elseif ($this->php_handling == Smarty::PHP_PASSTHRU || ($_attr['type'] == 'asp' && !$this->asp_tags) || $_attr['type'] == 'unmatched') { } elseif ($compiler->php_handling == Smarty::PHP_ALLOW) {
$compiler->parser->current_buffer->append_subtree(new Smarty_Internal_ParseTree_Text($compiler->parser, $_attr['code']));
return '';
} elseif ($this->php_handling == Smarty::PHP_ALLOW) {
if (!($compiler->smarty instanceof SmartyBC)) { if (!($compiler->smarty instanceof SmartyBC)) {
$compiler->trigger_template_error('$smarty->php_handling PHP_ALLOW not allowed. Use SmartyBC to enable it', $compiler->lex->taglineno); $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 { } else {
$compiler->has_code = true; $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, '#'); $ldel = preg_quote($compiler->smarty->left_delimiter, '#');
$rdel = preg_quote($compiler->smarty->right_delimiter, '#'); $rdel = preg_quote($compiler->smarty->right_delimiter, '#');
if (!preg_match("#{$ldel}\\s*/\\s*php\\s*{$rdel}$#", $_attr['code'], $match)) { preg_match("#^({$ldel}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);
}
if (!empty($match[2])) { if (!empty($match[2])) {
if ('nocache' == trim($match[2])) { if ('nocache' == trim($match[2])) {
$compiler->tag_nocache = true; $compiler->tag_nocache = true;
@@ -95,10 +92,96 @@ 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 * Call back function for $php_handling = PHP_QUOTE
* *
*/ */
private function quote($match) private function quote($match)
{ {
return htmlspecialchars($match[0], ENT_QUOTES); return htmlspecialchars($match[0], ENT_QUOTES);

View File

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

View File

@@ -62,13 +62,6 @@ class Smarty_Internal_Templatelexer
*/ */
public $taglineno; public $taglineno;
/**
* flag if parsing php script
*
* @var bool
*/
public $is_phpScript = false;
/** /**
* php code type * php code type
* *
@@ -123,7 +116,7 @@ class Smarty_Internal_Templatelexer
* *
* @var Smarty_Internal_TemplateCompilerBase * @var Smarty_Internal_TemplateCompilerBase
*/ */
private $compiler = null; public $compiler = null;
/** /**
* literal tag nesting level * literal tag nesting level
@@ -132,6 +125,12 @@ class Smarty_Internal_Templatelexer
*/ */
private $literal_cnt = 0; private $literal_cnt = 0;
/**
* PHP start tag string
*
* @var string
*/
/** /**
* trace file * trace file
* *
@@ -144,6 +143,7 @@ class Smarty_Internal_Templatelexer
* *
* @var string * @var string
*/ */
public $yyTracePrompt; public $yyTracePrompt;
/** /**
@@ -151,12 +151,13 @@ class Smarty_Internal_Templatelexer
* *
* @var array * @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 * storage for assembled token patterns
* *
* @var sring * @var string
*/ */
private $yy_global_pattern1 = null; private $yy_global_pattern1 = null;
@@ -180,7 +181,15 @@ class Smarty_Internal_Templatelexer
* @var array * @var array
*/ */
public $smarty_token_names = array( // Text for parser error messages public $smarty_token_names = array( // Text for parser error messages
'NOT' => '(!,not)', 'OPENP' => '(', 'CLOSEP' => ')', 'OPENB' => '[', '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 * constructor
@@ -192,15 +201,15 @@ class Smarty_Internal_Templatelexer
{ {
$this->data = $data; $this->data = $data;
$this->counter = 0; $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->counter += strlen($match[0]);
} }
$this->line = 1; $this->line = 1;
$this->smarty = $compiler->smarty; $this->smarty = $compiler->smarty;
$this->compiler = $compiler; $this->compiler = $compiler;
$this->ldel = preg_quote($this->smarty->left_delimiter, '/'); $this->ldel = preg_quote($this->smarty->left_delimiter, '~');
$this->ldel_length = strlen($this->smarty->left_delimiter); $this->ldel_length = strlen($this->smarty->left_delimiter);
$this->rdel = preg_quote($this->smarty->right_delimiter, '/'); $this->rdel = preg_quote($this->smarty->right_delimiter, '~');
$this->rdel_length = strlen($this->smarty->right_delimiter); $this->rdel_length = strlen($this->smarty->right_delimiter);
$this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter; $this->smarty_token_names['LDEL'] = $this->smarty->left_delimiter;
$this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter; $this->smarty_token_names['RDEL'] = $this->smarty->right_delimiter;
@@ -212,6 +221,14 @@ class Smarty_Internal_Templatelexer
$this->yyTracePrompt = '<br>'; $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_state = 1;
private $_yy_stack = array(); private $_yy_stack = array();
@@ -255,7 +272,7 @@ class Smarty_Internal_Templatelexer
public function yylex1() public function yylex1()
{ {
if (!isset($this->yy_global_pattern1)) { 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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -308,10 +325,25 @@ class Smarty_Internal_Templatelexer
function yy_r1_2() 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) { 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) { 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; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
} }
function yy_r1_7() function yy_r1_18()
{
$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()
{ {
$to = strlen($this->data); $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} }
@@ -393,7 +386,7 @@ class Smarty_Internal_Templatelexer
public function yylex2() public function yylex2()
{ {
if (!isset($this->yy_global_pattern2)) { if (!isset($this->yy_global_pattern2)) {
$this->yy_global_pattern2 = "/\G(" . $this->ldel . "\\s*(if|elseif|else if|while)\\s+)|\G(" . $this->ldel . "\\s*for\\s+)|\G(" . $this->ldel . "\\s*foreach(?![^\s]))|\G(" . $this->ldel . "\\s*setfilter\\s+)|\G(((" . $this->ldel . "\\s*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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -470,15 +463,6 @@ class Smarty_Internal_Templatelexer
} }
function yy_r2_6() 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(); $this->yypopstate();
@@ -486,7 +470,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_21() function yy_r2_8()
{ {
$this->yypopstate(); $this->yypopstate();
@@ -494,7 +478,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_22() function yy_r2_9()
{ {
$this->yypopstate(); $this->yypopstate();
@@ -502,7 +486,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_24() function yy_r2_11()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDELSLASH; $this->token = Smarty_Internal_Templateparser::TP_LDELSLASH;
@@ -510,7 +494,7 @@ class Smarty_Internal_Templatelexer
$this->taglineno = $this->line; $this->taglineno = $this->line;
} }
function yy_r2_25() function yy_r2_12()
{ {
$this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->token = Smarty_Internal_Templateparser::TP_LDEL;
@@ -521,7 +505,7 @@ class Smarty_Internal_Templatelexer
public function yylex3() public function yylex3()
{ {
if (!isset($this->yy_global_pattern3)) { if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 = "/\G(\\s*" . $this->rdel . ")|\G(\")|\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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -658,90 +642,90 @@ class Smarty_Internal_Templatelexer
$this->token = Smarty_Internal_Templateparser::TP_NOT; $this->token = Smarty_Internal_Templateparser::TP_NOT;
} }
function yy_r3_27() function yy_r3_29()
{ {
$this->token = Smarty_Internal_Templateparser::TP_TYPECAST; $this->token = Smarty_Internal_Templateparser::TP_TYPECAST;
} }
function yy_r3_31() function yy_r3_33()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENP; $this->token = Smarty_Internal_Templateparser::TP_OPENP;
} }
function yy_r3_32() function yy_r3_34()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEP; $this->token = Smarty_Internal_Templateparser::TP_CLOSEP;
} }
function yy_r3_33() function yy_r3_35()
{ {
$this->token = Smarty_Internal_Templateparser::TP_OPENB; $this->token = Smarty_Internal_Templateparser::TP_OPENB;
} }
function yy_r3_34() function yy_r3_36()
{ {
$this->token = Smarty_Internal_Templateparser::TP_CLOSEB; $this->token = Smarty_Internal_Templateparser::TP_CLOSEB;
} }
function yy_r3_35() function yy_r3_37()
{ {
$this->token = Smarty_Internal_Templateparser::TP_PTR; $this->token = Smarty_Internal_Templateparser::TP_PTR;
} }
function yy_r3_36() function yy_r3_38()
{ {
$this->token = Smarty_Internal_Templateparser::TP_APTR; $this->token = Smarty_Internal_Templateparser::TP_APTR;
} }
function yy_r3_37() function yy_r3_39()
{ {
$this->token = Smarty_Internal_Templateparser::TP_EQUAL; $this->token = Smarty_Internal_Templateparser::TP_EQUAL;
} }
function yy_r3_38() function yy_r3_40()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INCDEC; $this->token = Smarty_Internal_Templateparser::TP_INCDEC;
} }
function yy_r3_39() function yy_r3_42()
{ {
$this->token = Smarty_Internal_Templateparser::TP_UNIMATH; $this->token = Smarty_Internal_Templateparser::TP_UNIMATH;
} }
function yy_r3_41() function yy_r3_44()
{ {
$this->token = Smarty_Internal_Templateparser::TP_MATH; $this->token = Smarty_Internal_Templateparser::TP_MATH;
} }
function yy_r3_43() function yy_r3_46()
{ {
$this->token = Smarty_Internal_Templateparser::TP_AT; $this->token = Smarty_Internal_Templateparser::TP_AT;
} }
function yy_r3_44() function yy_r3_47()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HATCH; $this->token = Smarty_Internal_Templateparser::TP_HATCH;
} }
function yy_r3_45() function yy_r3_48()
{ {
// resolve conflicts with shorttag and right_delimiter starting with '=' // resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) { if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->rdel_length) == $this->smarty->right_delimiter) {
preg_match("/\s+/", $this->value, $match); preg_match("~\s+~", $this->value, $match);
$this->value = $match[0]; $this->value = $match[0];
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $this->token = Smarty_Internal_Templateparser::TP_SPACE;
} else { } else {
@@ -749,86 +733,86 @@ class Smarty_Internal_Templatelexer
} }
} }
function yy_r3_46() function yy_r3_49()
{ {
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE; $this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
} }
function yy_r3_49() function yy_r3_52()
{ {
$this->token = Smarty_Internal_Templateparser::TP_ID; $this->token = Smarty_Internal_Templateparser::TP_ID;
} }
function yy_r3_50() function yy_r3_53()
{ {
$this->token = Smarty_Internal_Templateparser::TP_INTEGER; $this->token = Smarty_Internal_Templateparser::TP_INTEGER;
} }
function yy_r3_51() function yy_r3_54()
{ {
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK; $this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate(); $this->yypopstate();
} }
function yy_r3_52() function yy_r3_55()
{ {
$this->token = Smarty_Internal_Templateparser::TP_VERT; $this->token = Smarty_Internal_Templateparser::TP_VERT;
} }
function yy_r3_53() function yy_r3_56()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOT; $this->token = Smarty_Internal_Templateparser::TP_DOT;
} }
function yy_r3_54() function yy_r3_57()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COMMA; $this->token = Smarty_Internal_Templateparser::TP_COMMA;
} }
function yy_r3_55() function yy_r3_58()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON; $this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
} }
function yy_r3_56() function yy_r3_59()
{ {
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON; $this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
} }
function yy_r3_57() function yy_r3_60()
{ {
$this->token = Smarty_Internal_Templateparser::TP_COLON; $this->token = Smarty_Internal_Templateparser::TP_COLON;
} }
function yy_r3_58() function yy_r3_61()
{ {
$this->token = Smarty_Internal_Templateparser::TP_QMARK; $this->token = Smarty_Internal_Templateparser::TP_QMARK;
} }
function yy_r3_59() function yy_r3_62()
{ {
$this->token = Smarty_Internal_Templateparser::TP_HEX; $this->token = Smarty_Internal_Templateparser::TP_HEX;
} }
function yy_r3_60() function yy_r3_63()
{ {
$this->token = Smarty_Internal_Templateparser::TP_SPACE; $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) { 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; $this->token = Smarty_Internal_Templateparser::TP_TEXT;
@@ -848,7 +832,7 @@ class Smarty_Internal_Templatelexer
public function yylex4() public function yylex4()
{ {
if (!isset($this->yy_global_pattern4)) { if (!isset($this->yy_global_pattern4)) {
$this->yy_global_pattern4 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G([\S\s])/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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -915,7 +899,7 @@ class Smarty_Internal_Templatelexer
{ {
$to = strlen($this->data); $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} else { } else {
@@ -928,7 +912,7 @@ class Smarty_Internal_Templatelexer
public function yylex5() public function yylex5()
{ {
if (!isset($this->yy_global_pattern5)) { if (!isset($this->yy_global_pattern5)) {
$this->yy_global_pattern5 = "/\G(" . $this->ldel . "\\s*literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/literal\\s*" . $this->rdel . ")|\G(" . $this->ldel . "\\s*\/)|\G(" . $this->ldel . "\\s*[0-9]*[a-zA-Z_]\\w*)|\G(" . $this->ldel . "\\s*)|\G(\")|\G(`\\$)|\G(\\$[0-9]*[a-zA-Z_]\\w*)|\G(\\$)|\G(([^\"\\\\]*?)((?:\\\\.[^\"\\\\]*?)*?)(?=(" . $this->ldel . "|\\$|`\\$|\")))|\G([\S\s])/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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -1063,7 +1047,7 @@ class Smarty_Internal_Templatelexer
public function yylex6() public function yylex6()
{ {
if (!isset($this->yy_global_pattern6)) { 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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -1142,7 +1126,7 @@ class Smarty_Internal_Templatelexer
{ {
$to = strlen($this->data); $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} }
@@ -1153,7 +1137,7 @@ class Smarty_Internal_Templatelexer
public function yylex7() public function yylex7()
{ {
if (!isset($this->yy_global_pattern7)) { 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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -1245,7 +1229,7 @@ class Smarty_Internal_Templatelexer
{ {
$to = strlen($this->data); $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} }
@@ -1256,7 +1240,7 @@ class Smarty_Internal_Templatelexer
public function yylex8() public function yylex8()
{ {
if (!isset($this->yy_global_pattern8)) { 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)) { if ($this->counter >= strlen($this->data)) {
return false; // end of input return false; // end of input
@@ -1326,7 +1310,7 @@ class Smarty_Internal_Templatelexer
{ {
$to = strlen($this->data); $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])) { if (isset($match[0][1])) {
$to = $match[0][1]; $to = $match[0][1];
} else { } else {

File diff suppressed because one or more lines are too long