Req #34945 [Opn->Fbk]: exec(): Problem with quotes in commandline

From: Date: Mon, 27 Jan 2020 12:08:10 +0000
Subject: Req #34945 [Opn->Fbk]: exec(): Problem with quotes in commandline
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225136@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=34945&edit=1

 ID:                 34945
 Updated by:         cmb@php.net
 Reported by:        mplomer at gmx dot de
 Summary:            exec(): Problem with quotes in commandline
-Status:             Open
+Status:             Feedback
 Type:               Feature/Change Request
 Package:            Program Execution
 Operating System:   WinXP
 PHP Version:        5CVS-2005-10-21 (snap)
-Assigned To:        
+Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

I don't see a need to add an option.  Regarding the original
report, the solution would be to enclose the command in another
pair of double-quotes, e.g.

  system('""D:\Program Files\fop\fop.bat" "path with blanks/to/bla.fo"
"output path/bla.pdf""');

As of PHP 5.3.11, this additional pair of double-quotes is
inserted by PHP, so the original test script should work as is.

See also <https://github.com/php/php-src/pull/5102>.


Previous Comments:
------------------------------------------------------------------------
[2010-02-03 20:21:26] mplomer at gmx dot de

Since PHP 5.2.1 the proc_open() function has a new parameter "bypass_shell", which is the
needed feature.

It would be nice to have the same solution for all other shell related functions
(exec,shell_exec,system,...). For example via a php.ini option.

------------------------------------------------------------------------
[2005-10-27 19:38:14] mplomer at gmx dot de

cmd.exe /C accepts only two quotes in a commandline. If there are more, then the first and the last
quote is removed.
This makes it impossible to pass commandlines like:
"C:/Program Files/bla/bla.exe" "c:/my files/bla.txt"

So it is IMHO the best way, if we create an option to bypass the command-interpreter.

------------------------------------------------------------------------
[2005-10-21 14:58:25] cspeer at gmx dot de

I have the same problem. I have also no solution to execute commands with many quotes.

------------------------------------------------------------------------
[2005-10-21 14:18:37] mplomer at gmx dot de

Sure, it's not directly a Bug in PHP, but it's a feature-request to workaround a
bug/feature of cmd.exe:

We need a possibility to bypass the command-interpreter for execution of commands, since cmd.exe
can't execute it complete correctly.
Or someone finds a solution to escape quotes correctly. I will check this out over the weekend ;-)

------------------------------------------------------------------------
[2005-10-21 12:58:36] tony2001@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system
is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.



------------------------------------------------------------------------


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=34945


--
Edit this bug report at https://bugs.php.net/bug.php?id=34945&edit=1


Thread (9 messages)

« previous php.bugs (#225136) next »