Skip to content

Commit 305e1bb

Browse files
committed
fix: Ensure label is always a string
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
1 parent 8981f32 commit 305e1bb

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

apps/files_sharing/lib/Controller/ShareAPIController.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,10 @@ public function createShare(
740740
}
741741

742742
// If we have a label, use it
743-
if (!empty($label)) {
743+
if ($label !== '') {
744+
if (strlen($label) > 255) {
745+
throw new OCSBadRequestException('Maximum label length is 255');
746+
}
744747
$share->setLabel($label);
745748
}
746749

apps/sharebymail/lib/ShareByMailProvider.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -1008,7 +1008,7 @@ protected function createShareObject(array $data): IShare {
10081008
$share->setPassword($data['password']);
10091009
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
10101010
$share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
1011-
$share->setLabel($data['label']);
1011+
$share->setLabel($data['label'] ?? '');
10121012
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
10131013
$share->setHideDownload((bool)$data['hide_download']);
10141014
$share->setReminderSent((bool)$data['reminder_sent']);

lib/private/Share20/Share.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ class Share implements IShare {
6666
private $shareTime;
6767
/** @var bool */
6868
private $mailSend;
69-
/** @var string */
70-
private $label = '';
7169
/** @var ICacheEntry|null */
7270
private $nodeCacheEntry;
7371
/** @var bool */
7472
private $hideDownload = false;
7573
private bool $reminderSent = false;
7674

75+
private string $label = '';
7776
private bool $noExpirationDate = false;
7877

7978
public function __construct(

0 commit comments

Comments
 (0)