From 600202fcb2eaca7d4807e46cd2f2034b851ed6ec Mon Sep 17 00:00:00 2001 From: SebastianKrupinski Date: Thu, 4 Jul 2024 19:45:34 -0400 Subject: [PATCH] fix(carddav): limit vcard size Signed-off-by: SebastianKrupinski --- .../lib/CardDAV/Validation/CardDavValidatePlugin.php | 2 +- .../CardDAV/Validation/CardDavValidatePluginTest.php | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php b/apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php index 635ab6fcc782a..1cf081a757d2f 100644 --- a/apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php +++ b/apps/dav/lib/CardDAV/Validation/CardDavValidatePlugin.php @@ -29,7 +29,7 @@ public function initialize(Server $server): void { public function beforePut(RequestInterface $request, ResponseInterface $response): bool { // evaluate if card size exceeds defined limit - $cardSizeLimit = $this->config->getValueInt(Application::APP_ID, 'card_size_limit', 5242880); + $cardSizeLimit = (int) $this->config->getValue(Application::APP_ID, 'card_size_limit', '5242880'); if ((int) $request->getRawServerValue('CONTENT_LENGTH') > $cardSizeLimit) { throw new Forbidden("VCard object exceeds $cardSizeLimit bytes"); } diff --git a/apps/dav/tests/unit/CardDAV/Validation/CardDavValidatePluginTest.php b/apps/dav/tests/unit/CardDAV/Validation/CardDavValidatePluginTest.php index 39155aace8bdc..b6652f187b89e 100644 --- a/apps/dav/tests/unit/CardDAV/Validation/CardDavValidatePluginTest.php +++ b/apps/dav/tests/unit/CardDAV/Validation/CardDavValidatePluginTest.php @@ -39,9 +39,9 @@ public function testPutSizeLessThenLimit(): void { // construct method responses $this->config - ->method('getValueInt') - ->with('dav', 'card_size_limit', 5242880) - ->willReturn(5242880); + ->method('getValue') + ->with('dav', 'card_size_limit', '5242880') + ->willReturn('5242880'); $this->request ->method('getRawServerValue') ->with('CONTENT_LENGTH') @@ -57,9 +57,9 @@ public function testPutSizeMoreThenLimit(): void { // construct method responses $this->config - ->method('getValueInt') - ->with('dav', 'card_size_limit', 5242880) - ->willReturn(5242880); + ->method('getValue') + ->with('dav', 'card_size_limit', '5242880') + ->willReturn('5242880'); $this->request ->method('getRawServerValue') ->with('CONTENT_LENGTH')