aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFerdinand Thiessen <opensource@fthiessen.de>2025-01-26 19:27:46 +0100
committerbackportbot[bot] <backportbot[bot]@users.noreply.github.com>2025-01-26 19:59:25 +0000
commit9658c051de39d3083ef69d43fb54e36a971b3090 (patch)
treec2dae881a83853f20936f9c9f5add509a1cdbb8d
parent6a4f14bb297ede7b52a7cc50c60b031980598403 (diff)
downloadnextcloud-server-backport/50447/stable30.tar.gz
nextcloud-server-backport/50447/stable30.zip
fix: Ensure `label` is always a stringbackport/50447/stable30
Signed-off-by: Ferdinand Thiessen <opensource@fthiessen.de>
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php5
-rw-r--r--apps/sharebymail/lib/ShareByMailProvider.php2
-rw-r--r--lib/private/Share20/Share.php3
3 files changed, 6 insertions, 4 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index f6c106b9b08..591ebb3f964 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -733,7 +733,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);
}
diff --git a/apps/sharebymail/lib/ShareByMailProvider.php b/apps/sharebymail/lib/ShareByMailProvider.php
index afd9e309999..3eb445908d9 100644
--- a/apps/sharebymail/lib/ShareByMailProvider.php
+++ b/apps/sharebymail/lib/ShareByMailProvider.php
@@ -1005,7 +1005,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']);
diff --git a/lib/private/Share20/Share.php b/lib/private/Share20/Share.php
index ac95e3ac0d4..35dcf6073f8 100644
--- a/lib/private/Share20/Share.php
+++ b/lib/private/Share20/Share.php
@@ -66,13 +66,12 @@ 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 string $label = '';
private bool $noExpirationDate = false;
public function __construct(