diff --git a/change_log.txt b/change_log.txt index 46b3eecf..e5a31f96 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@  ===== 3.1.25-dev===== (xx.xx.2015) + 11.06.2015 + - bugfix the lexer could hang on very large quoted strings (forum topic 25570) + 08.06.2015 - bugfix using {$foo} as array index like $bar.{$foo} or in double quoted string like "some {$foo} thing" failed https://github.com/smarty-php/smarty/issues/49 diff --git a/libs/Smarty.class.php b/libs/Smarty.class.php index dcf3e2ca..57410a69 100644 --- a/libs/Smarty.class.php +++ b/libs/Smarty.class.php @@ -111,7 +111,7 @@ class Smarty extends Smarty_Internal_TemplateBase /** * smarty version */ - const SMARTY_VERSION = '3.1.25-dev/4'; + const SMARTY_VERSION = '3.1.25-dev/5'; /** * define variable scopes diff --git a/libs/sysplugins/smarty_internal_configfilelexer.php b/libs/sysplugins/smarty_internal_configfilelexer.php index e5d4770b..e62728c2 100644 --- a/libs/sysplugins/smarty_internal_configfilelexer.php +++ b/libs/sysplugins/smarty_internal_configfilelexer.php @@ -21,7 +21,6 @@ */ class Smarty_Internal_Configfilelexer { - /** * Source * @@ -104,7 +103,8 @@ class Smarty_Internal_Configfilelexer * * @var array */ - public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', 6 => 'TRIPPLE'); + public $state_name = array(1 => 'START', 2 => 'VALUE', 3 => 'NAKED_STRING_VALUE', 4 => 'COMMENT', 5 => 'SECTION', + 6 => 'TRIPPLE'); /** * storage for assembled token patterns @@ -210,7 +210,7 @@ class Smarty_Internal_Configfilelexer public function yylex1() { if (!isset($this->yy_global_pattern1)) { - $this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS"; + $this->yy_global_pattern1 = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -219,7 +219,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state START'); } @@ -308,7 +312,7 @@ class Smarty_Internal_Configfilelexer public function yylex2() { if (!isset($this->yy_global_pattern2)) { - $this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS"; + $this->yy_global_pattern2 = "/\G([ \t\r]+)|\G(\\d+\\.\\d+(?=[ \t\r]*[\n#;]))|\G(\\d+(?=[ \t\r]*[\n#;]))|\G(\"\"\")|\G('[^'\\\\]*(?:\\\\.[^'\\\\]*)*'(?=[ \t\r]*[\n#;]))|\G(\"[^\"\\\\]*(?:\\\\.[^\"\\\\]*)*\"(?=[ \t\r]*[\n#;]))|\G([a-zA-Z]+(?=[ \t\r]*[\n#;]))|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -317,7 +321,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state VALUE'); } @@ -396,7 +404,9 @@ class Smarty_Internal_Configfilelexer function yy_r2_7() { - if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", "no"))) { + if (!$this->configBooleanize || !in_array(strtolower($this->value), Array("true", "false", "on", "off", "yes", + "no")) + ) { $this->yypopstate(); $this->yypushstate(self::NAKED_STRING_VALUE); return true; //reprocess in new state @@ -424,7 +434,7 @@ class Smarty_Internal_Configfilelexer public function yylex3() { if (!isset($this->yy_global_pattern3)) { - $this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/iS"; + $this->yy_global_pattern3 = "/\G([^\n]+?(?=[ \t\r]*\n))/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -433,7 +443,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state NAKED_STRING_VALUE'); } @@ -478,7 +492,7 @@ class Smarty_Internal_Configfilelexer public function yylex4() { if (!isset($this->yy_global_pattern4)) { - $this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/iS"; + $this->yy_global_pattern4 = "/\G([ \t\r]+)|\G([^\n]+?(?=[ \t\r]*\n))|\G(\n)/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -487,7 +501,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state COMMENT'); } @@ -544,7 +562,7 @@ class Smarty_Internal_Configfilelexer public function yylex5() { if (!isset($this->yy_global_pattern5)) { - $this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/iS"; + $this->yy_global_pattern5 = "/\G(\\.)|\G(.*?(?=[\.=[\]\r\n]))/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -553,7 +571,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state SECTION'); } @@ -604,7 +626,7 @@ class Smarty_Internal_Configfilelexer public function yylex6() { if (!isset($this->yy_global_pattern6)) { - $this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS"; + $this->yy_global_pattern6 = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/isS"; } if ($this->counter >= strlen($this->data)) { return false; // end of input @@ -613,7 +635,11 @@ class Smarty_Internal_Configfilelexer do { if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TRIPPLE'); } @@ -669,4 +695,5 @@ class Smarty_Internal_Configfilelexer $this->value = substr($this->data, $this->counter, $to - $this->counter); $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_TEXT; } + } diff --git a/libs/sysplugins/smarty_internal_configfileparser.php b/libs/sysplugins/smarty_internal_configfileparser.php index 51e4a9bb..69aaf990 100644 --- a/libs/sysplugins/smarty_internal_configfileparser.php +++ b/libs/sysplugins/smarty_internal_configfileparser.php @@ -2,7 +2,6 @@ class TPC_yyToken implements ArrayAccess { - public $string = ''; public $metadata = array(); @@ -68,7 +67,6 @@ class TPC_yyToken implements ArrayAccess class TPC_yyStackEntry { - public $stateno; /* The state-number */ public $major; /* The major token value. This is the code ** number for the token at this stack level */ @@ -357,15 +355,18 @@ class Smarty_Internal_Configfileparser const YY_SZ_ACTTAB = 38; - static public $yy_action = array(29, 30, 34, 33, 24, 13, 19, 25, 35, 21, 59, 8, 3, 1, 20, 12, 14, 31, 20, 12, 15, 17, 23, 18, 27, 26, 4, 5, 6, 32, 2, 11, 28, 22, 16, 9, 7, 10,); + static public $yy_action = array(29, 30, 34, 33, 24, 13, 19, 25, 35, 21, 59, 8, 3, 1, 20, 12, 14, 31, 20, 12, 15, + 17, 23, 18, 27, 26, 4, 5, 6, 32, 2, 11, 28, 22, 16, 9, 7, 10,); - static public $yy_lookahead = array(7, 8, 9, 10, 11, 12, 5, 27, 15, 16, 20, 21, 23, 23, 17, 18, 13, 14, 17, 18, 15, 2, 17, 4, 25, 26, 6, 3, 3, 14, 23, 1, 24, 17, 2, 25, 22, 25,); + static public $yy_lookahead = array(7, 8, 9, 10, 11, 12, 5, 27, 15, 16, 20, 21, 23, 23, 17, 18, 13, 14, 17, 18, 15, + 2, 17, 4, 25, 26, 6, 3, 3, 14, 23, 1, 24, 17, 2, 25, 22, 25,); const YY_SHIFT_USE_DFLT = - 8; const YY_SHIFT_MAX = 19; - static public $yy_shift_ofst = array(- 8, 1, 1, 1, - 7, - 3, - 3, 30, - 8, - 8, - 8, 19, 5, 3, 15, 16, 24, 25, 32, 20,); + static public $yy_shift_ofst = array(- 8, 1, 1, 1, - 7, - 3, - 3, 30, - 8, - 8, - 8, 19, 5, 3, 15, 16, 24, 25, 32, + 20,); const YY_REDUCE_USE_DFLT = - 21; @@ -373,9 +374,14 @@ class Smarty_Internal_Configfileparser static public $yy_reduce_ofst = array(- 10, - 1, - 1, - 1, - 20, 10, 12, 8, 14, 7, - 11,); - static public $yyExpectedTokens = array(array(), array(5, 17, 18,), array(5, 17, 18,), array(5, 17, 18,), array(7, 8, 9, 10, 11, 12, 15, 16,), array(17, 18,), array(17, 18,), array(1,), array(), array(), array(), array(2, 4,), array(15, 17,), array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,), array(6,), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(),); + static public $yyExpectedTokens = array(array(), array(5, 17, 18,), array(5, 17, 18,), array(5, 17, 18,), + array(7, 8, 9, 10, 11, 12, 15, 16,), array(17, 18,), array(17, 18,), array(1,), array(), array(), array(), + array(2, 4,), array(15, 17,), array(13, 14,), array(14,), array(17,), array(3,), array(3,), array(2,), + array(6,), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), array(), + array(), array(), array(), array(), array(),); - static public $yy_default = array(44, 37, 41, 40, 58, 58, 58, 36, 39, 44, 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, 47, 52, 51, 49, 48, 53,); + static public $yy_default = array(44, 37, 41, 40, 58, 58, 58, 36, 39, 44, 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, + 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, 47, 52, 51, 49, 48, 53,); const YYNOCODE = 29; @@ -418,9 +424,19 @@ class Smarty_Internal_Configfileparser public $yyerrcnt; /* Shifts left before out of the error */ public $yystack = array(); /* The parser's stack */ - public $yyTokenName = array('$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', 'start', 'global_vars', 'sections', 'var_list', 'section', 'newline', 'var', 'value',); + public $yyTokenName = array('$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL', + 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', + 'NAKED_STRING', 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', 'start', 'global_vars', 'sections', 'var_list', + 'section', 'newline', 'var', 'value',); - public static $yyRuleName = array('start ::= global_vars sections', 'global_vars ::= var_list', 'sections ::= sections section', 'sections ::=', 'section ::= OPENB SECTION CLOSEB newline var_list', 'section ::= OPENB DOT SECTION CLOSEB newline var_list', 'var_list ::= var_list newline', 'var_list ::= var_list var', 'var_list ::=', 'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT', 'value ::= BOOL', 'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING', 'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END', 'value ::= NAKED_STRING', 'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE', 'newline ::= COMMENTSTART NAKED_STRING NEWLINE',); + public static $yyRuleName = array('start ::= global_vars sections', 'global_vars ::= var_list', + 'sections ::= sections section', 'sections ::=', 'section ::= OPENB SECTION CLOSEB newline var_list', + 'section ::= OPENB DOT SECTION CLOSEB newline var_list', 'var_list ::= var_list newline', + 'var_list ::= var_list var', 'var_list ::=', 'var ::= ID EQUAL value', 'value ::= FLOAT', 'value ::= INT', + 'value ::= BOOL', 'value ::= SINGLE_QUOTED_STRING', 'value ::= DOUBLE_QUOTED_STRING', + 'value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END', 'value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END', + 'value ::= NAKED_STRING', 'value ::= OTHER', 'newline ::= NEWLINE', 'newline ::= COMMENTSTART NEWLINE', + 'newline ::= COMMENTSTART NAKED_STRING NEWLINE',); public function tokenName($tokenType) { @@ -722,9 +738,16 @@ class Smarty_Internal_Configfileparser } } - public static $yyRuleInfo = array(array(0 => 20, 1 => 2), array(0 => 21, 1 => 1), array(0 => 22, 1 => 2), array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6), array(0 => 23, 1 => 2), array(0 => 23, 1 => 2), array(0 => 23, 1 => 0), array(0 => 26, 1 => 3), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 25, 1 => 1), array(0 => 25, 1 => 2), array(0 => 25, 1 => 3),); + public static $yyRuleInfo = array(array(0 => 20, 1 => 2), array(0 => 21, 1 => 1), array(0 => 22, 1 => 2), + array(0 => 22, 1 => 0), array(0 => 24, 1 => 5), array(0 => 24, 1 => 6), array(0 => 23, 1 => 2), + array(0 => 23, 1 => 2), array(0 => 23, 1 => 0), array(0 => 26, 1 => 3), array(0 => 27, 1 => 1), + array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), + array(0 => 27, 1 => 3), array(0 => 27, 1 => 2), array(0 => 27, 1 => 1), array(0 => 27, 1 => 1), + array(0 => 25, 1 => 1), array(0 => 25, 1 => 2), array(0 => 25, 1 => 3),); - public static $yyReduceMap = array(0 => 0, 2 => 0, 3 => 0, 19 => 0, 20 => 0, 21 => 0, 1 => 1, 4 => 4, 5 => 5, 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 17,); + public static $yyReduceMap = array(0 => 0, 2 => 0, 3 => 0, 19 => 0, 20 => 0, 21 => 0, 1 => 1, 4 => 4, 5 => 5, + 6 => 6, 7 => 7, 8 => 8, 9 => 9, 10 => 10, 11 => 11, 12 => 12, 13 => 13, + 14 => 14, 15 => 15, 16 => 16, 17 => 17, 18 => 17,); #line 261 "../smarty/lexer/smarty_internal_configfileparser.y" function yy_r0() @@ -776,7 +799,8 @@ class Smarty_Internal_Configfileparser #line 307 "../smarty/lexer/smarty_internal_configfileparser.y" function yy_r9() { - $this->_retvalue = Array("key" => $this->yystack[$this->yyidx + - 2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor); + $this->_retvalue = Array("key" => $this->yystack[$this->yyidx + - 2]->minor, + "value" => $this->yystack[$this->yyidx + 0]->minor); } #line 312 "../smarty/lexer/smarty_internal_configfileparser.y" diff --git a/libs/sysplugins/smarty_internal_templatelexer.php b/libs/sysplugins/smarty_internal_templatelexer.php index 9bb6b63e..abf81d08 100644 --- a/libs/sysplugins/smarty_internal_templatelexer.php +++ b/libs/sysplugins/smarty_internal_templatelexer.php @@ -286,7 +286,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern1, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TEXT'); } @@ -399,7 +403,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern2, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAG'); } @@ -525,7 +533,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern3, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state TAGBODY '); } @@ -852,7 +864,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern4, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state LITERAL'); } @@ -932,7 +948,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern5, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state DOUBLEQUOTEDSTRING'); } @@ -1067,7 +1087,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern6, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBODY'); } @@ -1157,7 +1181,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern7, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDBLOCK'); } @@ -1260,7 +1288,11 @@ class Smarty_Internal_Templatelexer do { if (preg_match($this->yy_global_pattern8, $this->data, $yymatches, null, $this->counter)) { $yysubmatches = $yymatches; - $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + if (strlen($yysubmatches[0]) < 200) { + $yymatches = preg_grep("/(.|\s)+/", $yysubmatches); + } else { + $yymatches = array_filter($yymatches, 'strlen'); + } if (empty($yymatches)) { throw new Exception('Error: lexing failed because a rule matched' . ' an empty string. Input "' . substr($this->data, $this->counter, 5) . '... state CHILDLITERAL'); }