Skip to content

Commit

Permalink
fix(shareManager): Do not set default expireDate in server
Browse files Browse the repository at this point in the history
We present users with a UI to set expire date during creation, when enforced,
the frontend prevents (or should) the share from coming the server.

If somehow the share data reaches the server without an expiration date when enforced,
it should fail gracefully and not be set automatically.

Signed-off-by: fenn-cs <[email protected]>
  • Loading branch information
nfebe committed Apr 30, 2024
1 parent cb27fbc commit dbb802a
Showing 1 changed file with 0 additions and 36 deletions.
36 changes: 0 additions & 36 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -401,14 +401,6 @@ protected function validateExpirationDateInternal(IShare $share) {
}
}

// If expiredate is empty set a default one if there is a default
$fullId = null;
try {
$fullId = $share->getFullId();
} catch (\UnexpectedValueException $e) {
// This is a new share
}

if ($isRemote) {
$defaultExpireDate = $this->shareApiRemoteDefaultExpireDate();
$defaultExpireDays = $this->shareApiRemoteDefaultExpireDays();
Expand All @@ -420,15 +412,6 @@ protected function validateExpirationDateInternal(IShare $share) {
$configProp = 'internal_defaultExpDays';
$isEnforced = $this->shareApiInternalDefaultExpireDateEnforced();
}
if ($fullId === null && $expirationDate === null && $defaultExpireDate) {
$expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);
$days = (int)$this->config->getAppValue('core', $configProp, (string)$defaultExpireDays);
if ($days > $defaultExpireDays) {
$days = $defaultExpireDays;
}
$expirationDate->add(new \DateInterval('P' . $days . 'D'));
}

// If we enforce the expiration date check that is does not exceed
if ($isEnforced) {
Expand Down Expand Up @@ -487,25 +470,6 @@ protected function validateExpirationDateLink(IShare $share) {
}
}

// If expiredate is empty set a default one if there is a default
$fullId = null;
try {
$fullId = $share->getFullId();
} catch (\UnexpectedValueException $e) {
// This is a new share
}

if ($fullId === null && $expirationDate === null && $this->shareApiLinkDefaultExpireDate()) {
$expirationDate = new \DateTime('now', $this->dateTimeZone->getTimeZone());
$expirationDate->setTime(0, 0, 0);

$days = (int)$this->config->getAppValue('core', 'link_defaultExpDays', (string)$this->shareApiLinkDefaultExpireDays());
if ($days > $this->shareApiLinkDefaultExpireDays()) {
$days = $this->shareApiLinkDefaultExpireDays();
}
$expirationDate->add(new \DateInterval('P' . $days . 'D'));
}

// If we enforce the expiration date check that is does not exceed
if ($this->shareApiLinkDefaultExpireDateEnforced()) {
if ($expirationDate === null) {
Expand Down

0 comments on commit dbb802a

Please sign in to comment.