thephpleague / flysystem

Abstraction for local and remote filesystems
https://flysystem.thephpleague.com
MIT License
13.31k stars 826 forks source link

flysystem-webdav - WebDAVAdapter.php - createDirectory() not working allways #1689

Open chris5560 opened 1 year ago

chris5560 commented 1 year ago

In "WebDAVAdapter.php" file, the function "createDirectory" does not work, if a directory specified for "$path" starts with a "." or "/". The function will "return" directly. Line 219 says "return" it must be "continue" and everything works fine. Please fix it. Thanks Christian

tinect commented 8 months ago

This would not only affect WebDAV, but at least also InMemory, StaticInMemory and ZipArchive.

Example test:

/**
 * @test
 *
 * @dataProvider directoryPrefixProvider
 */
public function ensure_prefixed_directories_are_created_issue_1689(string $path): void
{
    $this->runScenario(function () use ($path) {
        $adapter = $this->adapter();

        $adapter->createDirectory(
            $path.'test',
            new Config()
        );

        $this->assertTrue($adapter->directoryExists('test'));
    });
}

public static function directoryPrefixProvider(): iterable
{
    yield [ './'];
    yield [ '/'];
    yield [ '/./'];
}

And what about creating a file ./my_fily.txt. This results into errors, too.

If you think it's worth, feel free to create a PR to fix it.