Skip to content

Commit

Permalink
09.10.2018
Browse files Browse the repository at this point in the history
 - bugfix fix of 26.8.2017 #327
   modifier is applied to sum expression #491
 - bugfix indexed arrays could not be defined "array(...)""
  • Loading branch information
uwetews committed Oct 9, 2018
1 parent 9301ba4 commit 7f531f6
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 31 deletions.
7 changes: 6 additions & 1 deletion change_log.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
===== 3.1.34-dev-1 =====
===== 3.1.34-dev-2 =====
09.10.2018
- bugfix fix of 26.8.2017 https://github.com/smarty-php/smarty/issues/327
modifier is applied to sum expression https://github.com/smarty-php/smarty/issues/491
- bugfix indexed arrays could not be defined "array(...)""

18.09.2018
- bugfix large plain text template sections without a Smarty tag > 700kB could
could fail in version 3.1.32 and 3.1.33 because PHP preg_match() restrictions
Expand Down
4 changes: 4 additions & 0 deletions lexer/smarty_internal_templatelexer.plex
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,7 @@ class Smarty_Internal_Templatelexer
if = ~(if|elseif|else if|while)\s+~
for = ~for\s+~
makenocache = ~make_nocache\s+~
array = ~array~
foreach = ~foreach(?![^\s])~
setfilter = ~setfilter\s+~
instanceof = ~\s+instanceof\s+~
Expand Down Expand Up @@ -550,6 +551,9 @@ class Smarty_Internal_Templatelexer
at {
$this->token = Smarty_Internal_Templateparser::TP_AT;
}
array openP {
$this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN;
}
hatch {
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}
Expand Down
25 changes: 12 additions & 13 deletions lexer/smarty_internal_templateparser.y
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ class Smarty_Internal_Templateparser

%right VERT.
%left COLON.
%left UNIMATH.


//
// complete template
Expand Down Expand Up @@ -632,16 +632,6 @@ expr(res) ::= expr(e) MATH(m) value(v). {
expr(res) ::= expr(e) UNIMATH(m) value(v). {
res = e . trim(m) . v;
}

// array
expr(res) ::= array(a). {
res = a;
}

// modifier
expr(res) ::= expr(e) modifierlist(l). {
res = $this->compiler->compileTag('private_modifier',array(),array('value'=>e,'modifierlist'=>l));
}

// if expression
// special conditions
Expand Down Expand Up @@ -787,7 +777,10 @@ value(res) ::= NAMESPACE(c). {
res = c;
}


// array
value(res) ::= arraydef(a). {
res = a;
}
// static class access
value(res) ::= ns1(c)DOUBLECOLON static_class_access(s). {
if (!in_array(strtolower(c), array('self', 'parent')) && (!$this->security || $this->security->isTrustedStaticClassAccess(c, s, $this->compiler))) {
Expand Down Expand Up @@ -1109,6 +1102,9 @@ modparameters(res) ::= . {
modparameter(res) ::= COLON value(mp). {
res = array(mp);
}
modparameter(res) ::= COLON UNIMATH(m) value(mp). {
res = array(trim(m).mp);
}

modparameter(res) ::= COLON array(mp). {
res = array(mp);
Expand Down Expand Up @@ -1191,7 +1187,10 @@ scond(res) ::= SINGLECOND(o). {
//
// ARRAY element assignment
//
array(res) ::= OPENB arrayelements(a) CLOSEB. {
arraydef(res) ::= OPENB arrayelements(a) CLOSEB. {
res = 'array('.a.')';
}
arraydef(res) ::= ARRAYOPEN arrayelements(a) CLOSEP. {
res = 'array('.a.')';
}

Expand Down
2 changes: 1 addition & 1 deletion libs/Smarty.class.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ class Smarty extends Smarty_Internal_TemplateBase
/**
* smarty version
*/
const SMARTY_VERSION = '3.1.34-dev-1';
const SMARTY_VERSION = '3.1.34-dev-2';
/**
* define variable scopes
*/
Expand Down
37 changes: 21 additions & 16 deletions libs/sysplugins/smarty_internal_templatelexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -592,7 +592,7 @@ public function yylex3()
{
if (!isset($this->yy_global_pattern3)) {
$this->yy_global_pattern3 =
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
$this->replace("/\G(\\s*SMARTYrdel)|\G((SMARTYldel)SMARTYal)|\G([\"])|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*')|\G([$][0-9]*[a-zA-Z_]\\w*)|\G([$])|\G(\\s+is\\s+in\\s+)|\G(\\s+as\\s+)|\G(\\s+to\\s+)|\G(\\s+step\\s+)|\G(\\s+instanceof\\s+)|\G(\\s*([!=][=]{1,2}|[<][=>]?|[>][=]?|[&|]{2})\\s*)|\G(\\s+(eq|ne|neq|gt|ge|gte|lt|le|lte|mod|and|or|xor)\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even|div)\\s+by\\s+)|\G(\\s+is\\s+(not\\s+)?(odd|even))|\G([!]\\s*|not\\s+)|\G([(](int(eger)?|bool(ean)?|float|double|real|string|binary|array|object)[)]\\s*)|\G(\\s*[(]\\s*)|\G(\\s*[)])|\G(\\[\\s*)|\G(\\s*\\])|\G(\\s*[-][>]\\s*)|\G(\\s*[=][>]\\s*)|\G(\\s*[=]\\s*)|\G(([+]|[-]){2})|\G(\\s*([+]|[-])\\s*)|\G(\\s*([*]{1,2}|[%\/^&]|[<>]{2})\\s*)|\G([@])|\G(array\\s*[(]\\s*)|\G([#])|\G(\\s+[0-9]*[a-zA-Z_][a-zA-Z0-9_\-:]*\\s*[=]\\s*)|\G(([0-9]*[a-zA-Z_]\\w*)?(\\\\[0-9]*[a-zA-Z_]\\w*)+)|\G([0-9]*[a-zA-Z_]\\w*)|\G(\\d+)|\G([`])|\G([|][@]?)|\G([.])|\G(\\s*[,]\\s*)|\G(\\s*[;]\\s*)|\G([:]{2})|\G(\\s*[:]\\s*)|\G(\\s*[?]\\s*)|\G(0[xX][0-9a-fA-F]+)|\G(\\s+)|\G([\S\s])/isS");
}
if (!isset($this->dataLength)) {
$this->dataLength = strlen($this->data);
Expand Down Expand Up @@ -788,10 +788,15 @@ public function yy_r3_41()

public function yy_r3_42()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
$this->token = Smarty_Internal_Templateparser::TP_ARRAYOPEN;
}

public function yy_r3_43()
{
$this->token = Smarty_Internal_Templateparser::TP_HATCH;
}

public function yy_r3_44()
{
// resolve conflicts with shorttag and right_delimiter starting with '='
if (substr($this->data, $this->counter + strlen($this->value) - 1, $this->compiler->getRdelLength()) ===
Expand All @@ -804,73 +809,73 @@ public function yy_r3_43()
}
}

public function yy_r3_44()
public function yy_r3_45()
{
$this->token = Smarty_Internal_Templateparser::TP_NAMESPACE;
}

public function yy_r3_47()
public function yy_r3_48()
{
$this->token = Smarty_Internal_Templateparser::TP_ID;
}

public function yy_r3_48()
public function yy_r3_49()
{
$this->token = Smarty_Internal_Templateparser::TP_INTEGER;
}

public function yy_r3_49()
public function yy_r3_50()
{
$this->token = Smarty_Internal_Templateparser::TP_BACKTICK;
$this->yypopstate();
}

public function yy_r3_50()
public function yy_r3_51()
{
$this->token = Smarty_Internal_Templateparser::TP_VERT;
}

public function yy_r3_51()
public function yy_r3_52()
{
$this->token = Smarty_Internal_Templateparser::TP_DOT;
}

public function yy_r3_52()
public function yy_r3_53()
{
$this->token = Smarty_Internal_Templateparser::TP_COMMA;
}

public function yy_r3_53()
public function yy_r3_54()
{
$this->token = Smarty_Internal_Templateparser::TP_SEMICOLON;
}

public function yy_r3_54()
public function yy_r3_55()
{
$this->token = Smarty_Internal_Templateparser::TP_DOUBLECOLON;
}

public function yy_r3_55()
public function yy_r3_56()
{
$this->token = Smarty_Internal_Templateparser::TP_COLON;
}

public function yy_r3_56()
public function yy_r3_57()
{
$this->token = Smarty_Internal_Templateparser::TP_QMARK;
}

public function yy_r3_57()
public function yy_r3_58()
{
$this->token = Smarty_Internal_Templateparser::TP_HEX;
}

public function yy_r3_58()
public function yy_r3_59()
{
$this->token = Smarty_Internal_Templateparser::TP_SPACE;
} // end function

public function yy_r3_59()
public function yy_r3_60()
{
$this->token = Smarty_Internal_Templateparser::TP_TEXT;
}
Expand Down

0 comments on commit 7f531f6

Please sign in to comment.