Skip to content

Commit aa7e48e

Browse files
committed
fix: don't put hashed password in share api response
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent 0a24ae5 commit aa7e48e

1 file changed

Lines changed: 7 additions & 3 deletions

File tree

apps/files_sharing/lib/Controller/ShareAPIController.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,10 +273,10 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
273273

274274
// "share_with" and "share_with_displayname" for passwords of link
275275
// shares was deprecated in Nextcloud 15, use "password" instead.
276-
$result['share_with'] = $share->getPassword();
276+
$result['share_with'] = $this->formatPasswordField($share->getPassword());
277277
$result['share_with_displayname'] = '(' . $this->l->t('Shared link') . ')';
278278

279-
$result['password'] = $share->getPassword();
279+
$result['password'] = $this->formatPasswordField($share->getPassword());
280280

281281
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
282282

@@ -292,7 +292,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
292292
$result['token'] = $token;
293293
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
294294
$result['share_with'] = $share->getSharedWith();
295-
$result['password'] = $share->getPassword();
295+
$result['password'] = $this->formatPasswordField($share->getPassword());
296296
$result['password_expiration_time'] = $share->getPasswordExpirationTime() !== null ? $share->getPasswordExpirationTime()->format(\DateTime::ATOM) : null;
297297
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
298298
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
@@ -351,6 +351,10 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
351351
return $result;
352352
}
353353

354+
private function formatPasswordField(?string $password): ?string {
355+
return ($password === null) ? null : 'redacted';
356+
}
357+
354358
/**
355359
* Check if one of the users address books knows the exact property, if
356360
* not we return the full name.

0 commit comments

Comments
 (0)