diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0bccc995cf..3fb37ad52d 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,6 +1,12 @@
ChangeLog
=========
+3.2.3 (????-??-??)
+------------------
+
+* #982: Make sure that files that are siblings of directories, are reported
+ as files (@nickvergessen)
+
3.2.2 (2017-02-14)
------------------
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index 6805ec0b01..f7fcf30577 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -893,15 +893,16 @@ private function generatePathNodes(PropFind $propFind, array $yieldFirst = null)
$newDepth--;
}
+ $propertyNames = $propFind->getRequestedProperties();
+ $propFindType = !empty($propertyNames) ? PropFind::NORMAL : PropFind::ALLPROPS;
+
foreach ($this->tree->getChildren($path) as $childNode) {
- $subPropFind = clone $propFind;
- $subPropFind->setDepth($newDepth);
if ($path !== '') {
$subPath = $path . '/' . $childNode->getName();
} else {
$subPath = $childNode->getName();
}
- $subPropFind->setPath($subPath);
+ $subPropFind = new PropFind($subPath, $propertyNames, $newDepth, $propFindType);
yield [
$subPropFind,
diff --git a/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php b/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
index c968e72008..f517651692 100644
--- a/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
+++ b/tests/Sabre/DAV/ServerPropsInfiniteDepthTest.php
@@ -160,4 +160,58 @@ function testUnknownProperty() {
}
+ function testFilesThatAreSiblingsOfDirectoriesShouldBeReportedAsFiles() {
+
+ $xml = '
+
+
+
+
+';
+
+ $this->sendRequest($xml);
+ $body = preg_replace("/xmlns(:[A-Za-z0-9_])?=(\"|\')DAV:(\"|\')/", "xmlns\\1=\"urn:DAV\"", $this->response->body);
+ $xml = simplexml_load_string($body);
+ $xml->registerXPathNamespace('d', 'urn:DAV');
+ $pathTests = [
+ '/d:multistatus',
+ '/d:multistatus/d:response',
+ '/d:multistatus/d:response/d:href',
+ '/d:multistatus/d:response/d:propstat',
+ '/d:multistatus/d:response/d:propstat/d:status',
+ '/d:multistatus/d:response/d:propstat/d:prop',
+ '/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype',
+ ];
+
+ $hrefPaths = [];
+
+ foreach ($pathTests as $test) {
+ $this->assertTrue(count($xml->xpath($test)) == true, 'We expected the ' . $test . ' element to appear in the response, we got: ' . $body);
+
+ if ($test === '/d:multistatus/d:response/d:href') {
+ foreach ($xml->xpath($test) as $thing) {
+ /** @var \SimpleXMLElement $thing */
+ $hrefPaths[] = strip_tags($thing->asXML());
+ }
+ } elseif ($test === '/d:multistatus/d:response/d:propstat/d:prop/d:resourcetype') {
+ $count = 0;
+ foreach ($xml->xpath($test) as $thing) {
+ /** @var \SimpleXMLElement $thing */
+ if (substr($hrefPaths[$count], -4) !== '.txt') {
+ $this->assertEquals('', $thing->asXML(), 'Path ' . $hrefPaths[$count] . ' is not reported as a directory');
+ } else {
+ $this->assertEquals('', $thing->asXML(), 'Path ' . $hrefPaths[$count] . ' is not reported as a file');
+ }
+
+ $count++;
+ }
+ }
+ }
+
+ $val = $xml->xpath('/d:multistatus/d:response/d:propstat/d:status');
+ $this->assertEquals(8, count($val), $body);
+ $this->assertEquals('HTTP/1.1 200 OK', (string)$val[0]);
+
+ }
+
}