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

From: Date: Tue, 28 Jan 2020 09:14:09 +0000
Subject: Req #34945 [Asn->Csd]: exec(): Problem with quotes in commandline
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-225184@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:        not-implemented at mark-plomer dot de
 Summary:            exec(): Problem with quotes in commandline
-Status:             Assigned
+Status:             Closed
 Type:               Feature/Change Request
 Package:            Program Execution
 Operating System:   WinXP
 PHP Version:        5CVS-2005-10-21 (snap)
 Assigned To:        cmb
 Block user comment: N
 Private report:     N

 New Comment:

Thanks!

Good things come to those who wait. :)


Previous Comments:
------------------------------------------------------------------------
[2020-01-27 21:42:37] not-implemented at mark-plomer dot de

Oh wow ... activity on my ~15 year old bug-report ;-) Yes I think it should be fine now, and you can
close the bug report as fixed :-) Thanks.

------------------------------------------------------------------------
[2020-01-27 12:08:10] cmb@php.net

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>.

------------------------------------------------------------------------
[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.

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


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 (#225184) next »