From 3d7dece0886a64ef4a2b78e16b7b3be5a1edc37d Mon Sep 17 00:00:00 2001 From: Uwe Tews Date: Sat, 21 Oct 2017 13:14:14 +0200 Subject: [PATCH] - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23 https://github.com/smarty-php/smarty/issues/394 --- change_log.txt | 6 +- lexer/smarty_internal_templatelexer.plex | 120 +--- lexer/smarty_internal_templateparser.y | 62 +- libs/Smarty.class.php | 614 ++++++++---------- .../smarty_internal_templatecompilerbase.php | 121 ++++ .../smarty_internal_templatelexer.php | 238 +++---- .../smarty_internal_templateparser.php | 359 +++++----- 7 files changed, 724 insertions(+), 796 deletions(-) diff --git a/change_log.txt b/change_log.txt index 1745cce73..982085f6b 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,6 +1,10 @@ ===== 3.1.32 - dev === +21.10.2017 + - bugfix custom delimiters could fail since modification of version 3.1.32-dev-23 + https://github.com/smarty-php/smarty/issues/394 + 18.10.2017 - -bugfix fix implementation of unclosed block tag in double quoted string of 12.10.2017 + - bugfix fix implementation of unclosed block tag in double quoted string of 12.10.2017 https://github.com/smarty-php/smarty/issues/396 https://github.com/smarty-php/smarty/issues/397 https://github.com/smarty-php/smarty/issues/391 https://github.com/smarty-php/smarty/issues/392 diff --git a/lexer/smarty_internal_templatelexer.plex b/lexer/smarty_internal_templatelexer.plex index ea53f9e84..a92653d0d 100644 --- a/lexer/smarty_internal_templatelexer.plex +++ b/lexer/smarty_internal_templatelexer.plex @@ -74,42 +74,7 @@ class Smarty_Internal_Templatelexer */ public $phpType = ''; - /** - * escaped left delimiter - * - * @var string - */ - public $ldel = ''; - - /** - * escaped left delimiter with space - * - * @var string - */ - public $ldel_q = ''; - - /** - * escaped left delimiter length - * - * @var int - */ - public $ldel_length = 0; - - /** - * escaped right delimiter - * - * @var string - */ - public $rdel = ''; - - /** - * escaped right delimiter length - * - * @var int - */ - public $rdel_length = 0; - - /** + /** * state number * * @var int @@ -202,13 +167,6 @@ class Smarty_Internal_Templatelexer 'SCOND' => '"is even" ... if condition', ); - /** - * preg string of user defined litereals - * - * @var string - */ - public $literals = ''; - /** * literal tag nesting level * @@ -266,29 +224,11 @@ class Smarty_Internal_Templatelexer $this->counter += strlen($match[0]); } $this->line = 1; - $this->smarty = $compiler->smarty; + $this->smarty = $compiler->template->smarty; $this->compiler = $compiler; - $this->ldel = preg_quote($this->smarty->left_delimiter, '/') . ($this->smarty->auto_literal ? '' : '\\s*'); - $this->ldel_length = strlen($this->smarty->left_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; - $literals = $this->smarty->getLiterals(); - if (!empty($literals)) { - foreach ($literals as $key => $literal) { - $literals[$key] = preg_quote($literal, '/'); - } - } - - if ($this->smarty->auto_literal) { - $literals[] = $this->ldel . '{1,}\\s+'; - } - if (!empty($literals)) { - $this->literals = implode('|', $literals); - } else { - $this->literals = preg_quote('^$', '/'); - } + $this->compiler->initDelimiterPreg(); + $this->smarty_token_names['LDEL'] = $this->smarty->getLeftDelimiter(); + $this->smarty_token_names['RDEL'] = $this->smarty->getRightDelimiter(); } /** @@ -304,15 +244,13 @@ class Smarty_Internal_Templatelexer /** * replace placeholders with runtime preg code * - * @param string $input + * @param string $preg * * @return string */ - public function replace($input) + public function replace($preg) { - return str_replace(array('SMARTYldel', 'SMARTYliteral', 'SMARTYrdel'), - array($this->ldel, $this->literals, $this->rdel), - $input); + return $this->compiler->replaceDelimiter($preg); } /** @@ -322,8 +260,8 @@ class Smarty_Internal_Templatelexer */ 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; + return $this->smarty->getAutoLiteral() && isset($this->value[ $this->compiler->getLdelLength() ]) ? + strpos(" \n\t\r", $this->value[ $this->compiler->getLdelLength() ]) !== false : false; } /*!lex2php @@ -332,22 +270,22 @@ class Smarty_Internal_Templatelexer %token $this->token %value $this->value %line $this->line - userliteral = ~SMARTYliteral~ + userliteral = ~(SMARTYldel)SMARTYautoliteral\s+SMARTYliteral~ char = ~[\S\s]~ - textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=(SMARTYliteral|SMARTYldel|\$|`\$|"))~ + textdoublequoted = ~([^"\\]*?)((?:\\.[^"\\]*?)*?)(?=((SMARTYldel)SMARTYal|\$|`\$|"SMARTYliteral))~ namespace = ~([0-9]*[a-zA-Z_]\w*)?(\\[0-9]*[a-zA-Z_]\w*)+~ emptyjava = ~[{][}]~ - phptag = ~(SMARTYldelphp([ ].*?)?SMARTYrdel)|(SMARTYldel[/]phpSMARTYrdel)~ - phpstart = ~([<][?]((php\s+|=)|\s+))|([<][%])|([<][?]xml\s+)|([<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>])|([?][>])|([%][>])~ + phptag = ~(SMARTYldel)SMARTYalphp([ ].*?)?SMARTYrdel|(SMARTYldel)SMARTYal[/]phpSMARTYrdel~ + phpstart = ~[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]~ slash = ~[/]~ - ldel = ~SMARTYldel~ + ldel = ~(SMARTYldel)SMARTYal~ rdel = ~\s*SMARTYrdel~ nocacherdel = ~(\s+nocache)?\s*SMARTYrdel~ notblockid = ~(?:(?!block)[0-9]*[a-zA-Z_]\w*)~ integer = ~\d+~ hex = ~0[xX][0-9a-fA-F]+~ math = ~\s*([*]{1,2}|[%/^&]|[<>]{2})\s*~ - comment = ~SMARTYldel[*]~ + comment = ~(SMARTYldel)SMARTYal[*]~ incdec = ~([+]|[-]){2}~ unimath = ~\s*([+]|[-])\s*~ openP = ~\s*[(]\s*~ @@ -370,14 +308,14 @@ class Smarty_Internal_Templatelexer backtick = ~[`]~ vert = ~[|]~ qmark = ~\s*[?]\s*~ - constant = ~([_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*)(?![0-9A-Z_]*[a-z])~ + constant = ~[_]+[A-Z0-9][0-9A-Z_]*|[A-Z][0-9A-Z_]*(?![0-9A-Z_]*[a-z])~ attr = ~\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\s*[=]\s*~ id = ~[0-9]*[a-zA-Z_]\w*~ literal = ~literal~ strip = ~strip~ - lop = ~\s*(([!=][=]{1,2})|([<][=>]?)|([>][=]?)|[&|]{2})\s*~ + lop = ~\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\s*~ slop = ~\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\s+~ - tlop = ~\s+(is\s+(not\s+)?(odd|even|div)\s+by)\s+~ + tlop = ~\s+is\s+(not\s+)?(odd|even|div)\s+by\s+~ scond = ~\s+is\s+(not\s+)?(odd|even)~ isin = ~\s+is\s+in\s+~ as = ~\s+as\s+~ @@ -390,12 +328,11 @@ class Smarty_Internal_Templatelexer foreach = ~foreach(?![^\s])~ setfilter = ~setfilter\s+~ instanceof = ~\s+instanceof\s+~ - not = ~([!]\s*)|(not\s+)~ + not = ~[!]\s*|not\s+~ typecast = ~[(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\s*~ double_quote = ~["]~ - text = ~((.*?)(?=(SMARTYliteral|[{]|([<][?]((php\s+|=)|\s+))|([<][%])|([<][?]xml\s+)|([<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>])|([?][>])|([%][>]))))|(.*)~ - literaltext = ~(.*?)(?=SMARTYldel[/]?literalSMARTYrdel)~ - anytext = ~.*~ + text = ~(.*?)(?=((SMARTYldel)SMARTYal|[<][?]((php\s+|=)|\s+)|[<][%]|[<][?]xml\s+|[<]script\s+language\s*=\s*["']?\s*php\s*["']?\s*[>]|[?][>]|[%][>]SMARTYliteral))|[\s\S]+~ + literaltext = ~(.*?)(?=(SMARTYldel)SMARTYal[/]?literalSMARTYrdel)~ */ /*!lex2php %statename TEXT @@ -403,11 +340,11 @@ class Smarty_Internal_Templatelexer $this->token = Smarty_Internal_Templateparser::TP_TEXT; } comment { - preg_match("/[*]{$this->rdel}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + preg_match("/[*]{$this->compiler->getRdelPreg()}/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); if (isset($match[0][1])) { $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->compiler->trigger_template_error ("missing or misspelled comment closing tag '*{$this->smarty->getRightDelimiter()}'"); } $this->value = substr($this->data,$this->counter,$to-$this->counter); return false; @@ -475,12 +412,12 @@ class Smarty_Internal_Templatelexer $this->taglineno = $this->line; } ldel dollar id nocacherdel { - if ($this->_yy_stack[count($this->_yy_stack)-1] == self::TEXT) { + if ($this->_yy_stack[count($this->_yy_stack)-1] === self::TEXT) { $this->yypopstate(); $this->token = Smarty_Internal_Templateparser::TP_SIMPELOUTPUT; $this->taglineno = $this->line; } else { - $this->value = $this->smarty->left_delimiter; + $this->value = $this->smarty->getLeftDelimiter(); $this->token = Smarty_Internal_Templateparser::TP_LDEL; $this->yybegin(self::TAGBODY); $this->taglineno = $this->line; @@ -592,7 +529,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) { + if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) === $this->smarty->getRightDelimiter()) { preg_match("/\s+/",$this->value,$match); $this->value = $match[0]; $this->token = Smarty_Internal_Templateparser::TP_SPACE; @@ -663,9 +600,6 @@ class Smarty_Internal_Templatelexer literaltext { $this->token = Smarty_Internal_Templateparser::TP_LITERAL; } - anytext { - $this->token = Smarty_Internal_Templateparser::TP_LITERAL; - } */ /*!lex2php %statename DOUBLEQUOTEDSTRING diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y index 2ed1fa831..0a11a0cd2 100644 --- a/lexer/smarty_internal_templateparser.y +++ b/lexer/smarty_internal_templateparser.y @@ -157,7 +157,7 @@ class Smarty_Internal_Templateparser $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template(); } - /** + /** * insert PHP code in current buffer * * @param string $code @@ -167,7 +167,21 @@ class Smarty_Internal_Templateparser $this->current_buffer->append_subtree($this, new Smarty_Internal_ParseTree_Tag($this, $code)); } - /** + /** + * error rundown + * + */ + public function errorRunDown() + { + while ($this->yystack !== Array()) { + $this->yy_pop_parser_stack(); + } + if (is_resource($this->yyTraceFILE)) { + fclose($this->yyTraceFILE); + } + } + + /** * merge PHP code with prefix code and return parse tree tag object * * @param string $code @@ -176,13 +190,13 @@ class Smarty_Internal_Templateparser */ public function mergePrefixCode($code) { - $tmp =''; + $tmp = ''; foreach ($this->compiler->prefix_code as $preCode) { $tmp .= $preCode; } - $this->compiler->prefix_code=array(); + $this->compiler->prefix_code = array(); $tmp .= $code; - return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp,true)); + return new Smarty_Internal_ParseTree_Tag($this, $this->compiler->processNocacheCode($tmp, true)); } } @@ -327,7 +341,7 @@ smartytag(res) ::= tag(t) RDEL. { // output tags start here // smartytag(res) ::= SIMPELOUTPUT(i). { - $var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $'); + $var = trim(substr(i, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); if (preg_match('/^(.*)(\s+nocache)$/', $var, $match)) { res = $this->compiler->compileTag('private_print_expression',array('nocache'),array('value'=>$this->compiler->compileVariable('\''.$match[1].'\''))); } else { @@ -381,8 +395,8 @@ tag(res) ::= LDEL varindexed(vi) EQUAL expr(e) attributes(a). { // simple tag like {name} smartytag(res)::= SIMPLETAG(t). { - $tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length)); - if ($tag == 'strip') { + $tag = trim(substr(t, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength())); + if ($tag === 'strip') { $this->strip = true; res = null;; } else { @@ -453,23 +467,23 @@ tag(res) ::= LDELMAKENOCACHE DOLLARID(i). { // {if}, {elseif} and {while} tag tag(res) ::= LDELIF(i) expr(ie). { - $tag = trim(substr(i,$this->lex->ldel_length)); - res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); + $tag = trim(substr(i,$this->compiler->getLdelLength())); + res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); } tag(res) ::= LDELIF(i) expr(ie) attributes(a). { - $tag = trim(substr(i,$this->lex->ldel_length)); - res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); + $tag = trim(substr(i,$this->compiler->getLdelLength())); + res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); } tag(res) ::= LDELIF(i) statement(ie). { - $tag = trim(substr(i,$this->lex->ldel_length)); - res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); + $tag = trim(substr(i,$this->compiler->getLdelLength())); + res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,array(),array('if condition'=>ie)); } tag(res) ::= LDELIF(i) statement(ie) attributes(a). { - $tag = trim(substr(i,$this->lex->ldel_length)); - res = $this->compiler->compileTag(($tag == 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); + $tag = trim(substr(i,$this->compiler->getLdelLength())); + res = $this->compiler->compileTag(($tag === 'else if')? 'elseif' : $tag,a,array('if condition'=>ie)); } // {for} tag @@ -517,8 +531,8 @@ tag(res) ::= LDELSETFILTER ID(m) modparameters(p) modifierlist(l). { // end of block tag {/....} smartytag(res)::= CLOSETAG(t). { - $tag = trim(substr(t, $this->lex->ldel_length, -$this->lex->rdel_length), ' /'); - if ($tag == 'strip') { + $tag = trim(substr(t, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' /'); + if ($tag === 'strip') { $this->strip = false; res = null; } else { @@ -785,7 +799,7 @@ value(res) ::= doublequoted_with_quotes(s). { value(res) ::= varindexed(vi) DOUBLECOLON static_class_access(r). { $prefixVar = $this->compiler->getNewPrefixVariable(); - if (vi['var'] == '\'smarty\'') { + if (vi['var'] === '\'smarty\'') { $this->compiler->appendPrefixCode("compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).';?>'); } else { $this->compiler->appendPrefixCode("compiler->compileVariable(vi['var']).vi['smarty_internal_index'].';?>'); @@ -845,7 +859,7 @@ variable(res) ::= DOLLARID(i). { res = $this->compiler->compileVariable('\''.substr(i,1).'\''); } variable(res) ::= varindexed(vi). { - if (vi['var'] == '\'smarty\'') { + if (vi['var'] === '\'smarty\'') { $smarty_var = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']); res = $smarty_var; } else { @@ -987,7 +1001,7 @@ varvarele(res) ::= ID(s). { res = '\''.s.'\''; } varvarele(res) ::= SIMPELOUTPUT(i). { - $var = trim(substr(i, $this->lex->ldel_length, -$this->lex->rdel_length), ' $'); + $var = trim(substr(i, $this->compiler->getLdelLength(), -$this->compiler->getRdelLength()), ' $'); res = $this->compiler->compileVariable('\''.$var.'\''); } @@ -1000,7 +1014,7 @@ varvarele(res) ::= LDEL expr(e) RDEL. { // objects // object(res) ::= varindexed(vi) objectchain(oc). { - if (vi['var'] == '\'smarty\'') { + if (vi['var'] === '\'smarty\'') { res = $this->compiler->compileTag('private_special_variable',array(),vi['smarty_internal_index']).oc; } else { res = $this->compiler->compileVariable(vi['var']).vi['smarty_internal_index'].oc; @@ -1019,7 +1033,7 @@ objectchain(res) ::= objectchain(oc) objectelement(oe). { // variable objectelement(res)::= PTR ID(i) arrayindex(a). { - if ($this->security && substr(i,0,1) == '_') { + if ($this->security && substr(i,0,1) === '_') { $this->compiler->trigger_template_error (self::Err1); } res = '->'.i.a; @@ -1064,7 +1078,7 @@ function(res) ::= ns1(f) OPENP params(p) CLOSEP. { // method // method(res) ::= ID(f) OPENP params(p) CLOSEP. { - if ($this->security && substr(f,0,1) == '_') { + if ($this->security && substr(f,0,1) === '_') { $this->compiler->trigger_template_error (self::Err1); } res = f . "(". implode(',',p) .")"; diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index c5216d267..e357bf272 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -29,7 +29,6 @@ * @package Smarty * @version 3.1.32-dev */ - /** * set SMARTY_DIR to absolute path to Smarty library files. * Sets SMARTY_DIR only if user application has not already defined it. @@ -37,7 +36,6 @@ if (!defined('SMARTY_DIR')) { define('SMARTY_DIR', dirname(__FILE__) . DIRECTORY_SEPARATOR); } - /** * set SMARTY_SYSPLUGINS_DIR to absolute path to Smarty internal plugins. * Sets SMARTY_SYSPLUGINS_DIR only if user application has not already defined it. @@ -64,14 +62,12 @@ */ define('SMARTY_RESOURCE_DATE_FORMAT', '%b %e, %Y'); } - /** * Load Smarty_Autoloader */ if (!class_exists('Smarty_Autoloader')) { include dirname(__FILE__) . '/bootstrap.php'; } - /** * Load always needed external class files */ @@ -95,337 +91,218 @@ * * @method int clearAllCache(int $exp_time = null, string $type = null) * @method int clearCache(string $template_name, string $cache_id = null, string $compile_id = null, int $exp_time = null, string $type = null) - * @method int compileAllTemplates(string $extension = '.tpl', bool $force_compile = false, int $time_limit = 0, int $max_errors = null) - * @method int compileAllConfig(string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, int $max_errors = null) + * @method int compileAllTemplates(string $extension = '.tpl', bool $force_compile = false, int $time_limit = 0, $max_errors = null) + * @method int compileAllConfig(string $extension = '.conf', bool $force_compile = false, int $time_limit = 0, $max_errors = null) * @method int clearCompiledTemplate($resource_name = null, $compile_id = null, $exp_time = null) */ class Smarty extends Smarty_Internal_TemplateBase { - /**#@+ - * constant definitions - */ - /** * smarty version */ - const SMARTY_VERSION = '3.1.32-dev-26'; - + const SMARTY_VERSION = '3.1.32-dev-27'; /** * define variable scopes */ - const SCOPE_LOCAL = 1; - - const SCOPE_PARENT = 2; - + const SCOPE_LOCAL = 1; + const SCOPE_PARENT = 2; const SCOPE_TPL_ROOT = 4; - - const SCOPE_ROOT = 8; - - const SCOPE_SMARTY = 16; - - const SCOPE_GLOBAL = 32; - + const SCOPE_ROOT = 8; + const SCOPE_SMARTY = 16; + const SCOPE_GLOBAL = 32; /** * define caching modes */ - const CACHING_OFF = 0; - + const CACHING_OFF = 0; const CACHING_LIFETIME_CURRENT = 1; - - const CACHING_LIFETIME_SAVED = 2; - + const CACHING_LIFETIME_SAVED = 2; /** * define constant for clearing cache files be saved expiration dates */ - const CLEAR_EXPIRED = - 1; - + const CLEAR_EXPIRED = -1; /** * define compile check modes */ - const COMPILECHECK_OFF = 0; - - const COMPILECHECK_ON = 1; - + const COMPILECHECK_OFF = 0; + const COMPILECHECK_ON = 1; const COMPILECHECK_CACHEMISS = 2; - /** * define debug modes */ - const DEBUG_OFF = 0; - - const DEBUG_ON = 1; - + const DEBUG_OFF = 0; + const DEBUG_ON = 1; const DEBUG_INDIVIDUAL = 2; - /** * modes for handling of "" tags in templates. */ const PHP_PASSTHRU = 0; //-> print tags as plain text - - const PHP_QUOTE = 1; //-> escape tags as entities - - const PHP_REMOVE = 2; //-> escape tags as entities - - const PHP_ALLOW = 3; //-> escape tags as entities - + const PHP_QUOTE = 1; //-> escape tags as entities + const PHP_REMOVE = 2; //-> escape tags as entities + const PHP_ALLOW = 3; //-> escape tags as entities /** * filter types */ - const FILTER_POST = 'post'; - - const FILTER_PRE = 'pre'; - - const FILTER_OUTPUT = 'output'; - + const FILTER_POST = 'post'; + const FILTER_PRE = 'pre'; + const FILTER_OUTPUT = 'output'; const FILTER_VARIABLE = 'variable'; - /** * plugin types */ - const PLUGIN_FUNCTION = 'function'; - - const PLUGIN_BLOCK = 'block'; - - const PLUGIN_COMPILER = 'compiler'; - - const PLUGIN_MODIFIER = 'modifier'; - + const PLUGIN_FUNCTION = 'function'; + const PLUGIN_BLOCK = 'block'; + const PLUGIN_COMPILER = 'compiler'; + const PLUGIN_MODIFIER = 'modifier'; const PLUGIN_MODIFIERCOMPILER = 'modifiercompiler'; - /** * Resource caching modes * (not used since 3.1.30) */ - const RESOURCE_CACHE_OFF = 0; - + const RESOURCE_CACHE_OFF = 0; const RESOURCE_CACHE_AUTOMATIC = 1; // cache template objects by rules - - const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects - - const RESOURCE_CACHE_ON = 4; // cache source and compiled resources - - /**#@-*/ - + const RESOURCE_CACHE_TEMPLATE = 2; // cache all template objects + const RESOURCE_CACHE_ON = 4; // cache source and compiled resources /** * assigned global tpl vars */ public static $global_tpl_vars = array(); - /** * error handler returned by set_error_handler() in Smarty::muteExpectedErrors() */ public static $_previous_error_handler = null; - /** * contains directories outside of SMARTY_DIR that are to be muted by muteExpectedErrors() */ public static $_muted_directories = array(); - /** * Flag denoting if Multibyte String functions are available */ public static $_MBSTRING = SMARTY_MBSTRING; - /** * The character set to adhere to (e.g. "UTF-8") */ public static $_CHARSET = SMARTY_RESOURCE_CHAR_SET; - /** * The date format to be used internally * (accepts date() and strftime()) */ public static $_DATE_FORMAT = SMARTY_RESOURCE_DATE_FORMAT; - /** * Flag denoting if PCRE should run in UTF-8 mode */ public static $_UTF8_MODIFIER = 'u'; - /** * Flag denoting if operating system is windows */ public static $_IS_WINDOWS = false; - - /**#@+ - * variables - */ - /** * auto literal on delimiters with whitespace * * @var boolean */ public $auto_literal = true; - /** * display error on not assigned variables * * @var boolean */ public $error_unassigned = false; - /** * look up relative file path in include_path * * @var boolean */ public $use_include_path = false; - - /** - * template directory - * - * @var array - */ - protected $template_dir = array('./templates/'); - - /** - * flags for normalized template directory entries - * - * @var array - */ - protected $_processedTemplateDir = array(); - /** * flag if template_dir is normalized * * @var bool */ public $_templateDirNormalized = false; - /** * joined template directory string used in cache keys * * @var string */ public $_joined_template_dir = null; - - /** - * config directory - * - * @var array - */ - protected $config_dir = array('./configs/'); - - /** - * flags for normalized template directory entries - * - * @var array - */ - protected $_processedConfigDir = array(); - /** * flag if config_dir is normalized * * @var bool */ public $_configDirNormalized = false; - /** * joined config directory string used in cache keys * * @var string */ public $_joined_config_dir = null; - /** * default template handler * * @var callable */ public $default_template_handler_func = null; - /** * default config handler * * @var callable */ public $default_config_handler_func = null; - /** * default plugin handler * * @var callable */ public $default_plugin_handler_func = null; - - /** - * compile directory - * - * @var string - */ - protected $compile_dir = './templates_c/'; - /** * flag if template_dir is normalized * * @var bool */ public $_compileDirNormalized = false; - - /** - * plugins directory - * - * @var array - */ - protected $plugins_dir = array(); - /** * flag if plugins_dir is normalized * * @var bool */ public $_pluginsDirNormalized = false; - - /** - * cache directory - * - * @var string - */ - protected $cache_dir = './cache/'; - /** * flag if template_dir is normalized * * @var bool */ public $_cacheDirNormalized = false; - /** * force template compiling? * * @var boolean */ public $force_compile = false; - /** * check template for modifications? * * @var boolean */ public $compile_check = true; - /** * use sub dirs for compiled/cached files? * * @var boolean */ public $use_sub_dirs = false; - /** * allow ambiguous resources (that are made unique by the resource handler) * * @var boolean */ public $allow_ambiguous_resources = false; - /** * merge compiled includes * * @var boolean */ public $merge_compiled_includes = false; - /* * flag for behaviour when extends: resource and {extends} tag are used simultaneous * if false disable execution of {extends} in templates called by extends resource. @@ -434,38 +311,30 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $extends_recursion = true; - /** * force cache file creation * * @var boolean */ public $force_cache = false; - /** * template left-delimiter * * @var string */ public $left_delimiter = "{"; - /** * template right-delimiter * * @var string */ public $right_delimiter = "}"; - /** * array of strings which shall be treated as literal by compiler * * @var array string */ public $literals = array(); - - /**#@+ - * security - */ /** * class name * This should be instance of Smarty_Security. @@ -474,29 +343,24 @@ class Smarty extends Smarty_Internal_TemplateBase * @see Smarty_Security */ public $security_class = 'Smarty_Security'; - /** * implementation of security class * * @var Smarty_Security */ public $security_policy = null; - /** * controls handling of PHP-blocks * * @var integer */ public $php_handling = self::PHP_PASSTHRU; - /** * controls if the php template file resource is allowed * * @var bool */ public $allow_php_templates = false; - - /**#@-*/ /** * debug mode * Setting this to true enables the debug-console. @@ -504,7 +368,6 @@ class Smarty extends Smarty_Internal_TemplateBase * @var boolean */ public $debugging = false; - /** * This determines if debugging is enable-able from the browser. *