#35161 [Opn]: Inaccurate documentation about popen() escaping in safe_mode
| From: | vrana@php.net | Date: | Wed, 09 Nov 2005 11:14:05 +0000 |
| Subject: | #35161 [Opn]: Inaccurate documentation about popen() escaping in safe_mode | ||
| References: | 1 | Groups: | php.doc |
| Request: | Send a blank email to phpdoc+get-969370816@lists.php.net to get a copy of this message | ||
ID: 35161
Updated by: vrana@php.net
Reported By: brion at pobox dot com
Status: Open
Bug Type: Documentation problem
Operating System: Mac OS X
PHP Version: Irrelevant
New Comment:
Snippet changed to: "With safe mode enabled, the command string is
escaped with escapeshellcmd(). Thus, echo
y | echo x becomes echo y \| echo x."
There's really no way to echo '-=< Test >=-' in safe_mode so I have
reopened the bug #32701.
I'm leaving this one open until 32701 will be resolved to document the
final state.
Previous Comments:
------------------------------------------------------------------------
[2005-11-09 03:28:34] brion at pobox dot com
Description:
------------
This bug was reported some months ago about odd escaping in
popen() when safe_mode is on:
http://bugs.php.net/bug.php?id=32701
Arguments correctly escaped, as with escapeshellarg(), end
up being unexpectedly corrupted under safe_mode with the
addition of unexpected backslashes.
The bug was marked as BOGUS. If it this is the intended
behavior, the documentation needs to be modified to reflect
this. Currently the docs for popen() and several other
functions include only this caveat:
"With safe mode enabled, all words following the initial
command string are treated as a single argument. Thus, echo
y | echo x becomes echo "y | echo x"."
However that is *false*:
1) Multiple arguments are sent where separated by spaces.
2) Quotes seem to be understood, so multi-word arguments are
themselves passed intact.
3) In addition to this sensible behavior, many characters
have backslashes inserted before them, even if they are
inside already-quoted arguments.
Accurate documentation, and an explanation of how to get
parameters to the other program without corruption, would be
a huge help in making our programs work correctly under
safe_mode.
cf http://bugzilla.wikimedia.org/show_bug.cgi?id=3891#c13
Reproduce code:
---------------
<?php
$r = popen("echo '-=< Test >=-'", "r");
print(stream_get_contents($r));
pclose($r);
?>
Expected result:
----------------
-=< Test >=-
Actual result:
--------------
-=\< Test \>=-
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=35161&edit=1