]> source.dussan.org Git - nextcloud-server.git/commitdiff
Make sure we only use numbers as length 1798/head
authorJoas Schilling <coding@schilljs.com>
Fri, 14 Oct 2016 07:09:21 +0000 (09:09 +0200)
committerJoas Schilling <coding@schilljs.com>
Wed, 19 Oct 2016 09:41:37 +0000 (11:41 +0200)
Signed-off-by: Joas Schilling <coding@schilljs.com>
apps/dav/lib/Connector/Sabre/QuotaPlugin.php
apps/dav/tests/unit/Connector/Sabre/QuotaPluginTest.php

index 0682fca94ea05c588fb8e0a39dd30f471987cda8..484bb5129e870334cb8b482228492d760f5ea05b 100644 (file)
@@ -120,12 +120,13 @@ class QuotaPlugin extends \Sabre\DAV\ServerPlugin {
        public function getLength() {
                $req = $this->server->httpRequest;
                $length = $req->getHeader('X-Expected-Entity-Length');
-               if (!$length) {
+               if (!is_numeric($length)) {
                        $length = $req->getHeader('Content-Length');
+                       $length = is_numeric($length) ? $length : null;
                }
 
                $ocLength = $req->getHeader('OC-Total-Length');
-               if ($length && $ocLength) {
+               if (is_numeric($length) && is_numeric($ocLength)) {
                        return max($length, $ocLength);
                }
 
index 48c920541a8591957b0af2b01c6ce4b88a946d77..89bc1ee8adb0d3d14f835d406a54af7703d57220 100644 (file)
@@ -132,6 +132,12 @@ class QuotaPluginTest extends \Test\TestCase {
                        array(512, array('CONTENT-LENGTH' => '512')),
                        array(2048, array('OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => '1024')),
                        array(4096, array('OC-TOTAL-LENGTH' => '2048', 'X-EXPECTED-ENTITY-LENGTH' => '4096')),
+                       [null, ['X-EXPECTED-ENTITY-LENGTH' => 'A']],
+                       [null, ['CONTENT-LENGTH' => 'A']],
+                       [1024, ['OC-TOTAL-LENGTH' => 'A', 'CONTENT-LENGTH' => '1024']],
+                       [1024, ['OC-TOTAL-LENGTH' => 'A', 'X-EXPECTED-ENTITY-LENGTH' => '1024']],
+                       [null, ['OC-TOTAL-LENGTH' => '2048', 'X-EXPECTED-ENTITY-LENGTH' => 'A']],
+                       [null, ['OC-TOTAL-LENGTH' => '2048', 'CONTENT-LENGTH' => 'A']],
                );
        }