fix: Ensure label is always a string

Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
This commit is contained in:
Ferdinand Thiessen 2025-01-26 19:27:46 +01:00
parent 8981f32358
commit 305e1bb260
No known key found for this signature in database
GPG key ID: 45FAE7268762B400
3 changed files with 6 additions and 4 deletions

View file

@ -740,7 +740,10 @@ class ShareAPIController extends OCSController {
}
// If we have a label, use it
if (!empty($label)) {
if ($label !== '') {
if (strlen($label) > 255) {
throw new OCSBadRequestException('Maximum label length is 255');
}
$share->setLabel($label);
}

View file

@ -1008,7 +1008,7 @@ class ShareByMailProvider extends DefaultShareProvider implements IShareProvider
$share->setPassword($data['password']);
$passwordExpirationTime = \DateTime::createFromFormat('Y-m-d H:i:s', $data['password_expiration_time'] ?? '');
$share->setPasswordExpirationTime($passwordExpirationTime !== false ? $passwordExpirationTime : null);
$share->setLabel($data['label']);
$share->setLabel($data['label'] ?? '');
$share->setSendPasswordByTalk((bool)$data['password_by_talk']);
$share->setHideDownload((bool)$data['hide_download']);
$share->setReminderSent((bool)$data['reminder_sent']);

View file

@ -66,14 +66,13 @@ class Share implements IShare {
private $shareTime;
/** @var bool */
private $mailSend;
/** @var string */
private $label = '';
/** @var ICacheEntry|null */
private $nodeCacheEntry;
/** @var bool */
private $hideDownload = false;
private bool $reminderSent = false;
private string $label = '';
private bool $noExpirationDate = false;
public function __construct(