From 4c88f5832ea01ec280f699301e287a79adfb6e7e Mon Sep 17 00:00:00 2001 From: Jan-Hendrik Willms <tleilax+studip@gmail.com> Date: Tue, 26 Sep 2023 12:43:19 +0000 Subject: [PATCH] fixes #3232 Closes #3232 Merge request studip/studip!2193 --- lib/classes/JsonApi/Routes/Blubber/CommentsCreate.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/classes/JsonApi/Routes/Blubber/CommentsCreate.php b/lib/classes/JsonApi/Routes/Blubber/CommentsCreate.php index 6d9502032eb..2e25d3fb527 100644 --- a/lib/classes/JsonApi/Routes/Blubber/CommentsCreate.php +++ b/lib/classes/JsonApi/Routes/Blubber/CommentsCreate.php @@ -54,9 +54,14 @@ class CommentsCreate extends JsonApiController protected function validateResourceDocument($json, $id = null) { - if (empty(self::arrayGet($json, 'data.attributes.content'))) { + if (!self::arrayHas($json, 'data.attributes.content')) { + return 'No comment provided'; + } + + if (mb_strlen(trim(self::arrayGet($json, 'data.attributes.content'))) === 0) { return 'Comment should not be empty.'; } + if (!$id && !$this->getThreadFromJson($json)) { return 'Invalid `block` relationship.'; } -- GitLab