ID: 48548
User updated by: adam at e-nition dot com
Reported By: adam at e-nition dot com
Status: Open
Bug Type: Scripting Engine problem
Operating System: Linux
PHP Version: 5.2.9
New Comment:
I fully understand that as I have tried it, but the include and require
functions manage this correctly? Seems a bit silly to be able to include
a file with this type of path but not check if it exists?
Also, if this were to work this way both windows and linux setups would
match - which is always nice :)
Either way thanks for looking at it.
Adam
Previous Comments:
------------------------------------------------------------------------
[2009-06-16 13:33:53] ben at nurfuerspam dot de
This is actually not a bug, as the path cannot be traversed on a
filesystem either.
Just try it in any *nix shell for yourself:
When you call "cd fake_dir/../" you'd expect to cut off the fakepath
and stay in the same directory, but you'll get a "No such file or
directory" error instead as there is no fake_dir that could be resolved.
------------------------------------------------------------------------
[2009-06-14 16:23:50] adam at e-nition dot com
Description:
------------
The file_exists() function returns false on files that do exist but use
a directory traversal in the path. Not at the start of the path, I mean
in the middle of the path. (This type of path works fine on the include
function)
Works fine on windows apache2.2.11 php5.2.9
Reproduce code:
---------------
(Example based on a file called 'real_file.php' being placed in a
directory called 'real_dir')
$test_path = 'real_dir/fake_dir/../real_file.php',
if (file_exists($test_path)) {
echo 'File does exist<br />';
echo (@include($test_path)) ? 'File included' : 'File NOT
included';
} else {
echo 'File does Not exist<br />';
echo (@include($test_path)) ? 'File included' : 'File NOT
included';
}
Expected result:
----------------
File does exist
File included
Actual result:
--------------
File does NOT exist
File included
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48548&edit=1