From 79ce72507af6fcd1ac3e95c00d3cff73ce903838 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=B4me=20Chilliet?= Date: Tue, 10 Dec 2024 15:27:38 +0100 Subject: [PATCH] fix(shares): Wrap exceptions from password validation to set code to 400 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This fixes a regression that bad password returned 403 instead of 400 because of previous changes. Signed-off-by: Côme Chilliet --- lib/private/Share20/Manager.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/private/Share20/Manager.php b/lib/private/Share20/Manager.php index ea338937e2a72..219f3d86380a5 100644 --- a/lib/private/Share20/Manager.php +++ b/lib/private/Share20/Manager.php @@ -112,7 +112,12 @@ protected function verifyPassword($password) { } // Let others verify the password - $this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); + try { + $this->dispatcher->dispatchTyped(new ValidatePasswordPolicyEvent($password)); + } catch (HintException $e) { + /* Wrap in a 400 bad request error */ + throw new HintException($e->getMessage(), $e->getHint(), 400, $e); + } } /** @@ -780,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;