You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently trying out some functionality that's normally working fine in native filesystems. But the the problem is that ../ and ./ are not working as intended. It seems ../ is not recognized as going directory back etc.
Warning: file_get_contents(vfs://test): Failed to open stream: "org\bovigo\vfs\vfsStreamWrapper::stream_open" call failed
I expect to create the file /test. But instead the file /etc/test gets created. Is this some kind of bug? I'm currently working on a Path Traversal simulation so this would be a very nice functionality to have.
The text was updated successfully, but these errors were encountered:
This is because of #211. vfsStream doesn't support a blank name (/) for root. So what's happening is it thinks etc is root and won't let you create files above that level.
If you modify your test slightly, things work:
$root = vfsStream::setup('root'); // <-- giving a name for root is the important part$root = vfsStream::setup(); // <-- this is the same as abovemkdir($root->url() . '/etc');
file_put_contents($root->url() . '/etc/../test', 'test');
echofile_get_contents($root->url() . '/test');
If you absolutely need / as the root name "right now" you could try mockfs. It's the exact same concept as vfs, but has some key differences. The test you're trying to do here works in mockfs.
useMockFileSystem\MockFileSystemasmockfs;
mockfs::create();
mkdir('mfs:///etc'); // note the three `/`. Two are for the scheme separator, one is to designate root.file_put_contents('mfs:///etc/../test', 'test');
echofile_get_contents('mfs:///test');
// prints "test"
I'm currently trying out some functionality that's normally working fine in native filesystems. But the the problem is that ../ and ./ are not working as intended. It seems ../ is not recognized as going directory back etc.
For example this is the code i tested:
I'm getting the following error:
I expect to create the file /test. But instead the file /etc/test gets created. Is this some kind of bug? I'm currently working on a Path Traversal simulation so this would be a very nice functionality to have.
The text was updated successfully, but these errors were encountered: