Skip to content

Commit 69cb1e7

Browse files
committed
Returning 404 if a subnode of a non-collection is accessed.
Fixes Issue 46.
1 parent b794a54 commit 69cb1e7

File tree

3 files changed

+18
-0
lines changed

3 files changed

+18
-0
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
1.2.0beta2 (2010-05-??)
2+
* Fixed: Issue 46: Fatal error for some non-existant nodes.
23
* Updated: some example sql to include email address.
34
* Added: 208 and 508 statuscodes from RFC5842.
45
* Added: Apache2 configuration examples

lib/Sabre/DAV/ObjectTree.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public function getNodeForPath($path) {
5454
// If this part of the path is just a dot, it actually means we can skip it
5555
if ($pathPart=='.' || $pathPart=='') continue;
5656

57+
if (!($currentNode instanceof Sabre_DAV_ICollection))
58+
throw new Sabre_DAV_Exception_FileNotFound('Could not find node at path: ' . $path);
59+
5760
$currentNode = $currentNode->getChild($pathPart);
5861

5962
}

tests/Sabre/DAV/ServerSimpleTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,20 @@ function testGetDoesntExist() {
4444

4545
}
4646

47+
function testGetDoesntExist2() {
48+
49+
$serverVars = array(
50+
'REQUEST_URI' => '/test.txt/randomblbla',
51+
'REQUEST_METHOD' => 'GET',
52+
);
53+
54+
$request = new Sabre_HTTP_Request($serverVars);
55+
$this->server->httpRequest = ($request);
56+
$this->server->exec();
57+
$this->assertEquals('HTTP/1.1 404 Not Found',$this->response->status);
58+
59+
}
60+
4761
/**
4862
* This test should have the exact same result as testGet.
4963
*

0 commit comments

Comments
 (0)