From 883275da1a5bb12da6de3e64a03788a6d300d741 Mon Sep 17 00:00:00 2001 From: bohwaz Date: Sun, 12 Mar 2023 15:32:19 +0100 Subject: [PATCH] Update dependencies --- lib/KD2/WebDAV/Server.php | 19 ++++++++++++++++++- lib/KD2/WebDAV/WOPI.php | 2 +- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/lib/KD2/WebDAV/Server.php b/lib/KD2/WebDAV/Server.php index d8aa6aa..7247387 100644 --- a/lib/KD2/WebDAV/Server.php +++ b/lib/KD2/WebDAV/Server.php @@ -301,7 +301,24 @@ class Server $this->extendExecutionTime(); - $created = $this->storage->put($uri, fopen('php://input', 'r'), $hash_algo, $hash, $mtime); + $stream = fopen('php://input', 'r'); + + // mod_fcgid <= 2.3.9 doesn't handle chunked transfer encoding for PUT requests + // see https://github.com/kd2org/picodav/issues/6 + if (strstr($_SERVER['HTTP_TRANSFER_ENCODING'] ?? '', 'chunked') && PHP_SAPI == 'fpm-fcgi') { + // We can't seek here + // see https://github.com/php/php-src/issues/9441 + $l = strlen(fread($stream, 1)); + + if ($l === 0) { + throw new Exception('This server cannot accept "Transfer-Encoding: chunked" uploads (please upgrade to mod_fcgid >= 2.3.10).', 500); + } + + // reset stream + fseek($stream, 0, SEEK_SET); + } + + $created = $this->storage->put($uri, $stream, $hash_algo, $hash, $mtime); $prop = $this->storage->properties($uri, ['DAV::getetag'], 0); diff --git a/lib/KD2/WebDAV/WOPI.php b/lib/KD2/WebDAV/WOPI.php index 1a6e36d..8f86882 100644 --- a/lib/KD2/WebDAV/WOPI.php +++ b/lib/KD2/WebDAV/WOPI.php @@ -157,7 +157,7 @@ class WOPI $data['UserCanRename'] = !$data['ReadOnly']; $data['DisableCopy'] = $data['ReadOnly']; $data['UserCanNotWriteRelative'] = true; // This requires you to implement file name UI - //$data['DisablePrint'] = true; // Does not work currently + $data['DisablePrint'] = true; // Does not work currently // see https://forum.collaboraonline.com/t/cross-origin-frame-issue-when-printing-in-chrome/1514 $json = json_encode($data, JSON_PRETTY_PRINT);