From 906a6612e497178e77fe9c780840ea3c6baf5e4c Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Fri, 7 Jul 2023 11:22:19 +0200 Subject: [PATCH] when reading an empty file getting EOF is not an error will allow uploading empty files via bulk upload Signed-off-by: Matthieu Gallien --- apps/dav/lib/BulkUpload/MultipartRequestParser.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/dav/lib/BulkUpload/MultipartRequestParser.php b/apps/dav/lib/BulkUpload/MultipartRequestParser.php index 7554447fc93b8..16c83fee64e31 100644 --- a/apps/dav/lib/BulkUpload/MultipartRequestParser.php +++ b/apps/dav/lib/BulkUpload/MultipartRequestParser.php @@ -211,13 +211,17 @@ private function readPartContent(int $length, string $md5): string { throw new BadRequest("Computed md5 hash is incorrect."); } - $content = stream_get_line($this->stream, $length); + if ($length === 0) { + $content = ''; + } else { + $content = stream_get_line($this->stream, $length); + } if ($content === false) { throw new Exception("Fail to read part's content."); } - if (feof($this->stream)) { + if ($length !== 0 && feof($this->stream)) { throw new Exception("Unexpected EOF while reading stream."); }