note 81510 added to function.glob
| From: | bisqwit at iki dot fi | Date: | Sat, 01 Mar 2008 23:46:33 +0000 |
| Subject: | note 81510 added to function.glob | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-136649@lists.php.net to get a copy of this message | ||
Pomle.com wrote:
> Here's a function that behaves as a recursive glob(). It does
> rely on shell command find, but works like a charm.
> function glob_rec($pattern, $path) {
> return explode("\n", shell_exec("find $path -name $pattern"));
> }
Do note that this command has a security hole.
If the $path or $pattern given includes special characters, for example a command substitution such
as "
rm index.php", the shell will process it and execute that command.
You can fix the problem by either escaping the characters properly (use shell_escape) or by writing
a function that actually calls glob(), or opendir()/readdir()/closedir(), recursively.
----
Server IP: 62.237.7.3
Probable Submitter: 194.29.198.4
----
Manual Page -- http://www.php.net/manual/en/function.glob.php
Edit -- https://master.php.net/note/edit/81510
Del: integrated -- https://master.php.net/note/delete/81510/integrated
Del: useless -- https://master.php.net/note/delete/81510/useless
Del: bad code -- https://master.php.net/note/delete/81510/bad+code
Del: spam -- https://master.php.net/note/delete/81510/spam
Del: non-english -- https://master.php.net/note/delete/81510/non-english
Del: in docs -- https://master.php.net/note/delete/81510/in+docs
Del: other reasons-- https://master.php.net/note/delete/81510
Reject -- https://master.php.net/note/reject/81510
Search -- https://master.php.net/manage/user-notes.php