Bug #51068 [Ana->Csd]: DirectoryIterator glob:// don't support current path relative queries
| From: | nikic@php.net | Date: | Mon, 11 Feb 2019 14:51:40 +0000 |
| Subject: | Bug #51068 [Ana->Csd]: DirectoryIterator glob:// don't support current path relative queries | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-219503@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=51068&edit=1
ID: 51068
Updated by: nikic@php.net
Reported by: pedro dot laguna at pentura dot com
Summary: DirectoryIterator glob:// don't support current path
relative queries
-Status: Analyzed
+Status: Closed
Type: Bug
Package: SPL related
Operating System: Linux
PHP Version: 7.1.9
Block user comment: N
Private report: N
New Comment:
Automatic comment on behalf of email@ahmed.ro
Revision: http://git.php.net/?p=php-src.git;a=commit;h=ec28d4c247ef3c7ab9af41ff6e26b802694492b2
Log: Fix bug #51068 (glob:// do not support current path relative)
Previous Comments:
------------------------------------------------------------------------
[2019-01-28 02:43:38] mail at ahmed dot nu
Hi
I was trying to find small thing I can contribute with, submitted MR as for fix for this, the same
idea of aharvey patches, hopefully it is okay
https://github.com/php/php-src/pull/3767
------------------------------------------------------------------------
[2018-08-18 11:27:59] cmb@php.net
Related To: Bug #52233
------------------------------------------------------------------------
[2017-10-24 07:43:03] requinix@php.net
Related To: Bug #75210
------------------------------------------------------------------------
[2010-02-17 18:29:37] aharvey@php.net
OK, strike my last patch, since it was only half of the solution.
This is really two bugs for the price of one. The first problem is that globs without a path (such
as glob://*) always had a / prepended to their file name within
spl_filesystem_object_get_file_name(), which caused the problem in this bug: that a relative foo.txt
was resulting in a call to stat("/foo.txt"), which was obviously wrong.
The second problem is in the glob wrapper itself. php_glob_stream_path_split() had an off-by-one
error that meant that glob patterns within the root directory resulted in an empty path string, just
the same as a relative glob. This was being partially masked by the first problem, since the
automatic prepending meant that globbing the root directory worked more or less by accident.
I've added a phpt file for the reported issue. I'm unsure of the best way to attack
testing iterating over the root directory in a platform-independent manner; this may be worth
someone with more familiarity writing a test for this case (ie creating a DirectoryIterator with
glob:///* on platforms where it makes sense and seeing if the results look vaguely sensible).
So, the patches, (hopefully) ready for review and application:
Against PHP_5_3:
http://www.adamharvey.name/patches/bug-51068-5.3.patch
Against trunk:
http://www.adamharvey.name/patches/bug-51068-trunk.patch
------------------------------------------------------------------------
[2010-02-17 17:10:37] aharvey@php.net
I kept looking into this after my initial post; I wasn't quite expecting this to be assigned
quite so fast!
A quick and dirty patch against PHP_5_3 that appears to fix this is at http://www.adamharvey.name/patches/bug-51068-spl_directory.patch
-- I can cook up a .phpt to go with it pretty rapidly if desired. This also doesn't look
terribly difficult to port to trunk.
------------------------------------------------------------------------
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=51068
--
Edit this bug report at https://bugs.php.net/bug.php?id=51068&edit=1