Skip to content

Commit ca40d4b

Browse files
Merge pull request #385 from nextcloud/backport/383/stable15
[stable15] Trim the subject before encrypting the subject
2 parents 2082815 + e5a9e5b commit ca40d4b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

lib/Push.php

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,11 +187,18 @@ protected function encryptAndSign(Key $userKey, array $device, int $id, INotific
187187
$data = [
188188
'nid' => $id,
189189
'app' => $notification->getApp(),
190-
'subject' => $notification->getParsedSubject(),
190+
'subject' => '',
191191
'type' => $notification->getObjectType(),
192192
'id' => $notification->getObjectId(),
193193
];
194194

195+
// Max length of encryption is 255, so we need to shorten the subject to be shorter
196+
$subject = $notification->getParsedSubject();
197+
$dataLength = 245 - strlen(json_encode($data));
198+
if (strlen($subject) > $dataLength) {
199+
$data['subject'] = substr($subject, 0, $dataLength) . '';
200+
}
201+
195202
if ($isTalkNotification) {
196203
$priority = 'high';
197204
} else {

0 commit comments

Comments
 (0)