[Pkg-owncloud-commits] [owncloud] 111/121: Return whole file if range request cannot be granted due to encryption

David Prévot taffit at moszumanska.debian.org
Thu Aug 21 16:44:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

taffit pushed a commit to branch master
in repository owncloud.

commit c6e87acb96dc51ff06be6e2471adb6991d4136d5
Author: Vincent Petry <pvince81 at owncloud.com>
Date:   Thu Aug 14 15:18:49 2014 +0200

    Return whole file if range request cannot be granted due to encryption
    
    Whenenver range headers are set and encryption is enabled, it is not
    possible to automatically fseek() to the proper position.
    
    To avoid returning corrupt/invalid data or causing a decryption error,
    the range headers are stripped so that the SabreDAV code in httpGet()
    returns the whole file.
    
    Backport of cc8c1d8e0776bda7f4c7c28e11984144a4861df3 from master
---
 lib/private/connector/sabre/server.php | 22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/lib/private/connector/sabre/server.php b/lib/private/connector/sabre/server.php
index aaf4fe8..43c3464 100644
--- a/lib/private/connector/sabre/server.php
+++ b/lib/private/connector/sabre/server.php
@@ -33,6 +33,11 @@ class OC_Connector_Sabre_Server extends Sabre\DAV\Server {
 	 */
 	private $overLoadedUri = null;
 
+	/**
+	 * @var boolean
+	 */
+	private $ignoreRangeHeader = false;
+
 	public function getRequestUri() {
 
 		if (!is_null($this->overLoadedUri)) {
@@ -59,6 +64,23 @@ class OC_Connector_Sabre_Server extends Sabre\DAV\Server {
 		return $result;
 	}
 
+	public function getHTTPRange() {
+		if ($this->ignoreRangeHeader) {
+			return null;
+		}
+		return parent::getHTTPRange();
+	}
+
+	protected function httpGet($uri) {
+		$range = $this->getHTTPRange();
+
+		if (OC_App::isEnabled('files_encryption') && $range) {
+			// encryption does not support range requests
+			$this->ignoreRangeHeader = true;	
+		}
+		return parent::httpGet($uri);
+	}
+
 	/**
 	 * @see \Sabre\DAV\Server
 	 */

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-owncloud/owncloud.git



More information about the Pkg-owncloud-commits mailing list