Skip to content

Commit

Permalink
Merge pull request #49366 from nextcloud/fix/remove-share-hint-except…
Browse files Browse the repository at this point in the history
…ion-wrapping

fix(files_sharing): Do not wrap password policy exception into a generic one
  • Loading branch information
come-nc authored Dec 12, 2024
2 parents cba556d + 365ff40 commit 7cc8a1b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/private/Share20/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private function splitFullId($id) {
* Verify if a password meets all requirements
*
* @param string $password
* @throws \Exception
* @throws HintException
*/
protected function verifyPassword($password) {
if ($password === null) {
Expand All @@ -115,7 +115,8 @@ protected function verifyPassword($password) {
try {
$this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password));
} catch (HintException $e) {
throw new \Exception($e->getHint());
/* Wrap in a 400 bad request error */
throw new HintException($e->getMessage(), $e->getHint(), 400, $e);
}
}

Expand Down Expand Up @@ -784,7 +785,7 @@ public function createShare(IShare $share) {
* @param IShare $share
* @return IShare The share object
* @throws \InvalidArgumentException
* @throws GenericShareException
* @throws HintException
*/
public function updateShare(IShare $share, bool $onlyValid = true) {
$expirationDateUpdated = false;
Expand Down
2 changes: 1 addition & 1 deletion tests/lib/Share20/ManagerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,7 @@ public function testVerifyPasswordHookFails(): void {
$this->assertInstanceOf(ValidatePasswordPolicyEvent::class, $event);
/** @var ValidatePasswordPolicyEvent $event */
$this->assertSame('password', $event->getPassword());
throw new HintException('message', 'password not accepted');
throw new HintException('password not accepted');
}
);

Expand Down

0 comments on commit 7cc8a1b

Please sign in to comment.