Bug #49446 [Com]: escapeshellarg dosn`t work on windows
Edit report at https://bugs.php.net/bug.php?id=49446&edit=1
ID: 49446
Comment by: micke dot andrsn at gmail dot com
Reported by: heromantor at users dot sourceforge dot net
Summary: escapeshellarg dosn`t work on windows
Status: Open
Type: Bug
Package: CGI/CLI related
Operating System: windows xp sp2
PHP Version: 5.2.10
Block user comment: N
Private report: N
New Comment:
Here is a PHP library which escapes everything correctly on Windows, if you want to port the
algorithm to native C code:
https://github.com/johnstevenson/winbox-args/blob/master/src/Args.php
Previous Comments:
------------------------------------------------------------------------
[2016-06-21 17:00:03] cmb@php.net
Automatic comment from SVN on behalf of cmb
Revision: http://svn.php.net/viewvc/?view=revision&revision=339439
Log: Fix Windows related documentation (see #49446)
------------------------------------------------------------------------
[2016-06-21 16:34:42] cmb@php.net
FWIW, I've just tested with PHP 7.0.7:
<?php
var_dump(escapeshellarg("%PATH%"));
var_dump(escapeshellarg("c:\\temp\\"));
var_dump(escapeshellarg('\\"'));
?>
Result:
string(8) "" PATH ""
string(11) ""c:\temp\\""
string(4) ""\ ""
With regard to the documentation (3) is correct, but (1) and (2)
would be wrong:
| On Windows, escapeshellarg() instead removes percent signs,
| replaces double quotes with spaces and adds double quotes around
| the string.
The documentation also doesn't yet mention that exclamation marks
are replaced by spaces.
I'll fix the doc bugs right away.
Anyhow, I'd like to see:
string(10) ""^%PATH^%""
string(10) ""c:\temp\""
string(3) "\"""
------------------------------------------------------------------------
[2011-03-03 10:54:28] pajoye@php.net
Something is wrong with this patch, and we should try to use ^ in trunk.
------------------------------------------------------------------------
[2009-09-11 01:00:00] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
------------------------------------------------------------------------
[2009-09-03 04:16:48] scottmac@php.net
This was fixed in 5.3 with bug #43261
Though \\ within double quotes is considered a single \
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=49446
--
Edit this bug report at https://bugs.php.net/bug.php?id=49446&edit=1
Thread (10 messages)