cvs: ZendEngine2(PHP_5_2) / zend_language_scanner.l php-src NEWS

[email protected] ("Scott MacVicar")
Newsgroups php.zend-engine.cvs
Message-ID <cvsscottmac1207777213@cvsserver>
scottmac		Wed Apr  9 21:40:13 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src	NEWS 
    /ZendEngine2	zend_language_scanner.l 
  Log:
  Fix heredoc handling. (Patch by Matt Wilmas)
  
  
http://cvs.php.net/viewvc.cgi/php-src/NEWS?r1=1.2027.2.547.2.1138&r2=1.2027.2.547.2.1139&diff_format=u
Index: php-src/NEWS
diff -u php-src/NEWS:1.2027.2.547.2.1138 php-src/NEWS:1.2027.2.547.2.1139
--- php-src/NEWS:1.2027.2.547.2.1138	Wed Apr  9 09:16:39 2008
+++ php-src/NEWS	Wed Apr  9 21:40:12 2008
@@ -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'
http://cvs.php.net/viewvc.cgi/ZendEngine2/zend_language_scanner.l?r1=1.131.2.11.2.14&r2=1.131.2.11.2.15&diff_format=u
Index: ZendEngine2/zend_language_scanner.l
diff -u ZendEngine2/zend_language_scanner.l:1.131.2.11.2.14 ZendEngine2/zend_language_scanner.l:1.131.2.11.2.15
--- ZendEngine2/zend_language_scanner.l:1.131.2.11.2.14	Sat Mar 22 18:53:08 2008
+++ ZendEngine2/zend_language_scanner.l	Wed Apr  9 21:40:13 2008
@@ -19,7 +19,7 @@
    +----------------------------------------------------------------------+
 */
 
-/* $Id: zend_language_scanner.l,v 1.131.2.11.2.14 2008/03/22 18:53:08 helly Exp $ */
+/* $Id: zend_language_scanner.l,v 1.131.2.11.2.15 2008/04/09 21:40:13 scottmac Exp $ */
 
 #define yyleng SCNG(yy_leng)
 #define yytext SCNG(yy_text)
@@ -1919,8 +1919,13 @@
 	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 @@
 	} 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();
 	}
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.