Skip to content

Commit 65e9059

Browse files
Merge pull request #50448 from nextcloud/backport/50447/stable30
[stable30] fix: Ensure `label` is always a string
2 parents 6a4f14b + 9658c05 commit 65e9059

3 files changed

Lines changed: 6 additions & 4 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -733,7 +733,10 @@ public function createShare(
733733
}
734734

735735
// If we have a label, use it
736-
if (!empty($label)) {
736+
if ($label !== '') {
737+
if (strlen($label) > 255) {
738+
throw new OCSBadRequestException('Maximum label length is 255');
739+
}
737740
$share->setLabel($label);
738741
}
739742

apps/sharebymail/lib/ShareByMailProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1005,7 +1005,7 @@ protected function createShareObject(array $data): IShare {
10051005
$share->setPassword($data['password']);
10061006
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
10071007
$share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
1008-
$share->setLabel($data['label']);
1008+
$share->setLabel($data['label'] ?? '');
10091009
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
10101010
$share->setHideDownload((bool)$data['hide_download']);
10111011

lib/private/Share20/Share.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,12 @@ 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

74+
private string $label = '';
7675
private bool $noExpirationDate = false;
7776

7877
public function __construct(

0 commit comments

Comments
 (0)