summaryrefslogtreecommitdiffstats
path: root/lib/private/comments/comment.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-02-09 03:14:30 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-02-09 03:14:30 +0100
commit347ad3e223e2582124d56b0d7174886bde194c16 (patch)
tree8f8d508d1d78a6258eb14c46a457e9bc634631b4 /lib/private/comments/comment.php
parent850ac0cf84f2492b16204b811f58a0dc7dc43b6e (diff)
downloadnextcloud-server-347ad3e223e2582124d56b0d7174886bde194c16.tar.gz
nextcloud-server-347ad3e223e2582124d56b0d7174886bde194c16.zip
Limit comment message to 1k chars
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;
}