Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions build/psalm-baseline.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4851,6 +4851,7 @@
</UndefinedInterfaceMethod>
</file>
<file src="lib/private/Share20/Manager.php">
<NullArgument occurrences="1"/>
<InvalidArgument occurrences="7">
<code>$data</code>
<code>'OCP\Share::postAcceptShare'</code>
Expand Down
9 changes: 7 additions & 2 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -1008,7 +1008,8 @@ public function updateShare(IShare $share) {
// The new password is not set again if it is the same as the old
// one.
$plainTextPassword = $share->getPassword();
if (!empty($plainTextPassword) && !$this->updateSharePasswordIfNeeded($share, $originalShare)) {
$updatedPassword = $this->updateSharePasswordIfNeeded($share, $originalShare);
if (!empty($plainTextPassword) && !$updatedPassword) {
$plainTextPassword = null;
}
if (empty($plainTextPassword) && !$originalShare->getSendPasswordByTalk() && $share->getSendPasswordByTalk()) {
Expand Down Expand Up @@ -1116,9 +1117,13 @@ private function updateSharePasswordIfNeeded(IShare $share, IShare $originalShar
$this->verifyPassword($share->getPassword());

// If a password is set. Hash it!
if ($share->getPassword() !== null) {
if (!empty($share->getPassword())) {
$share->setPassword($this->hasher->hash($share->getPassword()));

return true;
} else {
// Empty string and null are seen as NOT password protected
$share->setPassword(null);
return true;
}
} else {
Expand Down
4 changes: 2 additions & 2 deletions tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3515,7 +3515,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPassword() {
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
$manager->expects($this->never())->method('verifyPassword');
$manager->expects($this->once())->method('verifyPassword');
$manager->expects($this->never())->method('pathCreateChecks');
$manager->expects($this->never())->method('linkCreateChecks');
$manager->expects($this->never())->method('validateExpirationDateLink');
Expand Down Expand Up @@ -3587,7 +3587,7 @@ public function testUpdateShareMailEnableSendPasswordByTalkRemovingPasswordWithE
$manager->expects($this->once())->method('canShare')->willReturn(true);
$manager->expects($this->once())->method('getShareById')->with('foo:42')->willReturn($originalShare);
$manager->expects($this->once())->method('generalCreateChecks')->with($share);
$manager->expects($this->never())->method('verifyPassword');
$manager->expects($this->once())->method('verifyPassword');
$manager->expects($this->never())->method('pathCreateChecks');
$manager->expects($this->never())->method('linkCreateChecks');
$manager->expects($this->never())->method('validateExpirationDateLink');
Expand Down