From d0b6b69f7c36f51712bafaf4a4f4a5c05992e9b4 Mon Sep 17 00:00:00 2001 From: "uwe.tews@googlemail.com" Date: Sun, 18 Dec 2011 15:39:51 +0000 Subject: [PATCH] - bufix strings ending with " in multiline strings of config files failed to compile {isse 67) --- change_log.txt | 3 + .../smarty_internal_configfilelexer.php | 24 ++- .../smarty_internal_configfileparser.php | 197 +++++++++--------- 3 files changed, 113 insertions(+), 111 deletions(-) diff --git a/change_log.txt b/change_log.txt index e0e08259..ff9d4c99 100644 --- a/change_log.txt +++ b/change_log.txt @@ -1,4 +1,7 @@ ===== trunk ===== +18.12.2011 +- bufix strings ending with " in multiline strings of config files failed to compile {isse 67) + 17.12.2011 - improvement of compiling speed by new handling of plain text blocks in the lexer/parser (issue 68) diff --git a/libs/sysplugins/smarty_internal_configfilelexer.php b/libs/sysplugins/smarty_internal_configfilelexer.php index 6f95d569..326d8f97 100644 --- a/libs/sysplugins/smarty_internal_configfilelexer.php +++ b/libs/sysplugins/smarty_internal_configfilelexer.php @@ -81,11 +81,12 @@ class Smarty_Internal_Configfilelexer 5 => 0, 6 => 0, 7 => 0, + 8 => 0, ); if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)/iS"; + $yy_global_pattern = "/\G(#|;)|\G(\\[)|\G(\\])|\G(=)|\G([ \t\r]+)|\G(\n)|\G([0-9]*[a-zA-Z_]\\w*)|\G([\S\s])/iS"; do { if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { @@ -173,6 +174,11 @@ class Smarty_Internal_Configfilelexer $this->token = Smarty_Internal_Configfileparser::TPC_ID; } + function yy_r1_8($yy_subpatterns) + { + + $this->token = Smarty_Internal_Configfileparser::TPC_OTHER; + } @@ -528,12 +534,11 @@ class Smarty_Internal_Configfilelexer $tokenMap = array ( 1 => 0, 2 => 0, - 3 => 2, ); if ($this->counter >= strlen($this->data)) { return false; // end of input } - $yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([ \t\r]*\n)|\G(([\S\s]*?)(?=([ \t\r]*\n|\"\"\")))/iS"; + $yy_global_pattern = "/\G(\"\"\"(?=[ \t\r]*[\n#;]))|\G([\S\s])/iS"; do { if ($this->mbstring_overload ? preg_match($yy_global_pattern, substr($this->data, $this->counter), $yymatches) : preg_match($yy_global_pattern,$this->data, $yymatches, null, $this->counter)) { @@ -593,12 +598,13 @@ class Smarty_Internal_Configfilelexer function yy_r6_2($yy_subpatterns) { - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_CONTENT; - } - function yy_r6_3($yy_subpatterns) - { - - $this->token = Smarty_Internal_Configfileparser::TPC_TRIPPLE_CONTENT; + $to = strlen($this->data); + preg_match("/\"\"\"[ \t\r]*[\n#;]/",$this->data,$match,PREG_OFFSET_CAPTURE,$this->counter); + if (isset($match[0][1])) { + $to = $match[0][1]; + } + $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 f28fbc85..784bc684 100644 --- a/libs/sysplugins/smarty_internal_configfileparser.php +++ b/libs/sysplugins/smarty_internal_configfileparser.php @@ -191,57 +191,58 @@ class Smarty_Internal_Configfileparser#line 79 "smarty_internal_configfileparser const TPC_SINGLE_QUOTED_STRING = 10; const TPC_DOUBLE_QUOTED_STRING = 11; const TPC_TRIPPLE_QUOTES = 12; - const TPC_TRIPPLE_QUOTES_END = 13; - const TPC_NAKED_STRING = 14; - const TPC_TRIPPLE_CONTENT = 15; - const TPC_NEWLINE = 16; - const TPC_COMMENTSTART = 17; - const YY_NO_ACTION = 61; - const YY_ACCEPT_ACTION = 60; - const YY_ERROR_ACTION = 59; + const TPC_TRIPPLE_TEXT = 13; + const TPC_TRIPPLE_QUOTES_END = 14; + const TPC_NAKED_STRING = 15; + const TPC_OTHER = 16; + const TPC_NEWLINE = 17; + const TPC_COMMENTSTART = 18; + const YY_NO_ACTION = 60; + const YY_ACCEPT_ACTION = 59; + const YY_ERROR_ACTION = 58; - const YY_SZ_ACTTAB = 39; + const YY_SZ_ACTTAB = 38; static public $yy_action = array( - /* 0 */ 29, 30, 34, 33, 24, 7, 19, 21, 60, 9, - /* 10 */ 16, 1, 20, 14, 15, 6, 23, 20, 14, 32, - /* 20 */ 17, 31, 18, 27, 26, 2, 3, 5, 25, 22, - /* 30 */ 35, 4, 13, 11, 10, 12, 53, 28, 8, + /* 0 */ 29, 30, 34, 33, 24, 13, 19, 25, 35, 21, + /* 10 */ 59, 8, 3, 1, 20, 12, 14, 31, 20, 12, + /* 20 */ 15, 17, 23, 18, 27, 26, 4, 5, 6, 32, + /* 30 */ 2, 11, 28, 22, 16, 9, 7, 10, ); static public $yy_lookahead = array( - /* 0 */ 7, 8, 9, 10, 11, 12, 5, 14, 19, 20, - /* 10 */ 2, 22, 16, 17, 14, 3, 16, 16, 17, 13, - /* 20 */ 2, 15, 4, 24, 25, 22, 22, 3, 26, 16, - /* 30 */ 15, 6, 27, 24, 24, 1, 28, 23, 21, + /* 0 */ 7, 8, 9, 10, 11, 12, 5, 27, 15, 16, + /* 10 */ 20, 21, 23, 23, 17, 18, 13, 14, 17, 18, + /* 20 */ 15, 2, 17, 4, 25, 26, 6, 3, 3, 14, + /* 30 */ 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( - /* 0 */ -8, 1, 1, 1, -7, -4, -4, 15, 34, -8, - /* 10 */ -8, -8, 18, 6, 0, 13, 24, 12, 8, 25, + /* 0 */ -8, 1, 1, 1, -7, -3, -3, 30, -8, -8, + /* 10 */ -8, 19, 5, 3, 15, 16, 24, 25, 32, 20, ); - const YY_REDUCE_USE_DFLT = -12; - const YY_REDUCE_MAX = 11; + const YY_REDUCE_USE_DFLT = -21; + const YY_REDUCE_MAX = 10; static public $yy_reduce_ofst = array( - /* 0 */ -11, -1, -1, -1, 2, 10, 9, 5, 14, 17, - /* 10 */ 3, 4, + /* 0 */ -10, -1, -1, -1, -20, 10, 12, 8, 14, 7, + /* 10 */ -11, ); static public $yyExpectedTokens = array( /* 0 */ array(), - /* 1 */ array(5, 16, 17, ), - /* 2 */ array(5, 16, 17, ), - /* 3 */ array(5, 16, 17, ), - /* 4 */ array(7, 8, 9, 10, 11, 12, 14, ), - /* 5 */ array(16, 17, ), - /* 6 */ array(16, 17, ), - /* 7 */ array(15, ), - /* 8 */ array(1, ), + /* 1 */ array(5, 17, 18, ), + /* 2 */ array(5, 17, 18, ), + /* 3 */ array(5, 17, 18, ), + /* 4 */ array(7, 8, 9, 10, 11, 12, 15, 16, ), + /* 5 */ array(17, 18, ), + /* 6 */ array(17, 18, ), + /* 7 */ array(1, ), + /* 8 */ array(), /* 9 */ array(), /* 10 */ array(), - /* 11 */ array(), - /* 12 */ array(2, 4, ), - /* 13 */ array(13, 15, ), - /* 14 */ array(14, 16, ), - /* 15 */ array(16, ), + /* 11 */ array(2, 4, ), + /* 12 */ array(15, 17, ), + /* 13 */ array(13, 14, ), + /* 14 */ array(14, ), + /* 15 */ array(17, ), /* 16 */ array(3, ), /* 17 */ array(3, ), /* 18 */ array(2, ), @@ -264,16 +265,16 @@ static public $yy_action = array( /* 35 */ array(), ); static public $yy_default = array( - /* 0 */ 44, 37, 41, 40, 59, 59, 59, 55, 36, 39, - /* 10 */ 44, 44, 59, 59, 59, 59, 59, 59, 59, 59, - /* 20 */ 56, 52, 58, 57, 50, 45, 43, 42, 38, 46, - /* 30 */ 47, 53, 51, 49, 48, 54, + /* 0 */ 44, 37, 41, 40, 58, 58, 58, 36, 39, 44, + /* 10 */ 44, 58, 58, 58, 58, 58, 58, 58, 58, 58, + /* 20 */ 55, 54, 57, 56, 50, 45, 43, 42, 38, 46, + /* 30 */ 47, 52, 51, 49, 48, 53, ); const YYNOCODE = 29; const YYSTACKDEPTH = 100; const YYNSTATE = 36; - const YYNRULE = 23; - const YYERRORSYMBOL = 18; + const YYNRULE = 22; + const YYERRORSYMBOL = 19; const YYERRSYMDT = 'yy0'; const YYFALLBACK = 0; static public $yyFallback = array( @@ -305,10 +306,10 @@ static public $yy_action = array( '$', 'OPENB', 'SECTION', 'CLOSEB', 'DOT', 'ID', 'EQUAL', 'FLOAT', 'INT', 'BOOL', 'SINGLE_QUOTED_STRING', 'DOUBLE_QUOTED_STRING', - 'TRIPPLE_QUOTES', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', 'TRIPPLE_CONTENT', - 'NEWLINE', 'COMMENTSTART', 'error', 'start', - 'global_vars', 'sections', 'var_list', 'section', - 'newline', 'var', 'value', 'tripple_content', + 'TRIPPLE_QUOTES', 'TRIPPLE_TEXT', 'TRIPPLE_QUOTES_END', 'NAKED_STRING', + 'OTHER', 'NEWLINE', 'COMMENTSTART', 'error', + 'start', 'global_vars', 'sections', 'var_list', + 'section', 'newline', 'var', 'value', ); static public $yyRuleName = array( @@ -327,14 +328,13 @@ static public $yy_action = array( /* 12 */ "value ::= BOOL", /* 13 */ "value ::= SINGLE_QUOTED_STRING", /* 14 */ "value ::= DOUBLE_QUOTED_STRING", - /* 15 */ "value ::= TRIPPLE_QUOTES tripple_content TRIPPLE_QUOTES_END", - /* 16 */ "value ::= NAKED_STRING", - /* 17 */ "tripple_content ::= tripple_content TRIPPLE_CONTENT", - /* 18 */ "tripple_content ::= TRIPPLE_CONTENT", - /* 19 */ "tripple_content ::=", - /* 20 */ "newline ::= NEWLINE", - /* 21 */ "newline ::= COMMENTSTART NEWLINE", - /* 22 */ "newline ::= COMMENTSTART NAKED_STRING NEWLINE", + /* 15 */ "value ::= TRIPPLE_QUOTES TRIPPLE_TEXT TRIPPLE_QUOTES_END", + /* 16 */ "value ::= TRIPPLE_QUOTES TRIPPLE_QUOTES_END", + /* 17 */ "value ::= NAKED_STRING", + /* 18 */ "value ::= OTHER", + /* 19 */ "newline ::= NEWLINE", + /* 20 */ "newline ::= COMMENTSTART NEWLINE", + /* 21 */ "newline ::= COMMENTSTART NAKED_STRING NEWLINE", ); function tokenName($tokenType) @@ -615,38 +615,37 @@ static public $yy_action = array( } static public $yyRuleInfo = array( - array( 'lhs' => 19, 'rhs' => 2 ), - array( 'lhs' => 20, 'rhs' => 1 ), - array( 'lhs' => 21, 'rhs' => 2 ), - array( 'lhs' => 21, 'rhs' => 0 ), - array( 'lhs' => 23, 'rhs' => 5 ), - array( 'lhs' => 23, 'rhs' => 6 ), - array( 'lhs' => 22, 'rhs' => 2 ), + array( 'lhs' => 20, 'rhs' => 2 ), + array( 'lhs' => 21, 'rhs' => 1 ), array( 'lhs' => 22, 'rhs' => 2 ), array( 'lhs' => 22, 'rhs' => 0 ), - array( 'lhs' => 25, 'rhs' => 3 ), - array( 'lhs' => 26, 'rhs' => 1 ), - array( 'lhs' => 26, 'rhs' => 1 ), - array( 'lhs' => 26, 'rhs' => 1 ), - array( 'lhs' => 26, 'rhs' => 1 ), - array( 'lhs' => 26, 'rhs' => 1 ), + array( 'lhs' => 24, 'rhs' => 5 ), + array( 'lhs' => 24, 'rhs' => 6 ), + array( 'lhs' => 23, 'rhs' => 2 ), + array( 'lhs' => 23, 'rhs' => 2 ), + array( 'lhs' => 23, 'rhs' => 0 ), array( 'lhs' => 26, 'rhs' => 3 ), - array( 'lhs' => 26, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 27, 'rhs' => 3 ), array( 'lhs' => 27, 'rhs' => 2 ), array( 'lhs' => 27, 'rhs' => 1 ), - array( 'lhs' => 27, 'rhs' => 0 ), - array( 'lhs' => 24, 'rhs' => 1 ), - array( 'lhs' => 24, 'rhs' => 2 ), - array( 'lhs' => 24, 'rhs' => 3 ), + array( 'lhs' => 27, 'rhs' => 1 ), + array( 'lhs' => 25, 'rhs' => 1 ), + array( 'lhs' => 25, 'rhs' => 2 ), + array( 'lhs' => 25, 'rhs' => 3 ), ); static public $yyReduceMap = array( 0 => 0, 2 => 0, 3 => 0, + 19 => 0, 20 => 0, 21 => 0, - 22 => 0, 1 => 1, 4 => 4, 5 => 5, @@ -661,26 +660,25 @@ static public $yy_action = array( 14 => 14, 15 => 15, 16 => 16, - 18 => 16, 17 => 17, - 19 => 19, + 18 => 17, ); #line 131 "smarty_internal_configfileparser.y" function yy_r0(){ $this->_retvalue = null; } -#line 668 "smarty_internal_configfileparser.php" +#line 666 "smarty_internal_configfileparser.php" #line 136 "smarty_internal_configfileparser.y" function yy_r1(){ $this->add_global_vars($this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null; } -#line 673 "smarty_internal_configfileparser.php" +#line 671 "smarty_internal_configfileparser.php" #line 149 "smarty_internal_configfileparser.y" function yy_r4(){ $this->add_section_vars($this->yystack[$this->yyidx + -3]->minor, $this->yystack[$this->yyidx + 0]->minor); $this->_retvalue = null; } -#line 679 "smarty_internal_configfileparser.php" +#line 677 "smarty_internal_configfileparser.php" #line 154 "smarty_internal_configfileparser.y" function yy_r5(){ if ($this->smarty->config_read_hidden) { @@ -688,72 +686,67 @@ static public $yy_action = array( } $this->_retvalue = null; } -#line 687 "smarty_internal_configfileparser.php" +#line 685 "smarty_internal_configfileparser.php" #line 162 "smarty_internal_configfileparser.y" function yy_r6(){ $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor; } -#line 692 "smarty_internal_configfileparser.php" +#line 690 "smarty_internal_configfileparser.php" #line 166 "smarty_internal_configfileparser.y" function yy_r7(){ $this->_retvalue = array_merge($this->yystack[$this->yyidx + -1]->minor, Array($this->yystack[$this->yyidx + 0]->minor)); } -#line 697 "smarty_internal_configfileparser.php" +#line 695 "smarty_internal_configfileparser.php" #line 170 "smarty_internal_configfileparser.y" function yy_r8(){ $this->_retvalue = Array(); } -#line 702 "smarty_internal_configfileparser.php" +#line 700 "smarty_internal_configfileparser.php" #line 176 "smarty_internal_configfileparser.y" function yy_r9(){ $this->_retvalue = Array("key" => $this->yystack[$this->yyidx + -2]->minor, "value" => $this->yystack[$this->yyidx + 0]->minor); } -#line 707 "smarty_internal_configfileparser.php" +#line 705 "smarty_internal_configfileparser.php" #line 181 "smarty_internal_configfileparser.y" function yy_r10(){ $this->_retvalue = (float) $this->yystack[$this->yyidx + 0]->minor; } -#line 712 "smarty_internal_configfileparser.php" +#line 710 "smarty_internal_configfileparser.php" #line 185 "smarty_internal_configfileparser.y" function yy_r11(){ $this->_retvalue = (int) $this->yystack[$this->yyidx + 0]->minor; } -#line 717 "smarty_internal_configfileparser.php" +#line 715 "smarty_internal_configfileparser.php" #line 189 "smarty_internal_configfileparser.y" function yy_r12(){ $this->_retvalue = $this->parse_bool($this->yystack[$this->yyidx + 0]->minor); } -#line 722 "smarty_internal_configfileparser.php" +#line 720 "smarty_internal_configfileparser.php" #line 193 "smarty_internal_configfileparser.y" function yy_r13(){ $this->_retvalue = self::parse_single_quoted_string($this->yystack[$this->yyidx + 0]->minor); } -#line 727 "smarty_internal_configfileparser.php" +#line 725 "smarty_internal_configfileparser.php" #line 197 "smarty_internal_configfileparser.y" function yy_r14(){ $this->_retvalue = self::parse_double_quoted_string($this->yystack[$this->yyidx + 0]->minor); } -#line 732 "smarty_internal_configfileparser.php" +#line 730 "smarty_internal_configfileparser.php" #line 201 "smarty_internal_configfileparser.y" function yy_r15(){ $this->_retvalue = self::parse_tripple_double_quoted_string($this->yystack[$this->yyidx + -1]->minor); } -#line 737 "smarty_internal_configfileparser.php" +#line 735 "smarty_internal_configfileparser.php" #line 205 "smarty_internal_configfileparser.y" function yy_r16(){ - $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; - } -#line 742 "smarty_internal_configfileparser.php" -#line 210 "smarty_internal_configfileparser.y" - function yy_r17(){ - $this->_retvalue = $this->yystack[$this->yyidx + -1]->minor . $this->yystack[$this->yyidx + 0]->minor; - } -#line 747 "smarty_internal_configfileparser.php" -#line 216 "smarty_internal_configfileparser.y" - function yy_r19(){ $this->_retvalue = ''; } -#line 752 "smarty_internal_configfileparser.php" +#line 740 "smarty_internal_configfileparser.php" +#line 209 "smarty_internal_configfileparser.y" + function yy_r17(){ + $this->_retvalue = $this->yystack[$this->yyidx + 0]->minor; + } +#line 745 "smarty_internal_configfileparser.php" private $_retvalue; @@ -815,7 +808,7 @@ static public $yy_action = array( $this->internalError = true; $this->yymajor = $yymajor; $this->compiler->trigger_config_file_error(); -#line 815 "smarty_internal_configfileparser.php" +#line 808 "smarty_internal_configfileparser.php" } function yy_accept() @@ -832,7 +825,7 @@ static public $yy_action = array( $this->internalError = false; $this->retvalue = $this->_retvalue; //echo $this->retvalue."\n\n"; -#line 833 "smarty_internal_configfileparser.php" +#line 826 "smarty_internal_configfileparser.php" } function doParse($yymajor, $yytokenvalue)