Doc #76017 [NEW]: escapeshellarg bad example + other bad examples
| From: | peter dot mlich at volny dot cz | Date: | Tue, 27 Feb 2018 12:30:39 +0000 |
| Subject: | Doc #76017 [NEW]: escapeshellarg bad example + other bad examples | ||
| Groups: | php.doc.bugs | ||
| Request: | Send a blank email to doc-bugs+get-15470@lists.php.net to get a copy of this message | ||
From: peter dot mlich at volny dot cz
Operating system:
PHP version: 7.2.2
Package: Documentation problem
Bug Type: Documentation Problem
Bug description:escapeshellarg bad example + other bad examples
Description:
------------
---
From manual page: http://www.php.net/function.exec
---
Lot of examples is very very bad. I am user. I need see, what function
produce on output. Example for escapeshellarg
Example #1 escapeshellarg() example
<?php
system('ls '.escapeshellarg($dir));
?>
Changelog...
Ups? Where is data? What do this?
My example:
$name_orig = './history/file_20170526091704.csv';
$name_new = './actual/file.csv';
$cmd = 'diff -U0 '.escapeshellarg(escapeshellcmd($name_orig)).'
'.escapeshellarg(escapeshellcmd($name_new));
echo 'cmd = ' . $cmd;
exec($cmd, $output, $status); // run operation system command
Input csv files:
a;b;c 1;2;3
u;v;w u;v;w
e;f;g 4;5;6
h;i;j 7;8;9
Produce on screen:
cmd = diff -U0 "./history/file_20170526091704.csv" "./actual/file.csv"
(escapeshellarg escape arguments for commmand. Add quotes, "text")
Produce to $output, implode('\n',$output):
(Linux diff command generate difference of files)
--- ./actual/file.csv Wed May 17 14:18:26 2017
+++ ./history/file_20170526091704.csv Tue Feb 27 09:54:26 2018
@@ -1 +1 @@
-a;b;c
+1;2;3;
@@ -3,2 +3,2 @@
-e;f;g
-h;i;j
+4;5;6
+7;8;9
I dont know, if i need for escape arguments both,
escapeshellarg(escapeshellcmd, because, i not see example output for
single or both, or not see practical example usage.
--
Edit bug report at https://bugs.php.net/bug.php?id=76017&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=76017&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=76017&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=76017&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=76017&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=76017&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=76017&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=76017&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=76017&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=76017&r=support
Expected behavior: https://bugs.php.net/fix.php?id=76017&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=76017&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=76017&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=76017&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=76017&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=76017&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=76017&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=76017&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=76017&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=76017&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=76017&r=mysqlcfg