diff --git a/lexer/smarty_internal_templateparser.y b/lexer/smarty_internal_templateparser.y index b8c00e5d9..db3317fe5 100644 --- a/lexer/smarty_internal_templateparser.y +++ b/lexer/smarty_internal_templateparser.y @@ -154,6 +154,7 @@ class Smarty_Internal_Templateparser $this->template = $this->compiler->template; $this->smarty = $this->template->smarty; $this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false; + $this->allow_inline_constants = $this->smarty->allow_inline_constants; $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template(); } @@ -310,7 +311,7 @@ smartytag(A)::= SIMPLETAG(B). { $this->strip = true; A = null;; } else { - if (defined($tag)) { + if ($this->allow_inline_constants AND defined($tag)) { if ($this->security) { $this->security->isTrustedConstant($tag, $this->compiler); } @@ -381,7 +382,7 @@ output(A) ::= expr(B). { // tag with optional Smarty2 style attributes tag(res) ::= LDEL ID(i) attributes(a). { - if (defined(i)) { + if ($this->allow_inline_constants AND defined(i)) { if ($this->security) { $this->security->isTrustedConstant(i, $this->compiler); } @@ -391,7 +392,7 @@ tag(res) ::= LDEL ID(i) attributes(a). { } } tag(res) ::= LDEL ID(i). { - if (defined(i)) { + if ($this->allow_inline_constants AND defined(i)) { if ($this->security) { $this->security->isTrustedConstant(i, $this->compiler); } @@ -404,7 +405,7 @@ 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 ($this->allow_inline_constants AND defined(i)) { if ($this->security) { $this->security->isTrustedConstant(i, $this->compiler); } diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index 44589328e..4e3b12226 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.36'; + const SMARTY_VERSION = '3.1.37-dev-1'; /** * define variable scopes */ @@ -310,6 +310,14 @@ class Smarty extends Smarty_Internal_TemplateBase */ public $allow_ambiguous_resources = false; + /** + * allow inline constants (use defined constants without the $smarty.const. prefix) + * default to true for backwards compatibility + * + * @var boolean + */ + public $allow_inline_constants = true; + /** * merge compiled includes * diff --git a/libs/sysplugins/smarty_internal_templateparser.php b/libs/sysplugins/smarty_internal_templateparser.php index aaeae63b7..2813c4d87 100644 --- a/libs/sysplugins/smarty_internal_templateparser.php +++ b/libs/sysplugins/smarty_internal_templateparser.php @@ -1771,6 +1771,7 @@ public function __construct(Smarty_Internal_Templatelexer $lex, Smarty_Internal_ $this->template = $this->compiler->template; $this->smarty = $this->template->smarty; $this->security = isset($this->smarty->security_policy) ? $this->smarty->security_policy : false; + $this->allow_inline_constants = $this->smarty->allow_inline_constants; $this->current_buffer = $this->root_buffer = new Smarty_Internal_ParseTree_Template(); } /* The parser's stack */ public static function yy_destructor($yymajor, $yypminor) @@ -2259,7 +2260,7 @@ public function yy_r13() $this->strip = true; $this->_retvalue = null; } else { - if (defined($tag)) { + if ($this->allow_inline_constants AND defined($tag)) { if ($this->security) { $this->security->isTrustedConstant($tag, $this->compiler); } @@ -2348,7 +2349,7 @@ public function yy_r21() // line 393 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r25() { - if (defined($this->yystack[ $this->yyidx + -1 ]->minor)) { + if ($this->allow_inline_constants AND defined($this->yystack[ $this->yyidx + -1 ]->minor)) { if ($this->security) { $this->security->isTrustedConstant($this->yystack[ $this->yyidx + -1 ]->minor, $this->compiler); } @@ -2365,7 +2366,7 @@ public function yy_r25() // line 406 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r26() { - if (defined($this->yystack[ $this->yyidx + 0 ]->minor)) { + if ($this->allow_inline_constants AND defined($this->yystack[ $this->yyidx + 0 ]->minor)) { if ($this->security) { $this->security->isTrustedConstant($this->yystack[ $this->yyidx + 0 ]->minor, $this->compiler); } @@ -2380,7 +2381,7 @@ public function yy_r26() // line 418 "../smarty/lexer/smarty_internal_templateparser.y" public function yy_r27() { - if (defined($this->yystack[ $this->yyidx + -2 ]->minor)) { + if ($this->allow_inline_constants AND defined($this->yystack[ $this->yyidx + -2 ]->minor)) { if ($this->security) { $this->security->isTrustedConstant($this->yystack[ $this->yyidx + -2 ]->minor, $this->compiler); }