aboutsummaryrefslogtreecommitdiffstats
path: root/apps/dav/lib/comments
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@owncloud.com>2016-02-09 13:59:13 +0100
committerArthur Schiwon <blizzz@owncloud.com>2016-02-09 13:59:13 +0100
commitbbc86e0756429b4c51e245d6dcf3ad5a5a1785eb (patch)
tree74505daa8ec4089559238d1a31193599265f4c13 /apps/dav/lib/comments
parent347ad3e223e2582124d56b0d7174886bde194c16 (diff)
downloadnextcloud-server-bbc86e0756429b4c51e245d6dcf3ad5a5a1785eb.tar.gz
nextcloud-server-bbc86e0756429b4c51e245d6dcf3ad5a5a1785eb.zip
on DAV throw Bad Request if provided message is too long
Diffstat (limited to 'apps/dav/lib/comments')
-rw-r--r--apps/dav/lib/comments/commentnode.php7
-rw-r--r--apps/dav/lib/comments/commentsplugin.php3
2 files changed, 10 insertions, 0 deletions
diff --git a/apps/dav/lib/comments/commentnode.php b/apps/dav/lib/comments/commentnode.php
index d3cd53bceb1..339abc6382d 100644
--- a/apps/dav/lib/comments/commentnode.php
+++ b/apps/dav/lib/comments/commentnode.php
@@ -24,9 +24,11 @@ namespace OCA\DAV\Comments;
use OCP\Comments\IComment;
use OCP\Comments\ICommentsManager;
+use OCP\Comments\MessageTooLongException;
use OCP\ILogger;
use OCP\IUserManager;
use OCP\IUserSession;
+use Sabre\DAV\Exception\BadRequest;
use Sabre\DAV\Exception\Forbidden;
use Sabre\DAV\Exception\MethodNotAllowed;
use Sabre\DAV\PropPatch;
@@ -168,6 +170,7 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {
*
* @param $propertyValue
* @return bool
+ * @throws BadRequest
* @throws Forbidden
*/
public function updateComment($propertyValue) {
@@ -178,6 +181,10 @@ class CommentNode implements \Sabre\DAV\INode, \Sabre\DAV\IProperties {
return true;
} catch (\Exception $e) {
$this->logger->logException($e, ['app' => 'dav/comments']);
+ if($e instanceof MessageTooLongException) {
+ $msg = 'Message exceeds allowed character limit of ';
+ throw new BadRequest($msg . IComment::MAX_MESSAGE_LENGTH, 0, $e);
+ }
return false;
}
}
diff --git a/apps/dav/lib/comments/commentsplugin.php b/apps/dav/lib/comments/commentsplugin.php
index 56d94cc33e9..7abf6e71ee5 100644
--- a/apps/dav/lib/comments/commentsplugin.php
+++ b/apps/dav/lib/comments/commentsplugin.php
@@ -242,6 +242,9 @@ class CommentsPlugin extends ServerPlugin {
return $comment;
} catch (\InvalidArgumentException $e) {
throw new BadRequest('Invalid input values', 0, $e);
+ } catch (\OCP\Comments\MessageTooLongException $e) {
+ $msg = 'Message exceeds allowed character limit of ';
+ throw new BadRequest($msg . \OCP\Comments\IComment::MAX_MESSAGE_LENGTH, 0, $e);
}
}