From 3e8249f063a6b56506b05d91fedb6fb8ac0f57fa Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 22 Jan 2018 16:10:52 +0545 Subject: [PATCH] Fix copyNode for case of file named 0 (#1030) --- lib/DAV/Tree.php | 4 +++- tests/Sabre/DAV/TreeTest.php | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/DAV/Tree.php b/lib/DAV/Tree.php index 5d2792503f..7c04f09152 100644 --- a/lib/DAV/Tree.php +++ b/lib/DAV/Tree.php @@ -298,7 +298,9 @@ function getMultipleNodes($paths) { */ protected function copyNode(INode $source, ICollection $destinationParent, $destinationName = null) { - if (!$destinationName) $destinationName = $source->getName(); + if ((string)$destinationName === '') { + $destinationName = $source->getName(); + } if ($source instanceof IFile) { diff --git a/tests/Sabre/DAV/TreeTest.php b/tests/Sabre/DAV/TreeTest.php index e719e38d59..c70d17a222 100644 --- a/tests/Sabre/DAV/TreeTest.php +++ b/tests/Sabre/DAV/TreeTest.php @@ -24,6 +24,22 @@ function testCopy() { } + function testCopyFile() { + + $tree = new TreeMock(); + $tree->copy('hi/file', 'hi/newfile'); + + $this->assertArrayHasKey('newfile', $tree->getNodeForPath('hi')->newFiles); + } + + function testCopyFile0() { + + $tree = new TreeMock(); + $tree->copy('hi/file', 'hi/0'); + + $this->assertArrayHasKey('0', $tree->getNodeForPath('hi')->newFiles); + } + function testMove() { $tree = new TreeMock();