Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:28062 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 42859 invoked by uid 1010); 17 Feb 2007 04:24:27 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 42844 invoked from network); 17 Feb 2007 04:24:27 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 17 Feb 2007 04:24:27 -0000 Authentication-Results: pb1.pair.com header.from=greg@chiaraquartet.net; sender-id=unknown Authentication-Results: pb1.pair.com smtp.mail=greg@chiaraquartet.net; spf=permerror; sender-id=unknown Received-SPF: error (pb1.pair.com: domain chiaraquartet.net from 66.79.163.178 cause and error) X-PHP-List-Original-Sender: greg@chiaraquartet.net X-Host-Fingerprint: 66.79.163.178 bluga.net Linux 2.5 (sometimes 2.4) (4) Received: from [66.79.163.178] ([66.79.163.178:33427] helo=mail.bluga.net) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 05/54-34445-97386D54 for ; Fri, 16 Feb 2007 23:24:26 -0500 Received: from mail.bluga.net (mail.bluga.net [127.0.0.1]) by mail.bluga.net (Postfix) with ESMTP id A815C87368 for ; Fri, 16 Feb 2007 20:25:24 -0800 (PST) Received: from [192.168.0.106] (CPE-24-169-242-149.neb.res.rr.com [24.169.242.149]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.bluga.net (Postfix) with ESMTP id 667F887364 for ; Fri, 16 Feb 2007 20:25:24 -0800 (PST) Message-ID: <45D6838C.6030905@chiaraquartet.net> Date: Fri, 16 Feb 2007 22:24:44 -0600 User-Agent: Thunderbird 1.5.0.9 (X11/20070104) MIME-Version: 1.0 To: internals Mailing List Content-Type: multipart/mixed; boundary="------------060909050605020608080006" X-Virus-Scanned: ClamAV using ClamSMTP Subject: new test for php://input and patch for small flaw in run-tests.php From: greg@chiaraquartet.net (Gregory Beaver) --------------060909050605020608080006 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi all, While porting improvements of run-tests.php into the pear run-tests command, I noticed that there are no tests for the php://input stream in PHP_5_2 (didn't look at HEAD yet), so I thought I would offer one if it is useful. At the same time, I found a flaw in the implementation of POST_RAW, patch attached. Basically, \n is appended to all lines including the last line. The patch corrects this by appending \n to all but the last line so there is no trailing whitespace. Here's the new test: --TEST-- php://input --SKIPIF-- --POST_RAW-- Content-Type: application/x-www-form-urlencoded userid=joe&password=guessme --FILE-- --EXPECT-- array(0) { } array(2) { ["userid"]=> string(3) "joe" ["password"]=> string(7) "guessme" } string(27) "userid=joe&password=guessme" --------------060909050605020608080006 Content-Type: text/plain; name="run-tests.oops.patch.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="run-tests.oops.patch.txt" Index: run-tests.php =================================================================== RCS file: /repository/php-src/run-tests.php,v retrieving revision 1.226.2.37.2.23 diff -u -r1.226.2.37.2.23 run-tests.php --- run-tests.php 8 Feb 2007 15:22:03 -0000 1.226.2.37.2.23 +++ run-tests.php 17 Feb 2007 04:22:32 -0000 @@ -1300,12 +1300,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); --------------060909050605020608080006--