Skip to content

Commit 327bf3b

Browse files
icewind1991backportbot[bot]
authored andcommitted
fix: don't put hashed password in share api response
Signed-off-by: Robin Appelman <robin@icewind.nl>
1 parent ba6e944 commit 327bf3b

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
@@ -231,10 +231,10 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
231231

232232
// "share_with" and "share_with_displayname" for passwords of link
233233
// shares was deprecated in Nextcloud 15, use "password" instead.
234-
$result['share_with'] = $share->getPassword();
234+
$result['share_with'] = $this->formatPasswordField($share->getPassword());
235235
$result['share_with_displayname'] = '(' . $this->l->t('Shared link') . ')';
236236

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

239239
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
240240

@@ -250,7 +250,7 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
250250
$result['token'] = $token;
251251
} elseif ($share->getShareType() === IShare::TYPE_EMAIL) {
252252
$result['share_with'] = $share->getSharedWith();
253-
$result['password'] = $share->getPassword();
253+
$result['password'] = $this->formatPasswordField($share->getPassword());
254254
$result['password_expiration_time'] = $share->getPasswordExpirationTime() !== null ? $share->getPasswordExpirationTime()->format(\DateTime::ATOM) : null;
255255
$result['send_password_by_talk'] = $share->getSendPasswordByTalk();
256256
$result['share_with_displayname'] = $this->getDisplayNameFromAddressBook($share->getSharedWith(), 'EMAIL');
@@ -319,6 +319,10 @@ protected function formatShare(IShare $share, ?Node $recipientNode = null): arra
319319
return $result;
320320
}
321321

322+
private function formatPasswordField(?string $password): ?string {
323+
return ($password === null) ? null : 'redacted';
324+
}
325+
322326
/**
323327
* Check if one of the users address books knows the exact property, if
324328
* not we return the full name.

0 commit comments

Comments
 (0)