aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/comments/comment.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/comments/comment.php')
-rw-r--r--lib/private/comments/comment.php8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/private/comments/comment.php b/lib/private/comments/comment.php
index 36189d9523b..27e63c98555 100644
--- a/lib/private/comments/comment.php
+++ b/lib/private/comments/comment.php
@@ -22,6 +22,7 @@ namespace OC\Comments;
use OCP\Comments\IComment;
use OCP\Comments\IllegalIDChangeException;
+use OCP\Comments\MessageTooLongException;
class Comment implements IComment {
@@ -184,13 +185,18 @@ class Comment implements IComment {
*
* @param string $message
* @return IComment
+ * @throws MessageTooLongException
* @since 9.0.0
*/
public function setMessage($message) {
if(!is_string($message)) {
throw new \InvalidArgumentException('String expected.');
}
- $this->data['message'] = trim($message);
+ $message = trim($message);
+ if(mb_strlen($message, 'UTF-8') > IComment::MAX_MESSAGE_LENGTH) {
+ throw new MessageTooLongException('Comment message must not exceed ' . IComment::MAX_MESSAGE_LENGTH . ' characters');
+ }
+ $this->data['message'] = $message;
return $this;
}