aboutsummaryrefslogtreecommitdiffstats
path: root/apps/files_sharing/lib/Controller
diff options
context:
space:
mode:
authorfenn-cs <fenn25.fn@gmail.com>2024-03-20 16:41:26 +0100
committerfenn-cs <fenn25.fn@gmail.com>2024-05-23 14:11:33 +0100
commit59a5b4e0bddbc29d4e16a930972be34873a73e0c (patch)
tree49c2f2dc7ee1573b7e225f951e78e781345f244b /apps/files_sharing/lib/Controller
parent2fa099a6e1c905abe0d12167082e2946d8065a3a (diff)
downloadnextcloud-server-59a5b4e0bddbc29d4e16a930972be34873a73e0c.tar.gz
nextcloud-server-59a5b4e0bddbc29d4e16a930972be34873a73e0c.zip
fix(shareManager): Respect empty `expireDate` in server
If `expireDate` is an empty string and not `null` then the server should not set a default. Signed-off-by: fenn-cs <fenn25.fn@gmail.com>
Diffstat (limited to 'apps/files_sharing/lib/Controller')
-rw-r--r--apps/files_sharing/lib/Controller/ShareAPIController.php23
1 files changed, 15 insertions, 8 deletions
diff --git a/apps/files_sharing/lib/Controller/ShareAPIController.php b/apps/files_sharing/lib/Controller/ShareAPIController.php
index 1bdcee11c45..b9f89109304 100644
--- a/apps/files_sharing/lib/Controller/ShareAPIController.php
+++ b/apps/files_sharing/lib/Controller/ShareAPIController.php
@@ -549,7 +549,8 @@ class ShareAPIController extends OCSController {
* @param string $publicUpload If public uploading is allowed
* @param string $password Password for the share
* @param string|null $sendPasswordByTalk Send the password for the share over Talk
- * @param string $expireDate Expiry date of the share using user timezone at 00:00. It means date in UTC timezone will be used.
+ * @param ?string $expireDate The expiry date of the share in the user's timezone (UTC) at 00:00.
+ * If $expireDate is not supplied or set to `null`, the system default will be used.
* @param string $note Note for the share
* @param string $label Label for the share (only used in link and email)
* @param string|null $attributes Additional attributes for the share
@@ -571,7 +572,7 @@ class ShareAPIController extends OCSController {
string $publicUpload = 'false',
string $password = '',
?string $sendPasswordByTalk = null,
- string $expireDate = '',
+ ?string $expireDate = null,
string $note = '',
string $label = '',
?string $attributes = null
@@ -646,12 +647,18 @@ class ShareAPIController extends OCSController {
}
//Expire date
- if ($expireDate !== '') {
- try {
- $expireDateTime = $this->parseDate($expireDate);
- $share->setExpirationDate($expireDateTime);
- } catch (\Exception $e) {
- throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ if ($expireDate !== null) {
+ if ($expireDate !== '') {
+ try {
+ $expireDateTime = $this->parseDate($expireDate);
+ $share->setExpirationDate($expireDateTime);
+ } catch (\Exception $e) {
+ throw new OCSNotFoundException($this->l->t('Invalid date, date format must be YYYY-MM-DD'));
+ }
+ } else {
+ // Client sent empty string for expire date.
+ // Set noExpirationDate to true so overwrite is prevented.
+ $share->setNoExpirationDate(true);
}
}