[Pkg-owncloud-commits] [php-sabredav] 09/42: Fatal error during PROPFIND on file with no Depth header.
David Prévot
taffit at moszumanska.debian.org
Wed Jul 23 16:41:24 UTC 2014
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 359286c6b0120eea8283923b6dfa178c2149d46b
Author: Evert Pot <me at evertpot.com>
Date: Tue May 27 00:47:44 2014 -0400
Fatal error during PROPFIND on file with no Depth header.
Fixes #459
---
lib/DAV/Server.php | 2 +-
tests/Sabre/DAV/ServerPropsTest.php | 38 +++++++++++++++++++++++++++----------
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/lib/DAV/Server.php b/lib/DAV/Server.php
index 381fba8..3c593ea 100644
--- a/lib/DAV/Server.php
+++ b/lib/DAV/Server.php
@@ -912,7 +912,7 @@ class Server extends EventEmitter {
$parentNode
]];
- if ($depth > 0 || $depth === self::DEPTH_INFINITY) {
+ if (($depth > 0 || $depth === self::DEPTH_INFINITY) && $parentNode instanceof ICollection) {
$this->addPathNodesRecursively($propFindRequests, $propFind);
}
diff --git a/tests/Sabre/DAV/ServerPropsTest.php b/tests/Sabre/DAV/ServerPropsTest.php
index 596dc14..701b284 100644
--- a/tests/Sabre/DAV/ServerPropsTest.php
+++ b/tests/Sabre/DAV/ServerPropsTest.php
@@ -32,18 +32,11 @@ class ServerPropsTest extends AbstractServer {
}
- private function sendRequest($body) {
+ private function sendRequest($body, $path = '/', $headers = ['Depth' => '0']) {
- $serverVars = array(
- 'REQUEST_URI' => '/',
- 'REQUEST_METHOD' => 'PROPFIND',
- 'HTTP_DEPTH' => '0',
- );
+ $request = new HTTP\Request('PROPFIND', $path, $headers, $body);
- $request = HTTP\Sapi::createFromServerArray($serverVars);
- $request->setBody($body);
-
- $this->server->httpRequest = ($request);
+ $this->server->httpRequest = $request;
$this->server->exec();
}
@@ -73,6 +66,31 @@ class ServerPropsTest extends AbstractServer {
}
+ public function testPropFindEmptyBodyFile() {
+
+ $this->sendRequest("", '/test2.txt', []);
+ $this->assertEquals(207, $this->response->status);
+
+ $this->assertEquals(array(
+ 'Content-Type' => 'application/xml; charset=utf-8',
+ 'DAV' => '1, 3, extended-mkcol, 2',
+ 'Vary' => 'Brief,Prefer',
+ ),
+ $this->response->headers
+ );
+
+ $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');
+
+ list($data) = $xml->xpath('/d:multistatus/d:response/d:href');
+ $this->assertEquals('/test2.txt',(string)$data,'href element should have been /');
+
+ $data = $xml->xpath('/d:multistatus/d:response/d:propstat/d:prop/d:getcontentlength');
+ $this->assertEquals(1,count($data));
+
+ }
+
function testSupportedLocks() {
$xml = '<?xml version="1.0"?>
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list