#43908 [Opn]: exec() swallows whitespace in output
| From: | Arne dot Heizmann at csr dot com | Date: | Fri, 25 Jan 2008 17:59:47 +0000 |
| Subject: | #43908 [Opn]: exec() swallows whitespace in output | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-121539@lists.php.net to get a copy of this message | ||
ID: 43908
User updated by: Arne dot Heizmann at csr dot com
Reported By: Arne dot Heizmann at csr dot com
Status: Open
Bug Type: *General Issues
Operating System: Windows 2000
PHP Version: 5.2.5
New Comment:
> The actual implementation strip trailing whitespaces, my patch also
do
> it, but when the string contains only whitespaces, it remove just \r
> and \n.
So why are you explicitly fixing only half of the bug and leaving the
other half in?
Previous Comments:
------------------------------------------------------------------------
[2008-01-24 20:37:30] felipe@php.net
The actual implementation strip trailing whitespaces, my patch also do
it, but when the string contains only whitespaces, it remove just \r and
\n.
------------------------------------------------------------------------
[2008-01-24 15:46:45] Arne dot Heizmann at csr dot com
In your patch it appears that you are still deliberately removing
whitespace. Why?
------------------------------------------------------------------------
[2008-01-24 10:35:40] felipe@php.net
My suggestion:
http://ecl.zoone.com.br/etc/patches/bug43908.patch
------------------------------------------------------------------------
[2008-01-24 02:53:33] davidc@php.net
Even easier to reproduce:
<?php var_dump(exec("echo ' '")); ?>
------------------------------------------------------------------------
[2008-01-22 16:51:56] Arne dot Heizmann at csr dot com
Description:
------------
The exec() call is supposed to return the output of the system call
into the second parameter.
However, it modifies this output. It behaves as if rtrim() is called on
each line. This causes data loss because rtrim() is not reversible.
Reproduce code:
---------------
<?
header ('Content-type: text/plain');
file_put_contents ('temp', " "); // also reproducible with "\t"
exec ("type temp", $ops, $result);
echo var_export ($ops, true);
?>
Expected result:
----------------
array (
0 => ' ',
)
Actual result:
--------------
array (
0 => '',
)
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=43908&edit=1