cellog          Sat Jan  5 21:05:14 2008 UTC

  Modified files:              (Branch: PHP_5_2)
    /php-src    run-tests.php 
  Log:
  implement --FILE_EXTERNAL-- section for using an external file as --FILE--, 
use CGI for --EXPECTHEADERS--, fix --POST_RAW--
  
http://cvs.php.net/viewvc.cgi/php-src/run-tests.php?r1=1.226.2.37.2.41&r2=1.226.2.37.2.42&diff_format=u
Index: php-src/run-tests.php
diff -u php-src/run-tests.php:1.226.2.37.2.41 
php-src/run-tests.php:1.226.2.37.2.42
--- php-src/run-tests.php:1.226.2.37.2.41       Tue Jan  1 06:15:48 2008
+++ php-src/run-tests.php       Sat Jan  5 21:05:14 2008
@@ -24,7 +24,7 @@
    +----------------------------------------------------------------------+
  */
 
-/* $Id: run-tests.php,v 1.226.2.37.2.41 2008/01/01 06:15:48 sebastian Exp $ */
+/* $Id: run-tests.php,v 1.226.2.37.2.42 2008/01/05 21:05:14 cellog Exp $ */
 
 /* Sanity check to ensure that pcre extension needed by this script is 
available.
  * In the event it is not, print a nice error message indicating that this 
script will
@@ -403,7 +403,7 @@
                                        $html_output = is_resource($html_file);
                                        break;
                                case '--version':
-                                       echo '$Revision: 1.226.2.37.2.41 
$'."\n";
+                                       echo '$Revision: 1.226.2.37.2.42 
$'."\n";
                                        exit(1);
 
                                case 'u':
@@ -1004,7 +1004,7 @@
                if (preg_match('/^--([_A-Z]+)--/', $line, $r)) {
                        $section = $r[1];
                        $section_text[$section] = '';
-                       $secfile = $section == 'FILE' || $section == 'FILEEOF';
+                       $secfile = $section == 'FILE' || $section == 'FILEEOF' 
|| $section == 'FILE_EXTERNAL';
                        $secdone = false;
                        continue;
                }
@@ -1030,7 +1030,7 @@
                        $borked = false;
                }
        } else {
-               if (@count($section_text['FILE']) + 
@count($section_text['FILEEOF']) != 1) {
+               if (@count($section_text['FILE']) + 
@count($section_text['FILEEOF']) + @count($section_text['FILE_EXTERNAL']) != 1) 
{
                        $bork_info = "missing section --FILE--";
                        $borked = true;
                }
@@ -1038,6 +1038,17 @@
                        $section_text['FILE'] = preg_replace("/[\r\n]+$/", '', 
$section_text['FILEEOF']);
                        unset($section_text['FILEEOF']);
                }
+               if (@count($section_text['FILE_EXTERNAL']) == 1) {
+                       // don't allow tests to retrieve files from anywhere 
but this subdirectory
+                       $section_text['FILE_EXTERNAL'] = dirname($file) . '/' . 
trim(str_replace('..', '', $section_text['FILE_EXTERNAL']));
+                       if (@file_exists($section_text['FILE_EXTERNAL'])) {
+                               $section_text['FILE'] = 
file_get_contents($section_text['FILE_EXTERNAL']);
+                               unset($section_text['FILE_EXTERNAL']);
+                       } else {
+                               $bork_info = "could not load --FILE_EXTERNAL-- 
" . dirname($file) . '/' . trim($section_text['FILE_EXTERNAL']);
+                               $borked = true;
+                       }
+               }
                if ((@count($section_text['EXPECT']) + 
@count($section_text['EXPECTF']) + @count($section_text['EXPECTREGEX'])) != 1) {
                        $bork_info = "missing section --EXPECT--, --EXPECTF-- 
or --EXPECTREGEX--";
                        $borked = true;
@@ -1063,7 +1074,7 @@
        $tested = trim($section_text['TEST']);
 
        /* For GET/POST tests, check if cgi sapi is available and if it is, use 
it. */
-       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE'])) {
+       if (!empty($section_text['GET']) || !empty($section_text['POST']) || 
!empty($section_text['POST_RAW']) || !empty($section_text['COOKIE']) || 
!empty($section_text['EXPECTHEADERS'])) {
                if (isset($php_cgi)) {
                        $old_php = $php;
                        $php = $php_cgi .' -C ';
@@ -1333,12 +1344,15 @@
                $raw_lines = explode("\n", $post);
 
                $request = '';
+               $started = false;
                foreach ($raw_lines as $line) {
                        if (empty($env['CONTENT_TYPE']) && 
preg_match('/^Content-Type:(.*)/i', $line, $res)) {
                                $env['CONTENT_TYPE'] = trim(str_replace("\r", 
'', $res[1]));
                                continue;
                        }
-                       $request .= $line . "\n";
+                       if ($started) $request .= "\n";
+                       $started = true;
+                       $request .= $line;
                }
 
                $env['CONTENT_LENGTH'] = strlen($request);

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to