php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #40928 escapeshellarg() does not quote percent (%) correctly for cmd.exe
Submitted: 2007-03-27 13:31 UTC Modified: 2008-08-10 01:00 UTC
Votes:5
Avg. Score:5.0 ± 0.0
Reproduced:5 of 5 (100.0%)
Same Version:2 (40.0%)
Same OS:2 (40.0%)
From: phpbug dot 40928 at sub dot noloop dot net Assigned:
Status: No Feedback Package: Feature/Change Request
PHP Version: 5.2.1 OS: Windows Server 2003
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: phpbug dot 40928 at sub dot noloop dot net
New email:
PHP Version: OS:

 

 [2007-03-27 13:31 UTC] phpbug dot 40928 at sub dot noloop dot net
Description:
------------
On win32, the function escapeshellarg() replaces percent characters (%) with spaces. Instead, the function should escape the percent character, perhaps using the ^% construct, so that the percent sign can be safely used as a an argument to an application executed through exec().

Reproduce code:
---------------
<?

  // .... This creates a directory called "Test dir"  (without the quotes)
  // .... which is unexpected.
  $cmd = 'md';
  $arg = 'test%dir';
  $fullcmd = $cmd.' '.escapeshellarg($arg);

  // .... This creates a directory called "Test%dir"  (without the quotes)
  // .... which is the expected result of the above.
  // $fullcmd = 'md test^%dir';

  exec($fullcmd);
  system("dir /B");

?>

Expected result:
----------------
test%dir


Actual result:
--------------
test dir


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-04-29 11:56 UTC] phpbug dot 40928 at sub dot noloop dot net
Changing email, please ignore this comment.
 [2008-08-02 19:22 UTC] kalle@php.net
Please test out 5.3 in which bug #43261 was fixed that uses the ^ escape character on Windows:
http://bugs.php.net/bug.php?id=43261
 [2008-08-10 01:00 UTC] 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".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Dec 18 11:01:28 2024 UTC