when reading an empty file getting EOF is not an error

will allow uploading empty files via bulk upload

Signed-off-by: Matthieu Gallien <matthieu.gallien@nextcloud.com>
This commit is contained in:
Matthieu Gallien 2023-07-07 11:22:19 +02:00
parent 57b0bf316f
commit 4850828839

View file

@ -211,13 +211,17 @@ class MultipartRequestParser {
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.");
}