Bug #49446 [Com]: escapeshellarg dosn`t work on windows

From: Date: Thu, 25 May 2023 05:14:40 +0000
Subject: Bug #49446 [Com]: escapeshellarg dosn`t work on windows
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-244520@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=49446&edit=1 ID: 49446 Comment by: tourtraveltipsinc 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: Tour Travel Tips Inc are tour,destination, beaches, hotels, resturants etc. More info to visit:(https://tourtraveltipsinc.com)github.com Previous Comments: ------------------------------------------------------------------------ [2018-04-14 13:01:28] micke dot andrsn at gmail dot com 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 ------------------------------------------------------------------------ [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&amp;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". ------------------------------------------------------------------------ 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

« previous php.bugs (#244520) next »