From: Scott MacVicar Date: Wed, 9 Apr 2008 21:40:13 +0000 (+0000) Subject: Fix heredoc handling. (Patch by Matt Wilmas) X-Git-Tag: php-5.2.6RC5~6 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b584600e1da38583c8ab4325d408946b87302819;p=php Fix heredoc handling. (Patch by Matt Wilmas) --- diff --git a/NEWS b/NEWS index 091a86c22d..b633ae64c7 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,8 @@ PHP NEWS ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||| ?? Apr 2008, PHP 5.2.6 +- Fixed incorrect heredoc handling when label is used within the block. + (Matt Wilmas) - Fixed bug #44673 (With CGI argv/argc starts from arguments, not from script) (Dmitry) - Fixed bug #44667 (proc_open() does not handle pipes with the mode 'wb' diff --git a/Zend/zend_language_scanner.l b/Zend/zend_language_scanner.l index a8ee9e796e..8356408b12 100644 --- a/Zend/zend_language_scanner.l +++ b/Zend/zend_language_scanner.l @@ -1919,8 +1919,13 @@ HEREDOC_CHARS ("{"*([^$\n\r\\{]|("\\"[^\n\r]))|{HEREDOC_LITERAL_DOLLAR}|({ if (yyleng > CG(heredoc_len) && !memcmp(end - CG(heredoc_len), CG(heredoc), CG(heredoc_len))) { int len = yyleng - CG(heredoc_len) - 2; /* 2 for newline before and after label */ - if (len > 0 && yytext[len - 1] == '\r' && yytext[len] == '\n') { - len--; + /* May have matched fooLABEL; make sure there's a newline before it */ + if (yytext[len] != '\n') { + if (yytext[len] != '\r') { + goto wrong_label; + } + } else if (len > 0 && yytext[len - 1] == '\r') { + len--; /* Windows newline */ } /* Go back before last label char, to match in ST_END_HEREDOC state */ @@ -1937,6 +1942,7 @@ HEREDOC_CHARS ("{"*([^$\n\r\\{]|("\\"[^\n\r]))|{HEREDOC_LITERAL_DOLLAR}|({ } else { /* Go back to end of label, so the next match works correctly in case of * a variable or another label at the beginning of the next line */ +wrong_label: yyless(yyleng - 1); yymore(); }